T-F-S / tcolorbox

A LaTeX package to create highly customizable colored boxes.
http://www.ctan.org/pkg/tcolorbox
LaTeX Project Public License v1.3c
213 stars 15 forks source link

Does `\tcbcounter` not exist anymore? #278

Open CarLaTeX opened 2 months ago

CarLaTeX commented 2 months ago

I had this instruction

\newcounter{boxsubsectcnt}[\tcbcounter]

in an old project (see the attached MWE, the zip file). Till TeX Live 2021 it worked, now it gives the error (see attached log):

! Undefined control sequence.
<argument> c@\tcbcounter 

I changed it into:

\makeatletter
\newcounter{boxsubsectcnt}[\tcb@cnt@triplebox]
\makeatother

and it works, but in the tcolorbox documentation \tcbcounter is still mentioned.

Isn't the documentation up-to-date or I'm doing something wrong? Thank you! Ciao! Carla tcolobox_counters.zip tcolobox_counters.log

muzimuzhi commented 2 months ago

Before v6.0.0 (2023-02-10), after a box declaration using auto counter or use counter=<counter>, \tcbcounter was globally defined and held the counter name just created or to be used, but \thetcbcounter was undefined. This inconsistency was resolved in v6.0.0 by making both \tcbcounter and \thetcbcounter undefined after box declarations.

Now both \tcbcounter and \thetcbcounter are only defined inside "numbered" boxes.

See #203 and the corresponding Changelog entry for more info.

CarLaTeX commented 2 months ago

Thank you.

I would suggest explaining this more explicitly in the documentation. Something like: "Outside the box, you have to use the real counter name, not \tcbcounter. The real counter name is @.***@, where is the name of the current box, or the name box from which the counter is inherited, or the name of any other counter used. It can be found printing \texttt{\tcbcounter} inside the box."

Thank you, ciao! Carla

Il giorno dom 28 apr 2024 alle ore 06:38 Yukai Chou < @.***> ha scritto:

Before v6.0.0 (2023-02-10), after a box declaration using auto counter or use counter=, \tcbcounter was globally defined and held the counter just created or to be used, but \thetcbcounter was undefined. This inconsistency was resolved in v6.0.0 by making both \tcbcounter and \thetcbcounter undefined after box declarations.

See #203 https://github.com/T-F-S/tcolorbox/issues/203 and the corresponding Changelog entry https://github.com/T-F-S/tcolorbox/blob/067f384e2ba85ba3fd91958eb6adb8a1bcea6c29/doc/latex/tcolorbox/CHANGES.md?plain=1#L203 for more info.

— Reply to this email directly, view it on GitHub https://github.com/T-F-S/tcolorbox/issues/278#issuecomment-2081325376, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDP6GM7RBXQWRGBUEALJVLY7R4N7AVCNFSM6AAAAABG4FOC5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBRGMZDKMZXGY . You are receiving this because you authored the thread.Message ID: @.***>

T-F-S commented 2 months ago

As @muzimuzhi already explained, the new version fixed some kind of leakage, i.e. using the \tcbcounter outside the box.

I would not recommend to use the internal counter name \tcb@cnt@triplebox, because this name may change in future. My recommendation for your code is to replace auto counter by use counter where you can use any counter you want, e.g. use counter=boxsectcnt with a new counter boxsectcnt.

The full example for your code is:

% arara: pdflatex
% arara: pdflatex
% arara: showfile
\documentclass{book}

\usepackage[most]{tcolorbox}

% Use a counter 'boxsectcnt' for numbering the box
\newcounter{boxsectcnt}
\newcounter{boxsubsectcnt}[boxsectcnt]

\newtcolorbox[use counter=boxsectcnt]{triplebox}[2][]{%
    title={\tikz{\node(n){\thetcbcounter};\node[anchor=west, xshift=1.5pt] at (n.east){#2};}},
    #1
    }

% Till TeX Live 2021, the following worked
% \newcounter{boxsubsectcnt}[\tcbcounter]

% Now I have to use this:
%\makeatletter
%\newcounter{boxsubsectcnt}[\tcb@cnt@triplebox]
%\makeatother

\newcommand{\boxsubsection}[1]{%
    \vspace{2ex plus 1ex minus .2ex}
    \tikz{\node(n){\thetcbcounter.\stepcounter{boxsubsectcnt}\arabic{boxsubsectcnt}};\node[anchor=west, xshift=1.5pt] at (n.east){#1};}\par}

\begin{document}
\begin{triplebox}{Task with subsection}{}{}
Something

\boxsubsection{Subsection title}
Something after the first subsection

\boxsubsection{Another subsection title}
Something after the other subsection
\end{triplebox}

\end{document}
CarLaTeX commented 2 months ago

Thank you, Thomas, this is a simple and efficient solution, I wasn't thinking. Ciao! Carla

Il giorno lun 29 apr 2024 alle ore 10:28 Thomas F. Sturm < @.***> ha scritto:

As @muzimuzhi https://github.com/muzimuzhi already explained, the new version fixed some kind of leakage, i.e. using the \tcbcounter outside the box.

I would not recommend to use the internal counter name @.***@triplebox, because this name may change in future. My recommendation for your code is to replace auto counter by use counter where you can use any counter you want, e.g. use counter=boxsectcnt with a new counter boxsectcnt.

The full example for your code is:

% arara: pdflatex% arara: pdflatex% arara: showfile\documentclass{book} \usepackage[most]{tcolorbox} % Use a counter 'boxsectcnt' for numbering the box\newcounter{boxsectcnt}\newcounter{boxsubsectcnt}[boxsectcnt] \newtcolorbox[use counter=boxsectcnt]{triplebox}[2][]{% title={\tikz{\node(n){\thetcbcounter};\node[anchor=west, xshift=1.5pt] at (n.east){#2};}},

1

}

% Till TeX Live 2021, the following worked% \newcounter{boxsubsectcnt}[\tcbcounter] % Now I have to use @.***@triplebox]%\makeatother \newcommand{\boxsubsection}[1]{% \vspace{2ex plus 1ex minus .2ex} \tikz{\node(n){\thetcbcounter.\stepcounter{boxsubsectcnt}\arabic{boxsubsectcnt}};\node[anchor=west, xshift=1.5pt] at (n.east){#1};}\par} \begin{document}\begin{triplebox}{Task with subsection}{}{} Something \boxsubsection{Subsection title} Something after the first subsection \boxsubsection{Another subsection title} Something after the other subsection\end{triplebox} \end{document}

— Reply to this email directly, view it on GitHub https://github.com/T-F-S/tcolorbox/issues/278#issuecomment-2082147048, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDP6GPHITOCXZ6ME5RLL43Y7YABLAVCNFSM6AAAAABG4FOC5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBSGE2DOMBUHA . You are receiving this because you authored the thread.Message ID: @.***>