You can achieve something like this relatively easily by defining a new style
position/.style args={#1:#2 from #3}{
at=(#3.#1), anchor=#1+180, shift=(#1:#2)
}
Then you can specify the angle and the separation between the nodes using, for example, position=-120:{\nodeDist} from n2
.
If you want to use the value set in node distance
, you can use
\makeatletter
\tikzset{
position/.style args={#1 degrees from #2}{
at=(#2.#1), anchor=#1+180, shift=(#1:\tikz@node@distance)
}
}
\makeatother
and call the style using position=120 degrees from n2
![](https://i.stack.imgur.com/AZhxK.png)
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newdimen\nodeSize
\nodeSize=4mm
\newdimen\nodeDist
\nodeDist=6mm
\tikzset{
position/.style args={#1:#2 from #3}{
at=(#3.#1), anchor=#1+180, shift=(#1:#2)
}
}
\begin{document}
\begin{tikzpicture}[
node/.style={%
draw,
circle,
inner sep=0,
outer sep=0,
minimum size=\nodeSize,
node distance=\nodeDist,
},
]
\node [node] (n1) {$n_1$};
\node [node, below=of n1] (n2) {$n_2$};
\node [node, position=-120:{\nodeDist} from n2] (n3) {$n_3$};
\node [node, position=-60:{\nodeDist} from n2] (n4) {$n_4$};
\draw (n1) -- (n2);
\draw (n2) -- (n3);
\draw (n3) -- (n4);
\draw (n4) -- (n2);
\end{tikzpicture}
\end{document}
You may use right=of 2-1 |- 1-2
(without calc
library):
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\def\len{1cm}
\begin{tikzpicture}[node distance = \len, auto]
\tikzset{
block/.style = {rectangle, draw, text centered, minimum height=2em},
}
\node [block] (1-1) {1-1};
\node [block, below = of 1-1] (1-2) {1-2};
\node [block, below right = of 1-2] (2-1) {2-1};
\node [block,right=of 2-1 |- 1-2] (3-1) {3-1};
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/gLcMx.png)
Best Answer
remark the problem is similar with
instead of
but
is valable