使用 thmtools 时出现 LaTeX 错误:缺少 \begin{document}

使用 thmtools 时出现 LaTeX 错误:缺少 \begin{document}

开始使用该thmtools包时,我遇到了LaTeX Error: Missing \begin{document}.以下最小示例。

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}

\declaretheorem[within=section]{theorem}
\declaretheorem[within=section,sibling=theorem]{corollary}

\begin{document}

\begin{theorem}
This is a theorem.
\end{theorem}

\begin{corollary}
This is a corollary.
\end{corollary}

\end{document}

为什么会出现错误?我该如何修复该文档?

(我已经找到了答案,但我认为这也可能是其他人遇到的问题 - 因为我没有通过谷歌找到任何关于此问题的信息,所以我问了这个问题,如果没有其他人回答,我就会回答)

答案1

withinsibling,都为该定理分配了一个反面,而将两者都分配给同一个定理是没有意义的,如Thmtools 文档,第 14 页

正如评论中明确指出的那样,软件包作者已收到有关建议的通知,以给出比当前更好的警告消息,而当前警告消息只会给整个文档带来错误。

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}

\declaretheorem[within=section]{theorem}
\declaretheorem[sibling=theorem]{corollary}

\begin{document}

\begin{theorem}
This is a theorem.
\end{theorem}

\begin{corollary}
This is a corollary.
\end{corollary}

\end{document}

相关内容