给定一个循环变量\x
,我想将其用作(foo.\x west)
,例如,其中\x
可以是north
。我的尝试:
\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}
这会导致以下错误:
! Package PGF Math Error: Unknown function `northwest' (in 'northwest').
不幸的是,(a.\x\ west)
或者(a.\x{} west)
也不起作用,然后我收到Missing \endcsname inserted
错误。