# TikZ Nodes not exactly centered

In my solution to draw a plot with point, it was pointed out that the nodes containing \textbullet and $\circ$ were not placed exactly centered at the specified point. I found this hard to believe but it does indeed appear to be the case.

Here is an image magnified to 2400% which shows this. The left pictures is:

\node [red] at (0,0) {\textbullet};
\draw [brown]  (0,0) circle (3pt);


and the right is:

\node [blue] at (1,0) {$\circ$};
\draw [brown]   (1,0) circle (3pt);


Clearly both are not centered at the given point.

## Questions:

1. I though that nodes were centered by default so what is different in this case?
2. How would you ensure that these are placed with their centers at the specified point?

## Code:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [very thin, gray] (-1,-1) grid (2,1);

\node [red] at (0,0) {\textbullet};
\draw [brown]  (0,0) circle (3pt);

\node [blue] at (1,0) {$\circ$};
\draw [brown]   (1,0) circle (3pt);
\end{tikzpicture}
\end{document}

-
Are you sure these symbols are, themselves, centered? I had a similar kind of problem in tex.stackexchange.com/questions/5786/depth-of-the-times-symbol for this reason. –  Ryan Reich Jun 27 '12 at 1:53
@RyanReich: Using \fbox{A \textbullet A} \fbox{A $\circ$ A} \fbox{B} \hrule does not seem to exhibit the problem illustrated by Depth of the \times symbol. Surprisingly, using {$\times$} as the node text seems to get the center crossing exactly at the node's coordinate. –  Peter Grill Jun 27 '12 at 2:39
I think your second sentence confirms that this is the same problem as the other question -- in reverse. –  Ryan Reich Jun 27 '12 at 3:19
Another question facing what I think is a similar problem: how-to-center-a-typewriter-ttfamily –  Ignasi Jun 27 '12 at 7:13

The bounding box of a character always includes the baseline point:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \txt[count=\c] in {\textbullet,$\circ$,',x}{
\node [inner sep=0pt,draw=red,line width=.1pt,text=violet](a) at (.25*\c,0) {\txt};
\draw [brown]  (.25*\c,0) circle (3pt);
}
\end{tikzpicture}
\end{document}


-

Question 1 : My last example shows that the nodes are correctly centered and in your examples, if you use the option draw, you can see that the nodes are correctly centered too. The anchor used is (center) but if you put a text inside your node, the position of the text depends on the baseline.

Question 2 : It's easy to place a drawing exactly at the center of a node but a character is not symmetric and the baseline depends on the character. Your problem here is to determine if your character is symmetric and where is the baseline.

If you look at the last circle, $\circ$ is not correctly centered. In the four try the box with p$\circ$b is correctly centered vertically but not horizontally.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [very thin, gray] (-1,-1) grid (5,1);

\node [blue,draw,circle,minimum  size=10pt,anchor=center] at (0,0) {$\circ$};
\draw [brown]  (0,0) circle (3pt);

\node [blue,draw,circle,minimum  size=10pt,anchor=center] at (1,0) {p$\circ$ };
\draw [brown]   (1,0) circle (3pt);

\node [blue,draw,circle,minimum  size=10pt,anchor=center] at (2,0) {$\circ$b };
\draw [brown]   (2,0) circle (3pt);

\node [blue,draw,circle,minimum  size=10pt,anchor=center] at (3,0) {p$\circ$b };
\draw [brown]   (3,0) circle (3pt);

\node [blue,draw,circle,minimum  size=10pt,anchor=text] at (4,0) {p$\circ$b };
\draw [brown]   (4,0) circle (3pt);
\end{tikzpicture}

\end{document}


I built a box (here a square correctly centered). It's more easy to see that the square is correctly centered. The last picture too but not $\circ$. When you used a character, this character is in a box with a baseline and the position of the character inside the node depends of the baseline.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [very thin, gray] (-1,-1) grid (5,1);
\def\tvi{\vrule height 4pt depth 4pt width 8pt}

\node [blue,draw,circle,minimum  size=10pt,anchor=center] at (0,0) {\tvi};
\draw [red]  (0,0) circle (3pt);

\def\tvi{\vrule height 4pt depth 4pt width 1pt}
\node [blue,draw,circle,minimum  size=10pt,anchor=center] at (1,0) {\tvi$\circ$\tvi};
\draw [red]  (1,0) circle (3pt);

\end{tikzpicture}

\end{document}


-

​​​​​​​​​​

-
Impressive... :-) –  Daniel Jun 27 '12 at 11:18
A picture is worth a thousand word! ;-) –  Paul Gaborit Jun 27 '12 at 12:04
Since code only answers are frowned upon, shouldn't image only ones be too? :-) Wondering if this is the first image only answer. –  Peter Grill Jul 3 '12 at 21:13