thmtools 不起作用的定理列表 - 插入缺少 \endcsname

thmtools 不起作用的定理列表 - 插入缺少 \endcsname

我正在嘗試生成文檔中所有方程式的列表。我已經搜尋過,似乎一個好的解決方案是使用thmtools,它可以產生所有定理的清單(如果我正確的話)。我正在尋找的是(在下面的範例中,在 CheatSheet 章節中)包含所有等式定理內容的列表,如下(使用 LaTeX 格式):

$Some_{Lowtext}$                                   (1)
$Some^{Hightext}$                                  (2)

最小(非)工作範例:

\documentclass[a4paper,12pt]{report}
\usepackage{theorem}
\newtheorem{equate}{}
\usepackage{thmtools}
\renewcommand{\listtheoremname}{List of Equations}
\begin{document}
\tableofcontents
\newpage
\chapter{Name of Chapter}
\section{Name of Section}
\subsection{Name of SubSection}
sometext
\begin{equate}
$Some_{Lowtext}$
\end{equate}
    Some other Text
\begin{equate}
$Some^{Hightext}$
\end{equate}
    And some more

\chapter{CheatSheet}

\listoftheorems

\end{document}

這給了我以下錯誤(第 24 行是 後面的行\listoftheorems):

test.tex:24: Missing \endcsname inserted. []
test.tex:24: Too many }'s. []

我想知道這是否是產生這樣一個清單的方法以及如何解決我的錯誤。

答案1

使用declaretheorem而不是\newtheorem

theorem和套件thmtools使用不同的機制來定義定理環境:Frank Mittelbach 的theorem套件使用 LaTeX 內核\newtheorem宏,而 Ulrich Schwarz 的thmtools套件提供了一個\declaretheorem宏。

thmtools套件還提供了一個\listoftheorems宏,但後者僅列出了用\declaretheorem,聲明的定理環境不是那些只是用 聲明的\newtheorem。因此,如果你想利用,你應該用's\listoftheorems來聲明你的所有定理,而不是顯式地使用。thmtools\declaretheorem\newtheorem

\documentclass[a4paper,12pt]{report}

\usepackage{thmtools}
\declaretheorem{equate}
\renewcommand{\listtheoremname}{List of Equations}

\begin{document}
\begin{equate}[Low text]
$Some_{Lowtext}$
\end{equate}
    Some other Text
\begin{equate}[High text]
$Some^{Hightext}$
\end{equate}
\listoftheorems
\end{document}

在此輸入影像描述

有關您報告的錯誤的更多詳細信息

如果\declaretheorem在輸入檔案中至少未使用一次,\listoftheorems則會產生您報告的兩個錯誤。以下是重現該問題的一些最低程式碼:

\documentclass{report}
\usepackage{thmtools}
%\declaretheorem{foo}
\begin{document}
\listoftheorems
\end{document}

如果上面程式碼的第三行未註釋,則不會產生任何錯誤。在我看來,這種行為是無意的,屬於錯誤;也許應該通知作者。

相關內容