文档结构
最小文档
\documentclass{article} \begin{document} Hello, LaTeX! \end{document}
文档类
article短文档、论文、报告
report含章节的较长文档
book含部分和章节的完整书籍
beamer幻灯片演示
letter正式信函
导言区
\documentclass[12pt, a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath, graphicx} \title{My Document} \author{Alice} \date{\today}
章节命令
\part{}最高级(book/report)
\chapter{}章(仅 report/book)
\section{}
\subsection{}小节
\subsubsection{}子小节
\paragraph{}带名称的段落
文本格式
字体样式
\textbf{bold}**粗体**
\textit{italic}*斜体*
\underline{text}下划线
\texttt{code}等宽/打字机字体
\textsc{Small Caps}小型大写字母
\emph{emphasis}强调(上下文感知斜体)
字体大小
\tiny最小
\small小于正常
\normalsize默认大小
\large / \Large大 / 更大
\huge / \Huge巨大 / 最大
间距与换行
\\换行
\newpage换页
\vspace{1cm}垂直间距
\hspace{1cm}水平间距
\noindent取消段落缩进
~不换行空格
数学模式
行内与独立公式
Inline: $E = mc^2$ or \( a^2 + b^2 = c^2 \) Display: \[ \int_0^\infty e^{-x} dx = 1 \] Numbered: \begin{equation} F = ma \label{eq:newton} \end{equation}
常用符号
^ and _上标 / 下标:x^2a_i
\frac{a}{b}分数:a/b
\sqrt{x} / \sqrt[3]{x}平方根 / 立方根
\sum_{i=1}^{n}求和
\int_a^b积分
\lim_{x \to 0}极限
\infty无穷大符号
希腊字母
\alpha \beta \gamma \delta小写希腊字母
\Gamma \Delta \Theta \Lambda大写希腊字母
\epsilon \sigma \omega \pi更多小写希腊字母
\mu \nu \rho \tau \phi统计 / 物理常用
矩阵
\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} % pmatrix = (), vmatrix = ||, Bmatrix = {}
环境
常用环境
document主内容区域
equation带编号的数学方程
align对齐的多行方程
figure浮动图形
table浮动表格
verbatim原文文本(不格式化)
abstract摘要块(article)
对齐方程
\begin{align} x &= a + b \\ y &= c + d \end{align} % & marks alignment point, \\ breaks lines
列表与表格
列表
\begin{itemize} \item Bullet point \item Another item \end{itemize} \begin{enumerate} \item First \item Second \end{enumerate}
表格
\begin{tabular}{|l|c|r|} \hline Name & Age & Score \\ \hline Alice & 25 & 88 \\ Bob & 30 & 92 \\ \hline \end{tabular}
列格式符
l / c / r左对齐 / 居中 / 右对齐
|列间竖线
p{3cm}段落列(固定宽度)
\hline水平线
\cline{2-3}部分水平线(第 2-3 列)
图形
插入图片
\usepackage{graphicx} % in preamble \begin{figure}[htbp] \centering \includegraphics[width=0.8\textwidth]{img.png} \caption{A figure caption} \label{fig:example} \end{figure}
位置说明符
h此处(近似)
t页面顶部
b页面底部
p专用浮动页
!覆盖内部限制
H精确此处(需 float 包)
交叉引用
See Figure~\ref{fig:example} on page~\pageref{fig:example}. % Requires two compilations to resolve
参考文献
BibTeX 工作流
% In .bib file: @article{smith2025, author = {Smith, John}, title = {A Great Paper}, journal = {Nature}, year = {2025} }
文档中引用
According to~\cite{smith2025} ... \bibliographystyle{plain} \bibliography{refs} % refs.bib
参考文献样式
plain编号,按字母排序
unsrt编号,按引用顺序
abbrv类似 plain,缩写姓名
apalike作者-年份格式(类 APA)
宏包
常用宏包
amsmath高级数学环境
graphicx图片插入
hyperref可点击链接与引用
geometry页边距:\usepackage[margin=1in]{geometry}
booktabs专业表格(\toprule\midrule
xcolor文本和背景颜色
listings源代码排版
tikz程序化图形与图表
babel多语言支持
natbib灵活引用(作者-年份、编号)
自定义命令
新命令
\newcommand{\R}{\mathbb{R}} % shortcut \newcommand{\norm}[1]{\|#1\|} % 1 argument Now use: $x \in \R$, $\norm{v}$
重定义与新环境
\renewcommand{\abstractname}{Summary} \newenvironment{boxed} {\begin{center}\begin{tabular}{|p{0.9\textwidth}|}\hline} {\hline\end{tabular}\end{center}}
常用快捷命令
\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}} \newcommand{\dd}[2]{\frac{d #1}{d #2}} % Usage: $\pd{f}{x}$, $\dd{y}{t}$
常见模式
标题页
\begin{document} \maketitle \tableofcontents \newpage
编译
pdflatex doc.tex编译为 PDF
bibtex doc处理参考文献
latexmk -pdf doc.tex自动编译(处理多次运行)
xelatex doc.tex支持 Unicode / 自定义字体
特殊字符
\% \$ \& \# \_转义保留字符
\textbackslash文本中的反斜杠
\{ \}字面大括号
``text''智能双引号
---破折号(em dash)
--连接号(en dash)
实用技巧
\label{} + \ref{}交叉引用任意内容
\input{file}引入另一个 .tex 文件
% comment单行注释
\usepackage{lipsum}占位文本:\lipsum[1-3]