AMSTHM 和 AMS latex 总体上可以很好地计算定理。例如“按节编号”或“按子节编号”。为了满足多位作者的需求,我需要同时执行这两个操作。例如:子节计数中的定理 4.2.1.5 可能是按节计数中的定理 4.23。我想使用子节计数,但显示两个计数:定理 4.2.1.5(又名 4.23)。我知道我需要定义一个新的计数器,但我不明白如何才能得到正确的值。任何提示都将不胜感激。
答案1
你可以将你的定理封装在另一个环境中,从而改变编号,例如:
\documentclass{article}
\usepackage{amsmath}
\newtheorem{stheorem}{Theorem}[section]
\newcounter{dctheorem}[subsubsection]
\counterwithin{dctheorem}{subsection}
\newenvironment{dctheorem}{%
\ifnum \value{subsection}>0
\stepcounter{dctheorem}%
\ifnum \value{subsubsection}>0
\renewcommand*{\thestheorem}{\thesubsubsection.\arabic{dctheorem} (aka
\thesection.\arabic{stheorem})}%
\else
\renewcommand*{\thestheorem}{\thesubsection.\arabic{dctheorem} (aka
\thesection.\arabic{stheorem})}%
\fi
\fi
\stheorem
}{%
\endstheorem
}
\begin{document}
\section{Referencing}
See the theorems \ref{th:section}, \ref{th:subsectionA}, \ref{th:subsectionB},
\ref{th:subsubsectionA}, and \ref{th:subsubsectionB}.
\section{Test Section}
\begin{dctheorem}\label{th:section}
This is a test theorem at section level.
\end{dctheorem}
\subsection{Test Subsection}
\begin{dctheorem}\label{th:subsectionA}
This is a test theorem at subsection level.
\end{dctheorem}
\subsubsection{Test Subsubsection}
\begin{dctheorem}\label{th:subsubsectionA}
This is a test theorem at subsubsection level.
\end{dctheorem}
\begin{dctheorem}\label{th:subsubsectionB}
This is another test theorem at subsubsection level.
\end{dctheorem}
\subsection{Second Test Subsection}
\begin{dctheorem}\label{th:subsectionB}
This is a test theorem at subsection level.
\end{dctheorem}
\end{document}