I am using the following tikz-based command to create a circle around a letter.
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,minimum size=4mm, inner sep=0pt] (char)
{#1};}}
It works fine, but whenever I use multiple letters in the same line, they are not aligned.
I guess it has something to do with the baseline, like the circle is created in reference to the center of mass. Notice that b and d are a bit higher than a and c. How could I fix that?
UPDATE
Following the advice I got from the comments (thank you all), I got the circles aligned to each other (which is what I wanted), but unfortunately not to the text:
I saw the other post proposing this propnode
(the pink a), and I tried to shift it all over the place using the first argument, but it had no effect.
\pgfmathsetmacro{\nodebasesize}{1} % A node with a value of one will have this diameter
\pgfmathsetmacro{\nodeinnersep}{0.05}
\newcommand{\propnode}[5]{% position, name, options, value, label
\begin{tikzpicture}
\pgfmathsetmacro{\minimalwidth}{sqrt(#4*\nodebasesize)}
\node[#3,minimum width=\minimalwidth*1cm,inner sep=\nodeinnersep*1cm,circle,draw] (#2) at (#1) {#5};
\end{tikzpicture}
}
In fact, propnode
is a bit too high and circled is a bit too low. This is the code which calls everything:
(\circled{b},\circled{a},\circled{c},\circled{d},\propnode{0,4}{n05}{fill=pink,text=black}{0.15}{a}).
Best Answer
Here's an example using a strut: