是一个排版系统。

笔记

Limit controls must follow a math operator

\limits 用于使下标出现在运算符的下面。\limits 之前的符号需要是一个 math operator。所以需要这样定义

\mathop{\mathrm{arg\,min}}\limits_{0≤j<i}(D(j))

表格

合并单元格

\multicolumn{3}{l}{Stuff that spans 3 columns, left aligned}

tabular @{}

在 tabular 的参数中使用 @{} 可以移除对应列之间或者表格左右的空白。1

表格标题换行

无需宏包的做法:

  1. 使用 \shortstack 命令,缺点为无法调整竖直方向的对齐,其它单行标题靠下。

    \begin{tabular}{ll}
      \shortstack{ABC\\DEF} & GHI \\
      \hline
      cell                  & cell \\
    \end{tabular}

    效果为

    ABC
    DEF  GHI
    ---------
    cell cell
    
  2. tabular 环境第一个参数中使用 p{3cm} 指定单元格的宽度,可用 \newline 手动换行。

用 makecell 宏包:\makecell{ABC\\DEF} 两行间距较大,用 \\[-1ex] 暂时解决。

调整段间距

\setlength{\parskip}{8pt}

\newcommand\newcommand* 的区别

\newcommand 定义体中可以出现分段,\newcommand* 定义体中不能。2为了快速地排查错误,一般只要允许都应使用带 * 的版本。

\newcommand{\examplea}[1]{% #1 可以包含 \par
}
\newcommand*{\exampleb}[1]{% #1 不能包含 \par
}

禁用连字(ligature)

虽然连字是一种 feature,但是有的时候不需要连字。

  • f\/f 字母间距偏大,\/ 原本是用来修正斜体与直立体字符间距的 3
  • f{}f 可能在 pdfLaTeX 和 LuaLaTeX 不可用 4
  • \hbox{f}f

\{\lbrace 的区别 5

  • \{ 能在文本模式和数学模式中使用
  • \lbrace 只能在数学模式中使用

宏包

algorithm2e

参见主条目 LaTeX algorithm2e

ctex

汉字字宽被存于 \ccwd 中。6

工具

texcount

包括 include 文件的字数:

texcount -inc main.tex

简略输出:

texcount -inc -brief main.tex

Tables Generator

网站。用于生成 LaTeX 表格。支持从 Google Docs 中复制,可调整对齐选项等等。可在工具栏右边选择使用 booktabs 风格的表格。

Footnotes

  1. Why do people insert @{} in table preamble?

  2. What’s the difference between \newcommand and \newcommand*?

  3. LaTeX sequence /?

  4. How do I disable ligatures? Mico 的评论

  5. { & } vs \lbrace & \rbrace

  6. ctex 宏包文档第 1 章第 8 节 8.1 字号与间距