based on this nice question and its answers, I have this little code:
%
% circled steps (with labels to reference them!)
%
\newcommand*\circled[2][]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=1pt,#1] (char) {#2};}}
\newcounter{cstepcnt}
\newcommand{\startcstep}{\setcounter{cstepcnt}{0}}
\newcommand{\cstep}{%
\refstepcounter{cstepcnt}%
\circled[red, font=\scriptsize]{\arabic{cstepcnt}}% this is pretty dangerous
}
This let me mark part of text, or equation, or whatever with small circled numbers that I can refer to later (with \label and \ref), like:
This in nice, and a better solution than used \textcircled{} (the numbers are badly centered, especially if they're bigger than 9, and there is no flexibility in the shape or colors), but I know this is living dangerously when I use it into a picture; sometime it works, some time it explodes (because, I know, you should never nest tikzpictures).
Is there a way to obtain the same flexibility? I mean, havinf a kind of "circled number steps" that I can use inside and outside tikzpictures?
This is a MWE, where all is working, because I was not able to find a simple example where it breaks... but it breaks sometime, giving very big or small circles.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
%
\newcommand*\circled[2][]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=1pt,#1] (char) {#2};}}
\newcounter{cstepcnt}
\newcommand{\startcstep}{\setcounter{cstepcnt}{0}}
\newcommand{\cstep}{%
\refstepcounter{cstepcnt}%
\circled[red, font=\scriptsize]{\arabic{cstepcnt}}% this is pretty dangerous
}
\renewcommand{\thecstepcnt}{\textbf{\arabic{cstepcnt}:}}
\begin{document}
one text here \cstep{} some text here \cstep\label{c:one}.
\begin{tikzpicture}
\draw (0,0) node[draw](A){text\cstep\label{c:inner}};
\end{tikzpicture}
And then ref~\ref{c:one} and \ref{c:inner}.
\end{document}




tikzpictures. Of course, you could make the above more likely to be stable by adding several keys likeminimum width=0pt,minimum height=0pt,minimum size=0ptand so on, which may prevent them from growing too large. But still you will not be safe from someevery path/.append style=..., norevery node/.append style=...unless you locally reset all those as well. – Jun 18 '19 at 19:08pictureone? Will investigate. – Rmano Jun 18 '19 at 20:05circlenode shape and make it much less susceptible to external directives. You could just look up theellipsenode shape frompgflibraryshapes.geometric.code.texand kick out all the adjustments. I do not see how then the size could be adjusted by some key, simply because you do no longer look at these keys. (This is also a conceivable way to find out what keys the shape looks at.) – Jun 18 '19 at 20:12