# Tag Info

3

Andrew has provided already a solution, I just want to show, that the \@currentlabel change does not survive outside of phantom code. The doubled \refstepcounter command for the third box is done on purpose! \documentclass{article} \usepackage[paperwidth=6cm,paperheight=6cm,margin=4mm]{geometry} \usepackage{tcolorbox} \makeatletter ...

5

I haven't dived into the internals but it looks like tcolorbox is preserving the value of \@currentlabel so that it has the same value that it had before the start of the tcolorbox. On the other hand, it is incrementing your counter and it does allow you to assign a label to it using the label argument. If instead you use: ...

4

\begin{figure} doesn't expand the optional argument; when expansion happens it's too late. \documentclass[10pt,a4paper]{article} \usepackage{keyval} \usepackage[demo]{graphicx}% draft is just for the example \makeatletter \define@key{image}{pos}{\def\i@pos{#1}} % define key-val \setkeys{image}{pos=!htbp} % set default \newcommand{\image}[2][]{% ...

3

The foreach loop introduces a group and executes the contents within that group. So the keys(which are actually macros) survive until that group ends and vanishes after that. The regular TikZ commands are executed immediately so this doesn't cause a problem. Instead of hacking this behavior you can introduce a global macro and accumulate your keys inside ...

Top 50 recent answers are included