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.

Like the title says, is it possible to position a node a certain distance away from another node at a certain angle from that node?

share|improve this question
add comment

2 Answers 2

up vote 10 down vote accepted

Yes, TikZ can use polar coordinates. Not sure exactly what is the best way of defining the second node, here is one way.

\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \node (A) {A};
  \path (A) ++(30:2) node (B) [draw,fill=blue!20] {B};
\end{tikzpicture}
\end{document}

In (30:2) 30 is the angle, 2 the distance. 0° is to the right, positive direction is counterclockwise, so node B will be above and to the right of A.

share|improve this answer
    
Gnashing teeth - just beat me to it... –  Brent.Longborough Sep 7 '11 at 19:14
    
Is it possible to use the \node command instead of \path? Or at least include a style in \path? –  gablin Sep 7 '11 at 19:31
    
@gablin: I'm no expert, but I wasn't able to think of a way to do it with \node. But you can still do stuff like \path (A) ++(30:2) node (B) [draw,fill=blue!20] {B}; to style the node, if that was what you wanted. –  Torbjørn T. Sep 7 '11 at 19:37
    
@Torbjorn T: Yup, that's what I wanted. Thanks! =) –  gablin Sep 8 '11 at 9:37
add comment

TikZ allows you to specify positions and vectors in polar coordinates. Here's an example:

\begin{tikzpicture}
\node at (0,0) (a) {A node};
\node at (120:1cm) (b) {B node};
\path (a) ++(-45:2cm) node (c) {C node}; 
\end{tikzpicture}
share|improve this answer
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.