12

I'm trying to label a circled node in Tikz with some text to the left. The problem is it is colliding with the circle.

For example I have something like:

\begin{tikzpicture}
\node[draw,circle] at (0,0) {A};
\node[left] at (0,0) {010101};
\end{tikzpicture}

This causes the binary to overlap the node A. What is the best way to fix this?

3 Answers 3

7

One way to fix this is to load the positioning library

enter image description here

Note that in the code below I have named your first node as nameofnode and then positioned the text in relation to it by using left=of nameofnode.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
\node[draw,circle](nameofnode) at (0,0) {A};
\node[left=of nameofnode] {010101};
\end{tikzpicture}

\end{document}
2
  • Thanks! I'm trying to work out how to get the binary label a bit closer now.
    – Andrew
    Oct 31, 2012 at 16:24
  • 3
    @Andrew Try left=<distance> of nameofnode and vary <distance>. Oct 31, 2012 at 16:26
14

An even easier version is using the label option for nodes:

\documentclass{article}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}
        \node[draw,circle,label=left:010101] (CircleNode) at (0,0)  {A};
    \end{tikzpicture}
\end{document}

It looks just like Peter Grill's solution.

8

Instead of placing the text node at via coordinates, you could name the circle node and place it to the left of the named circled node:

enter image description here

Code:

\documentclass[border=2pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \node[draw,circle] (CircleNode) at (0,0)  {A};
  \node[left] at (CircleNode.west) {010101};
\end{tikzpicture}

\end{document}

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.