English ·中文 ·Español ·Português ·Français ·Русский ·Deutsch ·日本語 ·Polski
Acknowledgement: Everything written below is from my own experience in college and after reading various materials. I am neither a professional nor expert, but a student who has great passion for the language. Anyone can open a discussion in the issue section, or a pull request in case something should be modified or added. If you consider my work valuable, a donation is much appreciated.
LaTeX, which is pronounced «Lah-tech» or «Lay-tech» (to rhyme with «blech»), is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents but it can be used for almost any form of publishing.
LaTeX doesn't come without drawbacks, but is still worth learning.
You will need the following things:
In addition, you need to choose a compiler. The default compiler of mosteditors is pdfLaTeX, but if you need support for Unicode or TTF/OTF fonts fromyour system, use LuaLaTeX.
Or you can choose a simple online solution like ShareLaTeX.Please look at Additional Tools for a wider variety of choices.
Let's do the traditional Hello World in LaTeX.If you have installed TexMaker, first create a new file with ending .tex
. Then type in the following code below to render "Hello World!" and run "quick build". For other LaTeX editors, it should also be easy to follow the same procedure.
\documentclass[a4paper]{article}
\begin{document}
Hello World ! % This is your content
\end{document}
It should look like this in TexMaker:
main()
in java or C++... without which the document can't be rendered.Hello World
) is simply your own content.Some languages won't work right out of the box. To use TeX with other languages, you have some options.
The first method is including "packages" (You will learn about it later) because pdfLaTeX, the default compiler, is limited to 256 characters and various encoding issues. For example:
\documentclass[a4paper]{article}
\usepackage[T5]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
Xin chào thế giới. This is Hello World in Vietnamese.
\end{document}
Here we use the packages usepackage[T5]{fontenc}
and usepackage[utf8]{inputenc}
. This is really simple to understand as the package will import font encoders to display your content correctly. If you are using TexMaker this is what the above code display:
vs without the packages
usepackage{CJKutf8}
with \begin{CJK}{UTF8}
and \end{CJK}
comes in very handy. Here's Japanese
\documentclass[a4paper]{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{min}
この記事を読んでいただきありがとうございます。
%Thank you for reading this article.
\end{CJK}
\end{document}
As easy as eating
Another method is achievable if you switch your TeX compiler to LuaLaTeX (or XeLaTeX). Using fontspec
and polyglossia
, Unicode will work out of the box:
\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage{polyglossia}
%\setmainfont[]{DejaVu Serif}
\begin{document}
Xin chào thế giới. This is Hello World in Vietnamese.
\end{document}
The default font (Latin Modern) does not support all characters. You can, however, use almost any font installed on your system by uncommenting the \setmainfont
line. (TTF and OTF fonts are fully supported).
Two common types of lists are unordered and ordered list. Each of them can be handled with ease in LaTeX document:
\begin{itemize}
\item Item.
\item Another Item.
\end{itemize}
\begin{enumerate}
\item First Item.
\item Second Item.
\end{enumerate}
Here's how two types of list display in the output:
\section
and a paragraph with \paragraph
.
\subsection
and subparagraph with \subparagraph
\tableofcontents
Example:
\newpage
if you want to make a new page.
It's as easy as pie to use footnote+label+ref to make all kinds of footnotes you want. For example:
Hi let me introduce myself\footnote{\label{myfootnote}Hello footnote}.
... (later on)
I'm referring to myself \ref{myfootnote}.
\newline
to make a new line.
LaTeX offers a lot of functions by default, but in some situations it can come in handy to use so called packages. To import a package in LaTeX, you simply add the \usepackage
Here is an example of using two packages for displaying math:
Even more epic is how circuits are displayed:
A practical example
\begin{table}[h!]
\centering
\caption{Caption for the table.}
\label{tab:table1}
\begin{tabular}{l|c||r}
1 & 2 & 3\\
\hline
a & b & c\\
\end{tabular}
\end{table}
Now let's take a closer look
\begin{table}
and \end{table}
.\centering
to keep the table at the center of the page.{l|c||r}
is where we format the content inside the table. Here we can see:
\hline
actually adds a horizontal line to separate each row.
\usepackage{booktabs}
for a visually better table.
To add an image to the LaTeX file, you need to use figure environment and the graphicx package. Use \usepackage{graphicx}
and
\begin{figure}
\includegraphics[width=\linewidth]{filename.jpg}
\caption{What is it about?}
\label{fig:whateverlabel}
\end{figure}
\begin{figure}[h!]
Here's how the image is rendered:
One aspect of text compiling that is of the utmost importance to programmers and developers is how to professionally insert codes into the document.
For LaTeX, the process is simple and very professional. We just wrap the code with some predefined content, then we are good to go.
Example:
\documentclass[a4paper]{article}
\begin{document}
Hello world!
\begin{verbatim}
#include <iostream>
int main()
{
std::cout << "hello world!\n";
return 0;
}
\end{verbatim}
\end{document}
As you can see, with the {verbatim} wrapper you can easily insert code without worrying about how the syntax is formatted. Here is how it looks out of the box, clean and professional:
This method gives you more options, including insert code inline, make custom styles code, choose a specific language for code, import code from another file within the same directory.... With this method, you dont use {verbatim}, but include a package
Consider the following example:
\documentclass[a4paper]{article}
\usepackage{listings}
\usepackage{color}
\lstdefinestyle{mystyle}{
keywordstyle=\color{magenta},
backgroundcolor=\color{yellow},
commentstyle=\color{green},
basicstyle=\footnotesize,
}
\lstset{style=mystyle}
\begin{document}
Hello world!
\begin{lstlisting}[language=Python]
print "Hello World!"
\end{lstlisting}
\lstinputlisting[language=C++]{hello.cpp}
Lorem ipsum dolor sit amet \lstinline{print "Hello World"} , consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}
From this, you can see:
\begin{lstlisting}
and end with \end{lstlisting}
lstinputlisiting{name_of_file}
[language=C++]
\lstinline
\usepackage{color}
and define your own style then define the listing with your own theme (Please look at code below). You can modify many things with your own style, but you need to read the doc for the correct property name.Here is how the code above compiles in TexMaker:
When we use LaTeX, we may face a problem that a document is too long to be handle. Therefore, we should divide the file so that its contents can be easily handled.
Let's look at the example:
% main.tex
\documentclass[a4paper]{article}
\begin{document}
Hello Latex, This is my first part.
Hello Latex, This is my second part.
\end{document}
It's just a normal LaTeX file. Now, let's divide the document into two parts using the \input
keyword:
% main.tex
\documentclass[a4paper]{article}
\begin{document}
Hello Latex, This is my first part.
\input{second_file}
\end{document}
% second_file.tex
Hello Latex, This is my second part.
Now the main file looks different, but better documented. Here is the result in TeXShop on Mac:
If you are greatly interested, more on LaTeX can be found here or all over the web, depending on your need.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSECopyright (C) 2016 Luong VoEveryone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION: You just DO WHAT THE FUCK YOU WANT TO.
关于Latex中公式的编辑可以参考博文: 1. http://blog.sina.com.cn/s/blog_5e16f1770100gror.html 2. http://www.binghe.org/2010/03/latex-equation-and-numbering/ 1. 公式居中且左对齐,align带上*号,表示省略掉公式后的编号 \begin{align*} & {{x}_{k
建议直接粘贴到自己的编辑器里面看。 % All comment lines start with % % There are no multi-line comments % LaTeX is NOT a "What You See Is What You Get" word processing software like % MS Word, or OpenOffice Writer %
在LaTeX中,可以使用\setlength{\leftmargin}{0pt}来去掉itemize环境中的缩进。具体用法为: \begin{itemize} \setlength{\leftmargin}{0pt} \item 第一项 \item 第二项 \end{itemize} 或者使用 enumitem 宏包中的 nolistsep 参数 \begin{itemize}[nolistse
记录下自己LaTex入门路上整理的一些方法和技巧。大家如果觉得有帮助,欢迎点赞和收藏~~ LaTex家族里面其实有 CTeX, MiKTeX, TeX Live等等,但是目前windows上使用的主流是 TeX Live 入门步骤 卸载 CTeX 套装,安装 TeX Live。原因及教程见:TeX Live 下载及安装说明 看完:一份其实很短的 LaTeX 入门文档,你迷惑的「CTeX 和 LaT
Latex的使用心得 最近开始学习使用latex来编辑文档,虽说好用,但是我觉得对普通人来说入门门槛还是不低的,因为这其中会有很多奇奇怪怪的问题,而这些问题的排查你是要通过日志,这个习惯或者这种做法对很多普通用户我觉得应该是少见的,毕竟多数人都是习惯,可视化操作,然后有问题就是出来一个弹框问你要怎么选择,或者告诉你除了什么问题。 使用了latex之后,我觉得其实这个latex有点像word或者
r:right y = \left\{ \begin{array}{rr} a & 12345\\ b+x & 78\\ l &910 \end{array} \right. y = { a 12345 b + x 78 l 910 y = \left\{ \begin{array}{rr} a & 12345\\ b+x & 78\\ l &910 \end{array} \right. y=
错误描述: There’s no line here to end. …k=1}\mathcal{R}^t_i(u_k) \label{Eq.10} \ 翻译: 这里没有终点线。。。k=1}\mathcal{R}^t_i(u_k)\label{Eq.10}\ 原码: \begin{equation} \centering \vspace{-0.2cm} object=\max \sum^{T}_{
latex中出现错误的位置上下文如下。 效果如图\ref{fig1}。 \begin{figure}[htb] \centering \includegraphics[width=5in]{figure/fig1.png} \caption{注释} \label{fig1} \end{figure} 我之前在另一个文档中用了同样的package,用了同样的figure环境,同样的
Latex 引入参考文献 \begin{document}报错 当你使用了以下方式导入参考文献 \bibliographystyle{unsrt} \bibliography 但你发现会报错 不要慌乱哦 检查一下你的参考文献中是否有 & 如果有 只要在文件夹中生成的 .bbl 中将& 改为 \& 进行转义就可以了 或者你可以在你的.bib 中,将你参考文献的 & 改为 \& 再次编译之前要将文件夹
部署 LaTeX 安装 texlive-core 新建 a.tex 文件,内容如下: \documentclass[11pt,a4paper]{article} %加入了一些针对XeTeX的改进并且加入了 \XeTeX 命令来输入漂亮的XeTeX logo \usepackage{xltxtra} %启用一些LaTeX中的功能 \usepackage{xunicode} %%%% fontspe
LaTeX(LATEX,音译“拉泰赫”)是一种基于TeX的排版系统。 LaTeX通过CTAN服务器发布,或作为TeX用户组(TUG)或第三方提供的许多易于安装和可用的TeX发布版本的一部分。如果您遇到问题,请访问帮助部分。 LaTeX本身并不是一个独立的排版程序,而是运行在Donald E. Knuth的TeX排版系统之上的文档准备软件。TeX发行版通常会将工作中的TeX系统所需的所有部件捆绑在一
这是我的JSON数据: 这是我的反序列化代码: 我在PageSecurity上收到错误。这是我的PageResponce类。我想我可能处理信息是正确的。我只使用过JsonObject。我想知道如何获取“page”: 0,然后如何获取“线程” } 我的页面类 公共类页面{ }
我有下面的JSON和模型类,如何使用GSOn反序列化这个JSON,下面的代码片段会出现类似“预期的BEGIN\u对象,但是BEGIN\u数组”的异常。如何为下面的JSON数据生成模型CALS
Vim + LaTeX snippets setup How I'm able to take notes in mathematics lectures using LaTeX and Vim Vim configuration Copy tex.snippets to ~/.vim/UltiSnips/ and assuming you're using Vim Plug, add the f