LaTeX\LaTeX 排版笔记

1. 习惯篇:

  • 不引用\ref不标记\label
  • 参考文献及时引用\cite
  • 数据尽量以Excel形式保存

2. 宏包篇:

  • 数学宏包:amsmath
  • 表格宏包:booktabs
  • 图片宏包:graphicx
  • 颜色宏包:color & xcolor
  • 代码宏包:listings

3. 表格篇:

  • 在线LaTeX表格生成器
  • 表格转换器
  • Excel插件(LaTeX表格转换器):GitHub项目地址
  • LaTex表格常用命令:
    • 合并单元格:\multicolumn{2}{c}{文字}\multirow{2}{*}{}
    • 划线:\cline{2-3}
    • 表格底色设置:
      宏包:\usepackage{colortbl}
      环境:\begin{tabular}\end{tabular}
      命令:\rowcolor{颜色}:用于行开头,为整行设置背景色;
      \columncolor{颜色}:用于tabular环境开头的居中参数设定区内,为整列设定背景色;
      \cellcolor{颜色}:用于每个单元格前,为最小单元格设定颜色。
      优先级:单元>行设定>列设定
    • 表格大小设置:\scalebox{0.9}{\begin{tabular}\end{tabular}}
    • 字体大小设置:\tiny \scriptsize \small \normalsize \large \Large \LARGE \huge \Huge
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
% 三线表
\begin{table}[htbp]
\centering
\caption{表注}\label{tab:1}
\begin{tabularx}{\textwidth}{YY}
\toprule
文字 & 文字\\
\midrule
文字 & 文字\\
文字 & 文字\\
\bottomrule
\end{tabularx}
\end{table}
% 表格样式2
\begin{table}[htbp]
\centering
\caption{表注}
\begin{tabularx}{\textwidth}{c@{\hspace{1pc}}|X@{\hspace{1pc}}}
\Xhline{0.1em}
符号 & \multicolumn{1}{c}{符号说明}\\
\Xhline{0.05em}
$\int$ & 积分符号\\
$\int$ & 积分符号\\
$\int$ & 积分符号\\
\Xhline{0.1em}
\end{tabularx}
\end{table}

4. 图片篇:

  • 单图插入:
1
2
3
4
5
\begin{figure}[htbp]
\centering
\includegraphics[width=0.7\textwidth]{example-image-a}
\caption{图注}\label{fig:1}
\end{figure}
  • 多图插入:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
\begin{figure} 
\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[width=0.7\textwidth]{example-image-b}
\subcaption{fig1}
\label{fig:side:a}
\end{minipage}
\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[width=0.7\textwidth]{example-image-b}
\subcaption{fig2}
\label{fig:side:b}
\end{minipage}

\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[width=0.7\textwidth]{example-image-b}
\subcaption{fig1}
\label{fig:side:c}
\end{minipage}%
\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[width=0.7\textwidth]{example-image-b}
\subcaption[1]{fig2}
\label{fig:side:d}
\end{minipage}
\caption{图注}
\end{figure}

5. 公式篇:

  • 在线图片转代码
  • 图片转代码软件
  • 公式编辑器转代码软件
  • LATEX 公式的跨栏显示:对于APS期刊(PRL,PRX,PRB,PRA,PRE…),跨栏长公式再简单不过了,仅需要\begin{widetext}就可以解决,而且格式、编号甚至分割线都自动完成,中间公式部分就用普通的公式输入命令即可,比如eqnarray,非常好用。需在aps双栏环境下,调用lipsum宏包。此方法在APS官网上也有详细说明。
1
2
3
4
5
\begin{widetext}  
\begin{eqnarray}
公式内容
\end{eqnarray}
\end{widetext}

6. 列表篇:

  • 无序列表:
1
2
3
4
5
\begin{itemize}
\item
\item
\item
\end{itemize}
  • 有序列表:
1
2
3
4
5
\begin{enumerate}
\item
\item
\item
\end{enumerate}
  • 描述列表:
1
2
3
4
5
\begin{description}
\item[条目11]
\item[条目22]
\item[条目22]
\end{description}

9. 算法步骤排版:

  • 算法步骤代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
\begin{algorithm}
\caption{误差逆传播算法}\label{alg1}
\begin{algorithmic}[0]
\Require 训练集$D={(x_k,y_k)}_{k=1}^{m}$;学习率$\eta$.
\end{algorithmic}
\begin{algorithmic}[1]
\State{在(0,1)范围内随机初始化网络中所有连接权和阈值}
\Repeat
\ForAll{$(x_k,y_k)\in D$}
\State 根据当前参数和式(5.3)计算当前样本的输出$\hat{y_k}$;
\State 根据式(5.10)计算输出层神经元的梯度项$g_j$;
\State 根据式(5.15)计算隐层神经元的梯度项$e_h$;
\State 根据式(5.11)-(5.14)更新连接权$w_{hj}$,$v_{ih}$与阈值$\theta_j,\gamma_h$
\EndFor
\Until 达到停止条件
\Ensure 连接权与阈值确定的多层前馈神经网络
\end{algorithmic}
\end{algorithm}

10. 特殊符号排版

  • 摄氏度符号:$^{\circ}$C

11. 页眉页脚设置

12. 字体更改

  • 上传字体文件更改特定字体
1
2
3
4
\documentclass{beamer}
\usepackage{ctex}
\setCJKmainfont{FandolHei} % 更改为Overleaf支持的字体
\setCJKmainfont{微软雅黑.ttf} % 更改为上传的特定字体