I often find myself writing code like this:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\node (aNodeWithALongName) at (1,1) {a};
\node (bNodeWithALongName) at (1,-1) {b};
\node (c) at (0,0) {c};
\draw[->] (aNodeWithALongName) -- (aNodeWithALongName -| c);
\draw[->] (bNodeWithALongName) -- (bNodeWithALongName -| c);
\end{tikzpicture}
\end{document}
I'm drawing a path, and need to use the first point's position to compute the second point, and I would like to avoid repeating the aNodeWithALongName
, like this for example:
\draw[->] (aNodeWithALongName) -- (current -| c);
\draw[->] (bNodeWithALongName) -- (current -| c);
And more complex stuff:
\draw[->] ($(aNodeWithALongName)!.5!(bNodeWithALongName)$) -- (current -| c);
\draw[->] (bNodeWithALongName) -- ++(0, 1cm) -- (current -| c);
Is there a syntax similar to that which I could use?
Best Answer
I found a solution in this TeX-SX answer: