LaTeX 指南
本文为 LaTeX 使用指南,仅说明语法规则,不包含格式与排版建议。
参考资料
- LaTeX - A document preparation system
- KaTeX – The fastest math typesetting library for the web
- TeX - 维基百科
- LaTeX - 维基百科
- KaTeX - 维基百科
- LaTeX 数学公式大全 - 洛谷专栏
- 常用数学符号 - Baoshuo's OI Blog
简介
是一种基于 的排版系统,用于编写包含数学公式的文档。
是一个在浏览器中运行的 JavaScript 数学公式渲染库,可以在网页上渲染使用 语法编写的数学公式。
推荐两个我常用的 LaTeX 排版网站 Overleaf 和 在线 LaTeX 公式编辑器。
公式类型
行内公式
行内公式(Inline Math)是嵌入在文本中的公式,其两侧分别用 单美元符号($)标记。
$...$
行间公式
行间公式(Math Blocks)是独立成行并居中的公式,其前后分别用 双美元符号($$)标记。
$$
...
$$
tip
行内公式的“大小”(如分数的大小、巨运算符上下标的位置)通常比行间公式小。可以使用 \displaystyle 和 \textstyle 切换两种类型。
运算符号
基础
| 名称 | 演示 | 代码 |
|---|---|---|
| 加号 | + | |
| 减号 | - | |
| 乘号 | \times | |
| 点乘 | \cdot | |
| 除号 | \div | |
| 等号 | =、\eq | |
| 不等号 | \ne、\neq | |
| 约等号 | \approx | |
| 大于号 | >、\gt | |
| 小于号 | <、\lt | |
| 大于等于 | \ge、\geq | |
| 小于等于 | \le、\leq | |
| 正负号 | \pm、\plusmn | |
| 无穷 | \infty | |
| 根号 | , | \sqrt{x},\sqrt[y]{x} |
| 分数 | \frac{a}{b} | |
| 上取整 | 、 | \lceil、\rceil |
| 下取整 | 、 | \lfloor、\rfloor |
| 大括号 | , | \lbrace、\{,\rbrace、\} |
逻辑
| 名称 | 演示 | 代码 |
|---|---|---|
| 与 | \land | |
| 或 | \lor | |
| 非 | \lnot | |
| 推出 | , | \implies,\Rightarrow |
| 反推 | , | \impliedby,\Leftarrow |
| 等价 | , | \iff,\Leftrightarrow |
| 因为 | \because | |
| 所以 | \therefore |
巨运算符
求和
\sum_{i=1}^{n}a_i
http://localhost:3000
求积
\prod_{i=1}^{n}a_i
http://localhost:3000
积分
\int_{a}^{b}f(x)\mathrm{d}x
http://localhost:3000
极限
\lim_{x\to\infty}f(x)
http://localhost:3000
多行公式
递等式
\begin{aligned}
f(x) &= a \\
&= b \\
&= c
\end{aligned}
http://localhost:3000
分段函数
f(x)=
\begin{cases}
a & x>0 \\
b & x=0 \\
c & x<0
\end{cases}
http://localhost:3000
线性方程组
\begin{cases}
a_1x+b_1y+c_1z=d_1 \\
a_2x+b_2y+c_2z=d_2 \\
a_3x+b_3y+c_3z=d_3
\end{cases}
http://localhost:3000
多行公式
\begin{array}{l}
\cos\pi=1 \\
\sin^2a+\cos^2a=1 \\
\sin2a=2\sin a\cos a
\end{array}
http://localhost:3000
tip
通过调整 \begin{array} 后面的参数设置对齐方式:
{l} 表示左对齐;{c} 表示居中对齐;{r} 表示右对齐。
矩阵
\begin{bmatrix}
1 & 0 & \dots & 0 \\
0 & 1 & \dots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \dots & 1
\end{bmatrix}
http://localhost:3000
更多功能
边框
\boxed{a^2+b^2=c^2}
http://localhost:3000
颜色
{\color{White}\colorbox{Red}{FBI WARNING}}
http://localhost:3000
字体
正体
g\approx 9.8\mathrm{m/s^2}
http://localhost:3000
黑板粗体
x\in\mathbb{R}
http://localhost:3000
自定义运算符
\operatorname{lca}(6,8)=24
http://localhost:3000
编号
\tag{1}(a+b)^2=a^2+2ab+b^2
http://localhost:3000