简体   繁体   English

LaTex目录中的数学

[英]Maths in LaTex table of contents

I am trying to add a table of contents for my LaTex document. 我正在尝试为我的LaTex文档添加目录。 The issue I am having is that this line: 我遇到的问题是这一行:

    \subsubsection{The expectation of \(X^2\)}

Causes an error in the file that contains the table of contents 在包含目录的文件中导致错误

\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}

Which causes the document not to be generated. 这导致文档无法生成。

Does anyone have a solution to having maths in sections while still having the table of contents 有没有人有解决方案,在仍然有目录的情况下分段数学

You should use the Amsmath inline math delimiter $ instead of \\( and \\) . 您应该使用Amsmath内联数学分隔符$而不是\\(\\) Thus: 从而:

\subsubsection{The expectation of $X^2$}

Note: be sure to remove the currently generated .toc file first, otherwise the error will not go away. 注意:请务必先删除当前生成的.toc文件,否则错误不会消失。

If you wish to continue using \\( ... \\) as your math delimiters, you can load the (officially supported) fixltx2e package. 如果您希望继续使用\\( ... \\)作为数学分隔符,则可以加载(官方支持的) fixltx2e包。 This is where fixes to LaTeX go that cannot be integrated into the main sources because of the possibility of backwards compatibility problems. 这是修复LaTeX go的地方,因为可能存在向后兼容性问题而无法集成到主要源中。

(In short, your problem is that \\( and \\) by default aren't "robust" and hence can't be used in places like section headings and captions; the fixltx2e package fixes this.) (简而言之,您的问题是\\(\\)默认情况下不是“健壮”,因此不能在章节标题和标题等地方使用; fixltx2e包修复此问题。)

Could you try again with putting the $ signs around the expression? 你可以再次尝试将$符号放在表达式周围吗? What error do you get? 你得到什么错误?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM