# tikz align nodes

is it possible with TikZ to align a new node with respect to existing ones? I know the answer is affirmative in the case of one node using e.g. the node coordinate system, but what about align with respect to two nodes?

Example: suppose there are two nodes defined (A) and (B) and I want to create a third node (C) such that xy-coordinates satisfy C.x = A.x and C.y = B.y i.e. node (C) is vertically aligned with (B) and horizontally aligned with (A).

• Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code (with both cases mentioned), starting with \documentclass{...} and ending with \end{document}. – albert Aug 13 '18 at 10:22

You can achieve this using |- and -| along with node[midway]

\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}
\node (A) at (0,0) {A};
\node (B) at (8,3) {B};
\path (A) |- (B) node[midway] (C) {C};
\path (A) -| (B) node[midway] (D) {D};
\end{tikzpicture}
\end{document}

• Thank you! However looking at the -| and |- operators I found a shortcut in the manual which is the perpendicular coordinate system. One only needs to define \node (C) at (A -| B) {C};. – nicmus Aug 13 '18 at 10:43