I want to use circled numbers in a figure caption. I found a nice and short implementation using tikz here. The command itself is working (after using \DeclareRobustCommand instead), and the resulting symbols are correctly displayed.
However, the spacing around them is way too large for my liking (see the example below). I checked with \fbox that the actual tikz picture does not have any surrounding whitespace, so I assume it must be a kerning or skip issue. It sometimes seemed to me like the space around the numbers was inconsistent, indicating it isn't a kern, but I'm not sure how to test that more comprehensively.
Here's a minimal example (inside a figure caption because that's the only place I need it to work):
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\DeclareRobustCommand\circled[1]{
\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=1pt] (char) {\scriptsize \textbf{#1}};
}
}
\begin{document}
\begin{figure}[t]
\centering
\caption{
This is a figure caption.
\circled{1} I want to refer to parts of the figure using circled numbers.
\circled{2} But the spacing around the numbers is completely off.
\circled{3} I would've expected the numbers to behave like single letters, maybe like just writing (4) or something similar.
}
\end{figure}
\end{document}
Any advice how to control this spacing (and ideally make at least the space after the number fixed and non-breaking) is greatly appreciated!





%at the end of those lines (immediately after{or}), and at least that cause will be removed. – barbara beeton Aug 18 '23 at 19:49