3

How do you position a node more precisely than left of, right of?

\node[above =3 cm of node1,node distance=3.5cm] (node2){}; 

For example, how do you say that I want 3mm to the left and 4 mm above a certain node (or at a certain angle and distance alternatively)?

4

With the positioning library, you have the fairly flexible syntax demonstrated here:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
  \node (A){A};
  \node [above left = 3mm and 4mm of A] (B){B};
\end{tikzpicture}
\end{document}

For positioning nodes at an a distance and angle of another node: TikZ can handle polar coordinates, so this should be straightfoward too, but I'm having a brainfreeze on how precisely to do it in the best way...

3

How about something like this, with xshift and yshift, and also positions using relative placement with distances, placing the nodes precisely w.r.t the starting node:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
     \node[rectangle, draw=black] (node1) {N1};
     \node[rectangle, draw=black,xshift=2cm, yshift=2cm, at=(node1)] (node2) {N2};
     \node[below right=1cm and 1cm of node1, rectangle, draw=black] (node3) {N3};
\end{tikzpicture}

\end{document} 

enter image description here

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.