LaTex目录中的数学

Yac*_*oby 5 math latex

我正在尝试为我的LaTex文档添加目录.我遇到的问题是这一行:

    \subsubsection{The expectation of \(X^2\)}
Run Code Online (Sandbox Code Playgroud)

在包含目录的文件中导致错误

\contentsline {subsubsection}{\numberline {1.2.3}
The expectation of \relax $X^2\relax \GenericError { }{
LaTeX Error: Bad math environment delimiter}{
    See the LaTeX manual or LaTeX Companion for explanation.}
{Your command was ignored.\MessageBreak Type I <command> <return> 
to replace it with another command,\MessageBreak or <return> to 
continue without it.}}{5}
Run Code Online (Sandbox Code Playgroud)

这导致文档无法生成.

有没有人有解决方案,在仍然有目录的情况下分段数学

Ste*_*202 7

您应该使用Amsmath内联数学分隔符$而不是\(\).从而:

\subsubsection{The expectation of $X^2$}
Run Code Online (Sandbox Code Playgroud)

注意:请务必先删除当前生成的.toc文件,否则错误不会消失.

  • `$`很好,但``[`...`\]`应该总是用在`$$`...`$$`上. (4认同)

Wil*_*son 5

如果您希望继续使用\(... \)作为数学分隔符,您可以加载(官方支持的)fixltx2e包.这是修复LaTeX go的地方,因为可能存在向后兼容性问题而无法集成到主要源中.

(简而言之,你的问题是,\(并且\)默认情况下不是"健壮",因此不能在章节标题和标题等地方使用; fixltx2e包修复此问题.)