Latex使用手册

Latex使用手册。提供了常用符号源码,常用排版源码。

AI导读:本文为LaTeX使用手册,涵盖了常用符号和排版技巧。主要内容包括数字序号及圆圈序号的用法,以及多行公式的排版方法,例如通过casesarray环境进行条件表达式的展示。此外,还提供了插入图像和表格的最佳实践,强调在生成表格时需注意\label的位置,以及表格列格式的定义。此外,文中列举了常用的数学符号、希腊字母及二元关系符和运算符的用法,旨在帮助用户更有效地使用LaTeX进行排版与公式编辑。

排版

数字序号

圆圈序号:①②③④⑤⑥⑦⑧⑨⑩

1
2
\textcircled{\scriptsize{1}}
\textcircled{\scriptsize{2}}

多行公式

公式太长一行放不下,可以分成多行

1
2
3
4
5
6
\begin{equation}
\begin{aligned}
\sum_{k \in adj(j)} x_{i,k,t+1} &= (j \mod W < W - 1) \cdot x_{i,j+1,t+1} + (j \mod W > 0) \cdot x_{i,j-1,t+1} \\
&+ (j + W < W \times H) \cdot x_{i,j+W,t+1} + (j - W \geq 0) \cdot x_{i,j-W,t+1} \\
\end{aligned}
\end{equation}
$$ \begin{equation} \begin{aligned} \sum_{k \in adj(j)} x_{i,k,t+1} &= (j \mod W < W - 1) \cdot x_{i,j+1,t+1} + (j \mod W > 0) \cdot x_{i,j-1,t+1} \\ &+ (j + W < W \times H) \cdot x_{i,j+W,t+1} + (j - W \geq 0) \cdot x_{i,j-W,t+1} \\ \end{aligned} \end{equation} $$

带大括号的多行公式

cases实现

1
2
3
4
5
6
7
8
9
\begin{equation}
\begin{aligned}
z_{ijk}=
\begin{cases}
1 & \text{若插槽$j$放置第$i$个包装需要颜色$k$} \\
0 & \text{否则} \\
\end{cases}
\end{aligned}
\end{equation}
$$ \begin{equation} \begin{aligned} z_{ijk}= \begin{cases} 1 & \text{若插槽$j$放置第$i$个包装需要颜色$k$} \\ 0 & \text{否则} \\ \end{cases} \end{aligned} \end{equation} $$

array实现(有居中的需求)

