我想画一个五边形。这个可以
\draw \foreach \alpha in {0,72,...,359} {
\ifdim\alpha pt=0pt \else--\fi
(270+\alpha:1)
} -- cycle;
虽然这
\draw \foreach \alpha in {0,72,...,359} {
(270+\alpha:1) --
} cycle;
给出错误Cannot parse this coordinate.
有人能解释一下为什么吗?
答案1
您可以在使用它之前定义路径:
\documentclass[varwidth,border=7mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\xdef\p{}
\foreach \alpha in {0,72,...,359}{
\xdef\p{\p (270+\alpha:1) --}
}
\begin{tikzpicture}
\draw \p cycle;
\end{tikzpicture}
\end{document}