我有 TeX,它使用 定义theorem
和assumption
环境\newtheorem
,并且它在每个定理之后正确地重置假设计数器。
编号现在方法:
- 假设 0.1 和 0.2 与定理 1 相关
- 假设 1.1 和 1.2 与定理 2 相关
但那很尴尬。更好的如果编号如下:
- 假设 1.1 和 1.2 与定理 1 相关
- 假设 2.1 和 2.2 与定理 2 相关
有没有合理的方法来实现这一点?
特克斯:
\newtheorem{theorem}{Theorem}
\newtheorem{assumption}{Assumption}[theorem]
\begin{document}
\begin{assumption} \label{a}
Object $\mathcal{A}$ is great.
\end{assumption}
\begin{assumption} \label{b}
Object $\mathcal{B}$ is truly wonderful.
\end{assumption}
\begin{theorem}
Subject to Assumptions \ref{a} and \ref{b}, $\mathcal{A} \bigoplus \mathcal{B} = \mathcal{B}$.
\end{theorem}
\begin{assumption} \label{aa}
Object $\mathfrak{A}$ is awful.
\end{assumption}
\begin{assumption} \label{bb}
Object $\mathfrak{B}$ is truly terrible.
\end{assumption}
\begin{theorem}
Subject to Assumptions \ref{aa} and \ref{bb}, $\mathfrak{A} \bigotimes \mathfrak{B} = \mathfrak{B}$.
\end{theorem}
\end{document}
如果我在开始时使用\setcounter
计数器assumption
,它会将 N 更改为 0.N。如果我\setcounter{theorem}{1}
在开始时使用,则问题仍然存在,只是偏移了 1。
答案1
DIY \theassumption
,并强制其加1。
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\newtheorem{assumption}{Assumption}[theorem]
%%%% THE KEY LINE BELOW
\renewcommand\theassumption{\the\numexpr\thetheorem + 1\relax.\arabic{assumption}}
%%%%
\begin{document}
\begin{assumption} \label{a}
Object $\mathcal{A}$ is great.
\end{assumption}
\begin{assumption} \label{b}
Object $\mathcal{B}$ is truly wonderful.
\end{assumption}
\begin{theorem}
Subject to Assumptions \ref{a} and \ref{b}, $\mathcal{A} \bigoplus \mathcal{B} = \mathcal{B}$.
\end{theorem}
\begin{assumption} \label{aa}
Object $\mathfrak{A}$ is awful.
\end{assumption}
\begin{assumption} \label{bb}
Object $\mathfrak{B}$ is truly terrible.
\end{assumption}
\begin{theorem}
Subject to Assumptions \ref{aa} and \ref{bb}, $\mathfrak{A} \bigotimes \mathfrak{B} = \mathfrak{B}$.
\end{theorem}
\end{document}
(请注意,这假设您希望始终以阿拉伯数字形式打印定理数字。)
答案2
您可以定义一个assumption
环境,将其所引用的定理的标签作为参数。
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\usepackage{refcount}
%\usepackage{hyperref}
\newtheorem{theorem}{Theorem}
\newtheorem{assumptioninner}{Assumption}
\newcounter{assumption}
\newenvironment{assumption}[1]
{% #1 is the label of the corresponding theorem
\ifcsname assumption@#1\endcsname
% not the first assumption, advance
\expandafter\xdef\csname assumption@#1\endcsname{%
\the\numexpr\csname assumption@#1\endcsname+1\relax
}%
\else
\expandafter\xdef\csname assumption@#1\endcsname{1}%
\fi
\renewcommand{\theassumptioninner}{\getrefnumber{#1}.\csname assumption@#1\endcsname}%
\assumptioninner
}
{\endassumptioninner}
\begin{document}
\begin{assumption}{first}\label{a}
Object $\mathcal{A}$ is great.
\end{assumption}
\begin{assumption}{first}\label{b}
Object $\mathcal{B}$ is truly wonderful.
\end{assumption}
\begin{assumption}{second}\label{aa}
Object $\mathfrak{A}$ is awful.
\end{assumption}
\begin{theorem}\label{first}
Subject to Assumptions \ref{a} and \ref{b},
$\mathcal{A} \bigoplus \mathcal{B} = \mathcal{B}$.
\end{theorem}
\begin{assumption}{second}\label{bb}
Object $\mathfrak{B}$ is truly terrible.
\end{assumption}
\begin{theorem}\label{second}
Subject to Assumptions \ref{aa} and \ref{bb},
$\mathfrak{A} \bigotimes \mathfrak{B} = \mathfrak{B}$.
\end{theorem}
\end{document}
我相信可能有一种方法可以根据以下定理自动对假设进行编号。如果假设不需要仅先于它们引用的定理,那就不行。
该代码已经过带有和不带有的测试hyperref
。