跳转至

LaTeX 基本语法

基本构成

文档类型

\documentclass{}

规定文档的类型,一般为 article,也可以选择其它类型,如 bookletter 等等

添加注释

在每行的末尾加上 %,然后可以在后面添加注释。注释的内容不会出现在文档中。如果文章内容中需要使用 % 的话,需要在 % 前面加上反斜杠 \

添加标题、作者、日期等信息

\documentclass{article}
\title{标题}
\author{作者名}
\date{日期}
\begin{document}
\maketitle
\end{document}

\maketitle 这个控制序列可以将这些信息按照预定的格式打印出来。

添加目录

在导言区中添加 \tableofcontents

\documentclass{article}
\title{My first Latex document}
\author{Yingshan Li}
\date{8/26/2018}
\begin{document}
\maketitle
\tableofcontents
\end{document}
添加章节
\section{} 
\subsection{} 
\subsubsection{}
添加段落
\paragraph{} 
\subparagraph{} 
\subsubparagraph{}

添加包

当需要用到非默认存在的包时,需要在导言区中添加,如

\documentclass{article}
\usepackage{amsmath}
\title{My first Latex document}
\author{Yingshan Li}
\date{8/26/2018}
\begin{document}
\maketitle
\end{document}

字体设置

一般我们用 fontspec 包来设置字体

\usepackage{fontspec} 
\setmainfont{Times New Roman}
字体大小
\tiny 
\scriptsize 
\footnotesize 
\small 
\normalsize 
\large 
\large 
\LARGE 
\huge 
\Huge

添加数学公式

插入行内公式
$ ... $
插入行间公式
[ ... ]
在一行中插入多个公式
\begin{displaymath} 
S_{n+1} = S_{n} + S_{n},  
S_{n}=1=2^{n} 
\end{displaymath}
对行间公式进行编号
\begin{equation} 
... 
\end{equation}
回到页面顶部