1
2
3
4
5
6
7
\begin{equation}
z_{ijk}=\left\{
\begin{array}{rc}
1 & \text{若插槽$j$放置第$i$个包装需要颜色$k$} \\
0 & \text{否则} \\
\end{array} \right.
\end{equation}
$$ \begin{equation} z_{ijk}=\left\{ \begin{array}{rc} 1& \text{若插槽$j$放置第$i$个包装需要颜色$k$} \\ 0& \text{否则} \\ \end{array} \right. \end{equation} $$

补充例子:目标函数

1
2
3
4
5
6
7
8
9
10
11
12
13
% 使用cases
\begin{equation}
\begin{aligned}
& t = \min \sum^{P-1}_{i=1} \sum^{S}_{j=1} T(u^j_{i-1}, u^j_{i}) \\
& \text{s.t.}
\begin{cases}
% 1 辅助变量u
u^{j}_{i} = \sum^{C}_{k=1} k \cdot z_{ijk} & \\
% 2 每个插槽$j$在某一时刻只能容纳一种墨盒
\sum^{C}_{k=1} z_{ijk} = 1 & \quad \forall i \in \mathcal{P}, \forall j \in \mathcal{S} \\
\end{cases}
\end{aligned}
\end{equation}
$$ \begin{equation} \begin{aligned} & t = \min \sum^{P-1}_{i=1} \sum^{S}_{j=1} T(u^j_{i-1}, u^j_{i}) \\ & \text{s.t.} \begin{cases} % 1 辅助变量u u^{j}_{i} = \sum^{C}_{k=1} k \cdot z_{ijk} & \\ % 2 每个插槽$j$在某一时刻只能容纳一种墨盒 \sum^{C}_{k=1} z_{ijk} = 1 & \quad \forall i \in \mathcal{P}, \forall j \in \mathcal{S} \\ \end{cases} \end{aligned} \end{equation} $$

插入图像

单图:

1
2
3
4
5
6
\begin{figure}[h]
\centering
\includegraphics[width=.8\textwidth]{figures/asserts/chlorine_decay_curve.png}
\caption{泳池水中余氯浓度自然衰减模型及问题一预测结果}
\label{fig:p1_cd_curve}
\end{figure}

多子图(上下):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
\begin{figure}[h]
\centering

\begin{subfigure}{\linewidth}
\includegraphics[width=\textwidth]{figures/asserts/1bg_history_data.png} % 修改
\caption{单并柜历史数据} % 需要修改:子图a的标题
\label{fig:q1_history_data_1bg} % 需要修改:子图a的Label
\end{subfigure}

\begin{subfigure}{\linewidth}
\includegraphics[width=\textwidth]{figures/asserts/2bg_history_data.png} % 修改
\caption{二并柜历史数据} % 需要修改:子图b的标题
\label{fig:q1_history_data_2bg} % 需要修改:子图b的Label
\end{subfigure}

\caption{历史数据可视化图} % 需要修改:整个图的标题
\label{fig:q1_history_data} % 需要修改:整个图的Label
\end{figure}

多子图(左右):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
\begin{figure}[h]
\centering

\begin{subfigure}{0.48\linewidth}
\includegraphics[width=1\textwidth]{figures/asserts/p2_e1_curve.png} % 修改
\caption{指数一阶衰减模型} % 需要修改:子图a的标题
\label{fig:p2_e1} % 需要修改:子图a的Label
\end{subfigure}

\hfill % 在两个子图中间添加,用于填充(1-0.48-0.48)宽度的空白
\begin{subfigure}{0.48\linewidth}
\includegraphics[width=1\textwidth]{figures/asserts/p2_e2_curve.png} % 修改
\caption{指数二阶衰减模型} % 需要修改:子图b的标题
\label{fig:p2_e2} % 需要修改:子图b的Label
\end{subfigure}

\caption{指数衰减模型拟合曲线} % 需要修改:整个图的标题
\label{fig:p2_e} % 需要修改:整个图的Label
\end{figure}

插入表格

最佳实践:先到TablesGenerator中将内容输入到可视化的界面中,然后生成latex的表格,在将\begin{tabular}{...}\end{tabular}中的内容复制到下面的模板中。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
\begin{table}[h]
\caption{LSTM模型评价} % 需要修改:表的标题
\label{tab:lstm_metric} % 需要修改:表的Label
\centering

\begin{tabular}{llll} % 需要修改:每列的长度和对其方式
\toprule
设别类型 & MAE$\downarrow$ & R2 $\uparrow$ & AdjR2 $\uparrow$ \\
\midrule
单并柜 & 9.594 & 0.9885 & 0.9885 \\
二并柜 & 6.517 & 0.9982 & 0.9982 \\
三并柜 & 24.43 & 0.8173 & 0.8172 \\
\bottomrule
\end{tabular}

\end{table}

注意:

  • \label要在\caption后一行,否则会引用不到。figure中也是。

  • \begin{tabular}{...}中的第二个大括号({})是用来定义表格的列格式和对齐方式的。

公式

常用文本/数学通用符号

符号 源码 符号 源码 符号 源码 符号 源码
{ \{ } \} $ \$ % \%
$\S$ \S$ $\P$ \P $\dots$ \dots $\cdots$ \cdots
$\dagger$ \dagger $\ddagger$ \ddagger

常用希腊字母

\Alpha,\Beta 等希腊字母符号不存在,因为它们和拉丁字母A,B 等一模一样;小写字母里也不存在\omicron,直接用拉丁字母o 代替。

源码 源码 源码 源码 源码
$\alpha$ \alpha $\beta$ \beta $\gamma$ \gamma $\delta$ \delta $\epsilon$ \epsilon
$\lambda$ \lambda $\zeta$ \zeta $\eta$ \eta $\theta$ \theta $\omega$ \omega
$\tau$ \tau $\mu$ $\mu $\xi$ \xi $\pi$ \pi $\rho$ \rho
$\sigma$ \sigma $\phi$ \phi
$\varepsilon$ \varepsilon$ $\vartheta$ \vartheta $\varphi$ \varphi
$\Gamma$ \Gamma $\Delta$ \Delta $\Theta$ \Theta $\Phi$ \Phi
$\varGamma$ \varGamma $\varPhi$ \varPhi

二元关系符

所有的二元关系符都可以加\not 前缀得到相反意义的关系符,例如\not= 就得到不等号(同\ne)。

符号 源码 符号 源码 符号 源码
< < > > = =
$\leq$ \leq $\geq$ \geq $\equiv$ \equiv
$\ll$ \ll $\gg$ \gg
$\sim$ \sim $\simeq$ \simeq $\approx$ $\approx
$\subset$ $\subset $\supset$ \supset
$\subseteq$ \subseteq $\supseteq$ $\supseteq
$\in$ \in $\ni$ $\ni $\propto$ \propto

二元运算符

符号 源码 符号 源码 符号 源码
$+$ + $-$ - $\cdot$ \cdot
$\pm$ \pm $\mp$ \mp $\div$ \div
$\cup$ \cup $\cap$ \cap $\times$ \times
$\oplus$ \oplus $\ominus$ \ominus $\uplus$ \uplus
$\odot$ \odot $\oslash$ \oslash $\otimes$ \otimes

巨算符

符号 源码 符号 源码 符号 源码
$\sum$ \sum $\bigcup$ \bigcup $\bigvee$ \bigvee
$\prod$ \prod $\bigcap$ \bigcap $\bigwedge$ \bigwedge
$\int$ \int $\biguplus$ \biguplus $\bigoplus$ \bigoplus
$\oint$ \oint $\bigotimes$ \bigotimes
$\iint$ $\iint $\bigodot$ \bigodot

数学重音符号

符号 源码 符号 源码 符号 源码
$\hat{a}$ \hat{a} $\tilde{a}$ \tilde{a} $\bar{a}$ \bar{a}
$\vec{a}$ \vec{a} $\dot{a}$ \dot{a}

其他符号

符号 源码 符号 源码 符号 源码
$\gets$ \gets $\to$ $\to $\leftrightarrow$ \leftrightarrow
$\uparrow$ \uparrow $\downarrow$ \downarrow $\rightleftharpoons$ \rightleftharpoons
$\longrightarrow$ \longrightarrow $\Rightarrow$ \Rightarrow
$\cdots$ \cdots $\vdots$ \vdots $\ddots$ \ddots
$\forall$ \forall $\exists$ \exists $\infty$ \infty
$\bot$ \bot $\angle$ \angle

参考文章:
一份(不太)简短的LATEX2ε 介绍

作者

Janki

发布于

2024-09-17

更新于

2024-09-17

许可协议

评论