我正在尝试在包含 amsart 类的文档中使用来自 thmtools 包的命令 \listoftheorems。我正在通过 pdflatex 进行编译。示例
\documentclass{amsart}
\usepackage{thmtools}
\declaretheorem{theorem}
\begin{document}
\begin{theorem}[From somewhere]\label{thm1} A theorem.
\end{theorem}
\listoftheorems
\end{document}
在日志文件中生成以下错误(我复制粘贴了我认为相关的部分)。
(test2.loe
! Undefined control sequence.
\@dottedtocline ... \hbox {$\m@th \mkern \@dotsep
mu\hbox {.}\mkern \@dotsep...
l.1 ...eorem\thmtformatoptarg {From somewhere}}{1}
%
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Missing number, treated as zero.
<to be read again>
m
l.1 ...eorem\thmtformatoptarg {From somewhere}}{1}
%
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Undefined control sequence.
\@dottedtocline ...sep mu\hbox {.}\mkern \@dotsep
mu$}\hfill \nobreak \hb@xt...
l.1 ...eorem\thmtformatoptarg {From somewhere}}{1}
%
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Missing number, treated as zero.
<to be read again>
m
l.1 ...eorem\thmtformatoptarg {From somewhere}}{1}
%
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
)
\tf@loe=\write3
\openout3 = `test2.loe'.
值得注意的是两件事:
- 如果我编译上面的 MWE 时注释掉命令“\listoftheorems”,则不会出现错误,如果我然后取消注释 \listoftheorems ,然后 pdf 似乎可以正确输出,并且超链接也可以正常工作,但编译器仍然给出错误信息。
- 例如,如果我将 documentclass 替换为 article,则不会出现问题。但我需要让它与 amsart 一起工作。
请帮忙!
答案1
这里的问题是amsart
(事实上,所有 AMS 文档类)与实现“列表”的几个包之间的样式不兼容。AMS 的表格和列表类样式不使用标题和相关页码之间的点,而基本 LaTeX 类和许多包则使用点。(这也是其他问题的主题,例如listings 包的\lstlistoflistings
命令生成错误,但我还没有找到可以将其链接为重复的答案。)
提供一个修复程序来消除错误是相当容易的,但代价是不同列表之间的样式不一致。以下示例就是这样做的。使这些列表的样式并行更复杂,这里就不讨论了。
的定义\@dotsep
是从 复制而来,article.cls
并在此处定义,\providecommand
这样,如果先前加载的另一个包定义了它,它就不会被覆盖。
\documentclass{amsart}
\makeatletter
\providecommand\@dotsep{4.5}
\makeatother
\usepackage{thmtools}
\declaretheorem{theorem}
\begin{document}
\begin{theorem}[From somewhere]\label{thm1} A theorem.
\end{theorem}
\listoftheorems
\end{document}
答案2
我已添加所需更改thmtools
并发布v0.72 2020/08/01。现在\listoftheorems
在 AMS 类中使用的样式将类似于表格和图形列表。相关更改可在此处查看犯罪。
完整示例:
\documentclass{amsart}
\usepackage{thmtools}
\declaretheorem{theorem}
\declaretheorem[numbered=no]{definition}
\begin{document}
\listoffigures
\listoftheorems
\listoftheorems[title={List of Theorems (number swapped)}, swapnumber]
\section{title}
\subsection{title}
\begin{figure}[b]
content
\caption{Figure caption}
\end{figure}
\begin{theorem}[Numbered]
A theorem.
\end{theorem}
\begin{definition}[Unnumbered]
A definition.
\end{definition}
\end{document}