[Tex/LaTex] How to you position a node relatively to another in TikZ

nodespositioningtikz-pgf

I would like to place a node 'B' 60 degrees of an arbitrary node 'A' between which there is a distance of 2cm. I can do this if node 'A' is at (0, 0), so 'B' would just be (60 : 2) from 'A', but what happens when 'A' is not at (0, 0)?

Best Answer

There are multiple ways to do this. Some of them need the calc or positioning TikZ libraries (\usetikzlibrary{calc,positioning}).

The simplest way would be (using calc TikZ-library):

\node (A) at (2,4) {<content>};
\node (B) at ($ (A) + (60:2) $) {<content>};

You can also use the coordinate options ([<options>]<coordinate>) to add a shift option, which doesn't require any libraries but looks a little funny.

\node (B) at ([shift={(60:2)}]A) {<content>};