對 \newtheorem 進行排序並重置每個小節

對 \newtheorem 進行排序並重置每個小節

這可能是一個簡單的問題,但我對 LaTeX 比較陌生,找不到如何做到這一點。

我想\newtheorem透過自然數對我的編號進行編號,但重置每個小節。

如果我將其設為:

\newtheorem{example}{Example}[subsection]

它命令它為a.b.c,而我只想要它為c

本質上,我希望對範例進行排序並重置每個小節。

任何解決方案將不勝感激,提前致謝。

答案1

name您可以透過更新來變更某些定理的編號樣式\thename。這是一個 MWE example

\documentclass{article}

\newtheorem{example}{Example}[subsection]
\renewcommand{\theexample}{\alph{subsection}}

\begin{document}
    \subsection{This is the subsection}
    \begin{example}
        Here is the example.
    \end{example}

\end{document}

其他編號樣式有\roman\Roman和。人們也可以混合這些,例如\arabic\Alph

\renewcommand{\theexample}{\arabic{section}.\alph{subsection}}

答案2

\theexample在將環境定義為以下環境的從屬之後,您想要重新定義subsection

\newtheorem{example}{Example}[subsection]
\renewcommand{\theexample}{\alph{example}}

相關內容