6

When I include circle in the every node style, the distance from the label to the node depends on the length of the label:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\tikzstyle{every node}=[circle]
\node at (0,0) [label={A},draw,fill] {};
\node at (2,2) [label={BBBBB},draw,fill] {};
\node at (5,5) [label={CCCCCCCCCC},draw,fill] {};
\end{tikzpicture}

\end{document}

enter image description here

When I delete the tikzstyle and add circle to the options for the individual nodes, this goes away:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node at (0,0) [circle,label={A},draw,fill] {};
\node at (2,2) [circle,label={BBBBB},draw,fill] {};
\node at (4,4) [circle,label={CCCCCCCCCC},draw,fill] {};
\end{tikzpicture}

\end{document}

enter image description here

What's going on here and how can I avoid it, so I can keep circle in the node style?

6

Labels are also nodes. So TiKZ is setting each label in a circle. Since larger labels need larger circles, those labels are set further away from the labelled node. You can avoid this by explicitly specifying the usual rectangular shape for labels:

\documentclass[tikz]{standalone}
\begin{document}
  \begin{tikzpicture}
    [
      every node/.append style={circle},
      every label/.append style={rectangle},
    ]
    \node at (0,0) [label={A},draw,fill] {};
    \node at (2,2) [label={BBBBB},draw,fill] {};
    \node at (5,5) [label={CCCCCCCCCC},draw,fill] {};
  \end{tikzpicture}
\end{document}

non-circular labels

  • Perfect -- thanks for the fix, and the explanation. – LarrySnyder610 Oct 20 '14 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.