# How to start the equation numbering in the new box with $1$ again?

\documentclass[12pt, a4paper, UTF8, scheme = plain]{ctexrep}
\usepackage{graphicx}
\usepackage{tcolorbox}
\tcbuselibrary{skins,xparse,breakable}
\tcbset{%
colback      = white,
colframe     = black,
title filled = false,
colbacktitle = white,
breakable,
enhanced
}%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
\NewTColorBox[
auto counter,
%   number within    = tcolorbox,         %section ? chapter ? tcolorbox?
number freestyle = {Example \,\noexpand\arabic{\tcbcounter} }
]{example}{ O{}mo }{
fonttitle       = \bfseries,
coltitle        = black,
title           = {\thetcbcounter: #2},
#1
}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{example}{box 1}
$$a + b = c$$
$$a + b = c$$
$$a + b = c$$
\end{example}
How to start the equation numbering in the new box with $1$ again?
\begin{example}{box 2}
$$a^2 + b^2 = c^2$$
$$a^3 + b^3 = c^3$$
$$a + b = c$$
\end{example}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Is there an option for this in number within? I checked the manual but there was very little about it...

Reset the equation counter to 0 in the title of the \NewTColorBox.

\documentclass[12pt, a4paper, UTF8, scheme = plain]{ctexrep}
\usepackage{graphicx}
\usepackage{tcolorbox}
\tcbuselibrary{skins,xparse,breakable}
\tcbset{%
colback      = white,
colframe     = black,
title filled = false,
colbacktitle = white,
breakable,
enhanced
}%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
\NewTColorBox[
auto counter,
%   number within    = tcolorbox,         %section ? chapter ? tcolorbox?
number freestyle = {Example \,\noexpand\arabic{\tcbcounter} }
]{example}{ O{}mo }{
fonttitle       = \bfseries,
coltitle        = black,
title           = {\thetcbcounter: #2\setcounter{equation}{0}},
#1
}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{example}{box 1}
$$a + b = c$$
$$a + b = c$$
$$a + b = c$$
\end{example}
How to start the equation numbering in the new box with $1$ again?
\begin{example}{box 2}
$$a^2 + b^2 = c^2$$
$$a^3 + b^3 = c^3$$
$$a + b = c$$
\end{example}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}%%%%%%%%%%


• I thought there might be an option for that ... haha. As simple as this would do. Commented May 30, 2023 at 14:36

You should define a special counters for equations inside the boxes. It's not difficult to replace the equation counter with the special counter, that's reset at each example environment.

I also add support for hyperref.

\documentclass{article}
\usepackage{graphicx}
\usepackage{tcolorbox}
\tcbuselibrary{skins,xparse,breakable}

\usepackage{hyperref}

\tcbset{
colback      = white,
colframe     = black,
title filled = false,
colbacktitle = white,
breakable,
enhanced
}
\NewTColorBox[
auto counter,
number freestyle = {Example \noexpand\arabic{\tcbcounter}}
]{example}{ O{}mo }{
fonttitle = \bfseries,
coltitle  = black,
title     = {\thetcbcounter: #2},
#1
}

\newcounter{boxequation}
\setcounter{boxequation}{0}%
\ExpandArgs{cc}\let{c@equation}{c@boxequation}%
% comment the following line if you're not using hyperref
\renewcommand{\theHequation}{\arabic{\tcbcounter}\arabic{boxequation}}%
}

\begin{document}

\begin{example}{box 1}
\begin{gather}
a + b = c \\
a + b = c \\
a + b = c
\end{gather}
\end{example}
How to start the equation numbering in the new box with $1$ again?
\begin{example}{box 2}