在 amsthm 环境中使用 \tag 吗?

在 amsthm 环境中使用 \tag 吗?

我想自定义标记定理,类似于\tag在数学环境中自定义标记方程的方式。我应该怎么做?软件包amsthm文档并未提及此类操作。

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}


\begin{document}[article]

\begin{equation}
    a + b = c \tag{A1}\label{A1}
\end{equation}

\begin{theorem}[My important theorem.]
    The universe will cease to exist tomorrow.
\end{theorem}

I would like to tag My important theorem as ``T1'', just like how I tagged \eqref{A1}.

\end{document}

在此处输入图片描述

答案1

尽管界面不如常规方程那么理想\tag,但以下内容可能就足够了:

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath,amsthm}

\newtheorem{theorem}{Theorem}
\makeatletter
\newcommand{\settheoremtag}[1]{% \settheoremtag{<tag>}
  \let\oldthetheorem\thetheorem% Store \thetheorem
  \renewcommand{\thetheorem}{#1}% Redefine it to a fixed value
  \g@addto@macro\endtheorem{% At \end{theorem}, ...
    \addtocounter{theorem}{-1}% ...restore theorem counter value and...
    \global\let\thetheorem\oldthetheorem}% ...restore \thetheorem
  }
\makeatother
\begin{document}

\begin{equation}
    a + b = c \tag{A1}\label{A1}
\end{equation}

\settheoremtag{T4}
\begin{theorem}[My important theorem]\label{thm:importantA}
    The universe will cease to exist tomorrow.
\end{theorem}

I would like to tag My important theorem as ``\ref{thm:importantA},'' just like how I tagged~\eqref{A1}.
Then there is also Theorem~\ref{thm:importantB}.

\begin{theorem}[My important theorem]\label{thm:importantB}
    The universe will cease to exist tomorrow.
\end{theorem}

\end{document}

其思想是使用 设置定理标签\settheoremtag{<tag>},然后使用该标签为后续theorem环境设置编号。在 处\end{theorem},将恢复默认设置,以便允许将常规编号的定理与固定标签的定理混合在一起。

答案2

定义一种特殊形式的定理,并通过重新定义命令来使用带有参数的新环境来设置标签\the...

\documentclass{article}
\usepackage{amsmath,amsthm}

\usepackage{hyperref} % not mandatory, just to show it works also with it

\newtheorem{theorem}{Theorem}
\newtheorem{taggedtheoremx}{Theorem}
\newenvironment{taggedtheorem}[1]
 {\renewcommand\thetaggedtheoremx{#1}\taggedtheoremx}
 {\endtaggedtheoremx}

\begin{document}

\begin{equation}
    a + b = c \tag{A1}\label{A1}
\end{equation}

\begin{taggedtheorem}{T4}[My important theorem]\label{thm:importantA}
    The universe will cease to exist tomorrow.
\end{taggedtheorem}

I would like to tag My important theorem as ``\ref{thm:importantA},'' just like how I
tagged~\eqref{A1}. Then there is also Theorem~\ref{thm:importantB}.

\begin{theorem}[My important theorem]\label{thm:importantB}
    The universe will cease to exist tomorrow.
\end{theorem}

\end{document}

在此处输入图片描述

相关内容