# How to reference a tcbh theorem

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?

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:

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

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