Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Normally a edge drawn between two nodes starts and stops and the boundary of the nodes. How can one draw an edge to the center of a node?

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
Current result:

 \begin{tikzpicture}
  \node (0)              {};
  \node (1) [right of=0] {};
  \node (2) [above right of=1] {};
  \draw (0) -- (1);
  \draw (1) -- (2);
 \end{tikzpicture}

Desired result (looks like):

 \begin{tikzpicture}
  \draw (0,0) -- (1,0);
  \draw (1,0) -- (1.5,.5);
 \end{tikzpicture}
\end{document}

enter image description here

I want my TikZ code to be readable, so want I first place the nodes with relative positions and then draw the edges. I created the desired result without using the relative placement of nodes. This is not an acceptable solution.

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

You can suffix an anchor to any node:

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
Current result:

 \begin{tikzpicture}
  \node (0)              {};
  \node (1) [right of=0] {};
  \node (2) [above right of=1] {};
  \draw (0.center) -- (1.center);
  \draw (1.center) -- (2.center);
 \end{tikzpicture}

\end{document}
share|improve this answer
    
Beautiful. I knew the answer should be simple. Thanks! –  Tyson Williams Jul 30 '11 at 19:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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