Brif introduction to Latex
LaTeX is a software system for document preparation. When writing, the writer uses plain text as opposed to the formatted text found in “What You See Is What You Get” word processors like Microsoft Word, LibreOffice Writer and Apple Pages.
Install and configure Latex
首先根据平台安装一个Tex的发行版,我用的Mac,所以安装的是MacTex。这个文件很大,需要一点耐心去下载和安装。然后选择一个Latex编辑器,MacTex装好后会自带一个编辑器TeXShop,一般来说已经够用了,如果你已经习惯了用别的编辑器如SublimText写代码的话,需要在对你的编辑器进行进一步的配置,具体操作请自行Google,在这里就不详细展开了。
The basic framework:
首先建立一个test.tex文件,在其中输入:
\documentclass{article}
\begin{document}
Hello world!
\end{document}
这样就生成了一个最基本的tex文件,在TeXShop中点击Typeset或者command+T快捷键(在Sublime Text中是Command+B)就可以编译并盛恒PDF了
The basic syntax
Choose the type of document
\documentclass{}规定文档的类型,可以选择文章article,也可以选择其它类型,如book、letter等等
Annotation
在每一行的末尾加上%,然后就可以添加注释了,编译后注释的内容不会出现在文档中。如果文章内容中需要使用%的话,需要在%前面加上反斜杠\。
Heading, author, and date etc.
\documentclass{article}
\title{My first Latex document}
\author{Yingshan Li}
\date{8/26/2018}
\begin{document}
\maketitle
Hello world!
\end{document}
这样就可以将文章的标题、作者、日期等信息添加到文章中了,\maketitle这个控制序列可以将这些信息按照预定的格式打印出来。
Directory
只需要在导言区中添加\tableofcontents就可以了
\documentclass{article}
\title{My first Latex document}
\author{Yingshan Li}
\date{8/26/2018}
\begin{document}
\maketitle
\tableofcontents
Hello world!
\end{document}
Chapters
\section{}
\subsection{}
\subsubsection{}
Paragraphs
\paragraph{}
\subparagraph{}
\subsubparagraph{}
Packages
当需要用到非默认存在的包时,需要在导言区中添加,如
\documentclass{article}
\usepackage{amsmath}
\title{My first Latex document}
\author{Yingshan Li}
\date{8/26/2018}
\begin{document}
\maketitle
Hello world!
\end{document}
Font
一般我们用fontspec包来设置字体
\usepackage{fontspec}
\setmainfont{Times New Roman}
字体大小
\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\large
\LARGE
\huge
\Huge
Mathmatics
插入行内公式
$ … $
Einstein 's $E=mc^2$. %equation within line
插入行间公式
[ … ]
\[ E=mc^2. \] %equation between lines
在一行中插入多个公式
\begin{displaymath}
S_{n+1} = S_{n} + S_{n} ,
S_{n}=1=2^{n}
\end{displaymath}
对行间公式进行编号
\begin{equation}
...
\end{equation}
上下标
^{} %power
_{} %下标
分式
\frac{m}{n} %n分之m
开方
\sqrt{} %开平方
\sqrt[m]{n} %n开m次方
累计求和
\sum_{i=m}^{n} %从m到n求和
累计求商
\prod_{i=m}^{n} %从m到n求商
积分
\int_{i=m}^{n} %从m到n积分
向量
\vec a %a向量
\overrightarrow{AB} %A到B的向量
省略号
a+b+\cdots+z %a+b+…+z
大括号
\underbrace{a+b+\cdots+z}_{26} %a+b+…+z
横杠
\overline{m+n} %m+n公式上面加上横杠
\underline{m+n} %m+n公式下面加上横杠
最后附上一个常用LaTeX公式和符号的链接:LaTeX公式和符号