After poring over this site and the tcolorbox documentation for over an hour, I can't figure out how to reset the equation counter inside my derivation environment. I wrote the old version with mdframed and there it was as simple as \setcounter{equation}{0} at the beginning of the environment, but that obviously doesn't work here. I need the numbering to start over with each instance of derivation. I have a feeling it's trivial and I'm just not seeing it.
My MWE:
% !TEX TS-program = lualatexmk
% !TEX encoding = UTF-8 Unicode
\documentclass{article}
\usepackage{amsmath}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\newtcolorbox[auto counter]{derivation}{%
ams align,%
title={DERIVATION \thetcbcounter},%
fonttitle=\bfseries,%
label={derivation@\thetcbcounter},
coltitle=black,%
colback=orange!25,%
colframe=orange!60%
%colback=orange!5!white,%
%colframe=orange!75!black%
}%
\begin{document}
\begin{derivation}
x + y &= z && \text{given} \
y &= z - x && \text{solve for (y)}
\end{derivation}
\begin{derivation}
\gamma &= \frac{1}{\sqrt{1-v^2}} && \text{definition} \
v &= \sqrt{1-\frac{1}{\gamma^2}} && \text{solve for (v)}
\end{derivation}
\end{document}


mdframedmethod here, just addcode=\setcounter{equation}{0}to the options of thederivationbox. The question is whether this makes sense because then different equations carry the same number. – Nov 02 '20 at 01:25tcolorboxdocs. I can't imagine seeing derivations in a math or physics textbook with consecutively numbered steps through the book. The individual steps won't be referenced, only the boxes themselves. Am I missing something? – LaTeXereXeTaL Nov 02 '20 at 01:41(<number of derivation>-<number of equation in>)derivation, which can be achieved withcode=\setcounter{equation}{0}\renewcommand{\theequation}{\thetcbcounter-\arabic{equation}}. This is still not too good if you have ordinary equations in the document, but you could memorize the orginal equation number and restore it after the box in that case. BTW, thecodekey can be found in section 4.24 Miscellaneous of the tcolorbox manual v4.42. – Nov 02 '20 at 01:45codein the docs. Well hidden! Many thanks! – LaTeXereXeTaL Nov 02 '20 at 01:58