如何引用 tcbh 定理

如何引用 tcbh 定理

我通过“\newtcbtheorem”创建了一个自定义定理环境,但引用无法正常工作。例如:

\documentclass[a4paper, 11pt]{article}
\usepackage[a4paper,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}



\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage{mathtools}
\usepackage{mdframed}
\usepackage{tcolorbox}
\usepackage[absolute,overlay]{textpos}
\usepackage{xcolor}




\tcbuselibrary{theorems}

\newtcbtheorem[number within=section]{theorem}{Theorem}%
{colback=blue!25,colframe=blue!25!black,fonttitle=\bfseries}{th}


\begin{document}


\begin{theorem}{\emph{\textbf{Fermat's Little Theorem}}}{} \label{my theorem}
    For every prime $p$ and every integer $a$ with $p \nmid a$ holds $$a^{p-1} \equiv 1 \pmod p.$$
\end{theorem}

Here we reference Theorem ~\ref{my theorem}.


\end{document}

我本以为会看到“这里我们引用了定理 0.1。”,但结果却不是这样,我不知道该怎么办。你能帮帮我吗?

答案1

不当使用\label,请关注以下标签:

\documentclass[a4paper, 11pt]{article}
\usepackage[a4paper,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}



\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage{mathtools}
\usepackage{mdframed}
\usepackage{tcolorbox}
\usepackage[absolute,overlay]{textpos}
\usepackage{xcolor}




\tcbuselibrary{theorems}

\newtcbtheorem[number within=section]{theorem}{Theorem}%
{colback=blue!25,colframe=blue!25!black,fonttitle=\bfseries}{th}


\begin{document}


\begin{theorem}{\emph{\textbf{Fermat's Little Theorem}}}{mytheorem}
    For every prime $p$ and every integer $a$ with $p \nmid a$ holds $$a^{p-1} \equiv 1 \pmod p.$$
\end{theorem}

Here we reference Theorem~\ref{th:mytheorem}.


\end{document}

输出:

在此处输入图片描述

tcolorbox有关更多详细信息,请参阅第 330 页的文档……

相关内容