對於我的文檔,我喜歡將所有定理環境連續計數為定義 1、定義 2、...、定理 1、定理 2、...。
我創建了一個 tcb 定理環境來執行此操作,但是,每當我引用一個定理時,它只給出該定理所在的部分 + 小節。
\documentclass[reqno, 11pt]{amsart}
\usepackage[margin=0.75in]{geometry}
\usepackage{tcolorbox}
\usepackage{hyperref}
\usepackage{nameref}
\tcbuselibrary{theorems}
\hypersetup{
colorlinks = true,
linkcolor={red!50!black}
}
\newtcbtheorem[auto counter]{thm}{Theorem}
{theorem style=plain,colframe=red!50!black,colback=red!5!white,
coltitle=red!50!black,fonttitle=\upshape\bfseries,fontupper=\itshape,boxrule=0.5pt}{}
\begin{document}
\section{First Section}
\subsection{Subsection One} \hfill
\begin{thm}{Theorem 1 Name}{} \label{thm:1}
Theorem here
\end{thm}
\begin{thm}{Theorem 2 name}{} \label{thm:2}
Theorem here
\end{thm}
By Theorem ~\ref{thm:1}, ... By Theorem ~\ref{thm:2},...
\end{document}
在此範例中,參考為定理 1 和 2 呈現 1.1。
答案1
定理環境中的第二個參數(您留空)實際上是用於標籤的。您可以指定一個前綴,就像thm
定義定理環境時一樣(最後一個參數,您也將其留空),這樣您就不必在每個標籤中重複它:
\documentclass[reqno, 11pt]{amsart}
\usepackage[margin=0.75in]{geometry}
\usepackage{tcolorbox}
\usepackage{nameref}
\tcbuselibrary{theorems}
\usepackage{hyperref}
\hypersetup{
colorlinks = true,
linkcolor={red!50!black}
}
\newtcbtheorem[auto counter]{thm}{Theorem}
{theorem style=plain,colframe=red!50!black,colback=red!5!white,
coltitle=red!50!black,fonttitle=\upshape\bfseries,fontupper=\itshape,boxrule=0.5pt}{thm}
\begin{document}
\section{First Section}
\subsection{Subsection One} \hfill
\begin{thm}{Theorem 1 Name}{duck}
Theorem here
\end{thm}
\begin{thm}{Theorem 2 name}{bear}
Theorem here
\end{thm}
By Theorem ~\ref{thm:duck}, ... By Theorem ~\ref{thm:bear},...
\end{document}