我试图引用定理数
\documentclass{article}
\usepackage{amsthm}
\usepackage[bookmarks=true]{hyperref}
\usepackage[many]{tcolorbox}
\newtcbtheorem[number within=section]{Theorem}{Theorem}{
enhanced,breakable,
sharp corners,
attach boxed title to top left={
yshifttext=-1mm
},
colback=white,
colframe=blue!75!black,
fonttitle=\bfseries,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black
}
}{thm}
\begin{document}
\section{Section 1}
\subsection{Subsection 1}
\begin{Theorem}{First}{}\label{first}
test
\end{Theorem}
Here we refer Theorem \ref{first}
\begin{Theorem}{Second}{}\label{second}
test
\end{Theorem}
Here we refer Theorem \ref{second}
\end{document}
但我好像引用的是小节编号而不是定理编号。我该如何解决这个问题?
答案1
定义的正确语法是
\newtcbtheorem[init options]{Theorem box name}{Theorem title}{options}{prefix for label}
正确的用法是
\begin{foo}{title}{labelname}
当定理具有框名 foo 时。稍后,使用\ref{thm:labelname}
,假设前缀为thm
。:
会自动添加,但可以使用选项 进行更改label separator
。
话虽如此,标签是从tcbtheorem
定理的第二个参数添加的。外面将使用指向 OP 中第一个小节的\label{foo}
旧引用。\@currentlabel
\documentclass{article}
\usepackage{amsthm}
\usepackage[bookmarks=true]{hyperref}
\usepackage[many]{tcolorbox}
\newtcbtheorem[number within=section]{Theorem}{Theorem}{
enhanced,breakable,
sharp corners,
attach boxed title to top left={
yshifttext=-1mm
},
colback=white,
colframe=blue!75!black,
fonttitle=\bfseries,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black
}
}{thm}
\begin{document}
\section{Section 1}
\subsection{Subsection 1}
\begin{Theorem}{First}{first}
test
\end{Theorem}
Here we refer Theorem \ref{thm:first}
\begin{Theorem}{Second}{second}
test
\end{Theorem}
Here we refer Theorem \ref{thm:second}
\end{document}