# "tight fitting" circle node with tikz

Here's a minimal tikz figure:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [circle,draw] {A};
\end{tikzpicture}
\end{document}


That circle around the 'A' is bigger than I'd like. I want it to look more like this. (The 'A' is meant to be the same size as in the previous image, and the circle smaller.)

How can I achieve that? There are several previous questions about changing the size of a node, but they seem to be either about the size of an empty node, or making it bigger, which can be achieved with minimum size or inner sep. (I'm unsure about what these commands do or what the difference is, but they don't seem to be what I want.) My goal is just to specify the radius of the node exactly, regardless of the size of its label.

The circle is a node in a graph, and should behave as a node of the correct size when connecting arrows to it and so on.

I guess I could just write a \newcommand to draw an empty node of the correct size and then write the label on top of it, but it feels like that's not the intended way to use tikz, so I'm wondering what the proper way is.

• I don't understand what your problem is here. Do you not understand inner sep or do you want an alignment? Aug 10 '20 at 9:41
• @AndréC as a matter of fact, when I posted this I didn't understand inner sep. (I said so in the question.) But that isn't the point, necessarily. I want the node to have a specified radius, independently of the label's bounding box, that's all. Aug 10 '20 at 11:27
• With TikZ, a node is a box that contains text. This default box is rectangular. If it perfectly frames the text, the edges of the box touch the text, which is unattractive. By default TikZ leaves a space between the text and the edges of the box which is defined by the length ìnner sep (initially is 0.3333em). When the node is a circle, this circle is circumscribed to the rectangular node which is drawn by default. Translated with www.DeepL.com/Translator (free version) Aug 10 '20 at 11:48

To obtain a perfect alignment whatever the letter used, you must set the height and depth of the text:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzset{
circled node/.style={circle,draw, inner sep=0, minimum size=1.5em},
better circled node/.style={circled node,text height=.8em,text depth=.25em},
}
\foreach \letter[count=\c] in {A,B,H,Q,Z,a,f,g,É}{
\path (\c*6mm, 0) node [circled node] (N-\c) {\letter};
\path (\c*6mm, -1) node [better circled node] (M-\c) {\letter};
}
\draw[red,very thin,dashed] (N-1.base) -- ++(5cm,0);
\draw[red,very thin,dashed] (M-1.base) -- ++(5cm,0);
\end{tikzpicture}
\end{document}


Oh, well this was easier than I thought. One must combine the mysterious invocations inner sep and minimum size in the following manner:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [circle,draw, inner sep=0, minimum size=1.5em] {A};
\end{tikzpicture}
\end{document}


It looks weirdly off centre, but I'll live with that.

I imagine there's a reason why this works, and that it's written somewhere in the 1000 page manual. I wish I lived in a world in which I had time to read it.

• Circle has also a parameter radius, witch should make it even easier
– Cube
Aug 10 '20 at 7:02
• @Cube I forgot to mention that in the question: radius seems only able to make the circle bigger than the default, not smaller. It probably works as expected with some combination of inner sep and minimum size, I'd imagine. Aug 10 '20 at 7:04
• interesting, i didnt know that. \draw circle[radius=5pt] node{A}; would be how i do it and there it works no problem
– Cube
Aug 10 '20 at 7:13
• @Nathaniel -- invocation thats hilarious like black magic haha Aug 10 '20 at 7:27
• @Cube The circle node shape does not have a radius parameter, what you're using there is the circle path constructor, they are not the same. The way you do it there is no connection between the size of the circle and the size of the node, but with \node [circle,draw] {foo} the circle will always be bigger than foo. Aug 10 '20 at 7:36