我正在使用该amsthm
包。我定义了一些环境,例如
\theoremstyle{plain}
\newtheorem{theo}[subsection]{Theorem}
\newtheorem{satz}[subsection]{Satz}
编号按预期工作,将定理计数为子节。但是我还希望它们出现在目录中,就像它们是子节一样。
更新
更准确地说,假设我有以下文件:
\begin{document}
\tableofcontents
\chapter{Chapter One}
\section{Section A}
\begin{theo}[First Theorem]
Whatever.
\end{theo}
\section{Section B}
\begin{theo}[Second Theorem]
Whatever.
\end{theo}
\chapter{Chapter Two}
\section{Section A}
\begin{theo}[Third Theorem]
Whatever.
\end{theo}
\begin{theo}[Fourth Theorem]
Whatever.
\end{theo}
\end{document}
我希望我的目录看起来像这样
1. Chapter One
1.1 Section A
1.1.1 First Theorem
1.2 Section B
1.2.1 Second Theorem
2. Chapter Two
2.1 Section A
2.1.1 Third Theorem
2.1.2 Fourth Theorem
答案1
.toc
您可以通过定义辅助环境将写入内容合并到文件中;我使用它是xparse
因为它可以很容易地应对可选参数的存在。
\documentclass{article}
\usepackage{amsthm,xparse}
\usepackage{lipsum}
\theoremstyle{plain}
\newtheorem{theoaux}[subsection]{Theorem}
\NewDocumentEnvironment{theo}{o}
{\IfNoValueTF{#1}
{\theoaux\addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}Theorem}}
{\theoaux[#1]\addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}Theorem (#1)}}%
\ignorespaces}
{\endtheoaux}
\begin{document}
\tableofcontents
\section{A section}
\lipsum[1]
\subsection{A subsection}
\lipsum[2]
\subsection{A subsection}
\lipsum[3-4]
\begin{theo}\label{theo1}
$0=0$
\end{theo}
\section{Sec 2}
\lipsum[4]
\begin{theo}[B. C. Dull]\label{theo2}
$1>0$
\end{theo}
\end{document}
答案2
尝试这个:
\documentclass{report}
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{theo}[subsection]{Theorem}
\newtheorem{satz}[subsection]{Satz}
\newcommand{\counttosubsec}{\arabic{chapter}.\arabic{section}.\arabic{subsection}}
\newcommand{\addtheocontentsline}[1]{\addcontentsline{toc}{subsection}{\counttosubsec \quad Theorem~\ref{#1}}}
\newcommand{\addsatzcontentsline}[1]{\addcontentsline{toc}{subsection}{\counttosubsec \quad Satz~\ref{#1}}}
\begin{document}
\tableofcontents
\clearpage
\section{Sec 1}
\addtheocontentsline{theo1}
\begin{theo}\label{theo1}
Something
\end{theo}
\section{Sec 2}
\addsatzcontentsline{satz1}
\begin{satz}\label{satz1}
Something else
\end{satz}
\end{document}
答案3
我刚刚找到了一个可以满足我对这个问题的需求的解决方案(这里之前的任何答案都无法满足我的需求)。
这需要 amsmath 包,但其他的就不多了。在序言中,我们定义了一种新的定理风格,什么时候调用时会带有可选注释(或名称),它会将带有定理名称的一行添加到目录中。这样,只有最重要的结果(值得命名的结果)才会出现在目录中。
\newtheoremstyle{mythmstyle}%
{}%
{}%
{\it}%
{}%
{\bf}%
{}%
{ }%
{\thmname{#1}\thmnumber{ #2}%
\thmnote{: #3\addcontentsline{toc}{subsubsection}{{\it#1}: #3}}. }
\theoremstyle{mythmstyle}
\newtheorem{theorem}{Theorem}
然后在正文中,我们写类似
\begin{theorem}
A finite group is a $p$-group if and only if $\abs{G} = p^n$ for
some integer $n \ge 1$.
\end{theorem}
...
\begin{theorem}[Sylow Theorem, First]
Suppose that $\abs{G} = p^n m$, $p \nmid m$. Then
for each $1 \le i \le n$, $G$ has a subgroup $H_i$ of order $i$.
Moreover, these form a chain of normal subgroups, so that
\[ H_1 \unlhd H_2 \unlhd H_3 \unlhd \cdots \unlhd H_{n-1} \unlhd H_n \]
\end{theorem}
这样做,结合文档前面的目录,就会得到类似下面的内容: