Given a loop variable \x
, I would like to use it as (foo.\x west)
, for example, where \x
could be north
.
My attempt:
\documentclass[tikz,border=1mm]{standalone}
\begin{document}
\begin{tikzpicture}
\node[draw] (a) at (0,0) {foo};
\node[draw] (b) at (1,0) {bar};
\draw[red]
foreach \x in {north,south} {(a.\x west) -- (b.\x east)};
\end{tikzpicture}
\end{document}
This causes the following error:
! Package PGF Math Error: Unknown function `northwest' (in 'northwest').
Unfortunately, (a.\x\ west)
or (a.\x{} west)
also does not work, then I get the Missing \endcsname inserted
error.