1

I created a customised theorem environment via "\newtcbtheorem", however the referencing does not work properly. For example:

\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}

Here I would expect to see "Here we reference Theorem 0.1 .", but it does not work out and I do not know what to do. Could you please help me?

1 Answer 1

3

Improper usage of \label, please follow the below tags:

\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}

Output:

enter image description here

For further details, refer the documentation of tcolorbox page number 330...

1
  • 1
    Thanks a lot for your help, now it wokrs :) .
    – 3nondatur
    Commented Sep 20, 2019 at 9:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .