如何使用 let 操作在 tikzset 中定义超过 9 个点?

如何使用 let 操作在 tikzset 中定义超过 9 个点?

如下面代码所示\p10会出现错误,从而阻止长绘制。

如何克服这个问题?

我认为这被问这里但对于这个应用程序来说,答案尚不明确。

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzset{my doodle/.pic=%
{%
    \coordinate (-A) at (0,0);
    \coordinate (-B) at (1cm, 0);
    \coordinate (-C) at (1cm, -1cm);
    \coordinate (-D) at (0, -1cm);
    \draw[line width=1.5mm,red!40!orange!30!yellow] (-A) -- (-B) -- (-C) -- (-D) -- cycle; % gold rectangle
    % blue line
    \coordinate (-D1) at (-0.055cm,-1.07cm);                                % starting point of blue line
    \path let \p1=(-D1) in coordinate (-D2) at (-0.25cm,\y1+0.1cm);         % go to starting position of pattern
    \path let \p2=(-D2) in coordinate (-D3) at (-0.1cm,\y2-0.05cm);         % step 1
    \path let \p3=(-D3) in coordinate (-D4) at (-0.25cm,\y3+0.25cm);        % step 2
    \path let \p4=(-D4) in coordinate (-D5) at (-0.1cm,\y4-0.05cm);         % step 3
    \path let \p5=(-D5) in coordinate (-D6) at (-0.25cm,\y5-0.05cm);        % step 1
    \path let \p6=(-D6) in coordinate (-D7) at (-0.1cm,\y6+0.25cm);         % step 2
    \path let \p7=(-D7) in coordinate (-D8) at (-0.25cm,\y7-0.05cm);        % step 3
    \path let \p8=(-D8) in coordinate (-D9) at (-0.1cm,\y8-0.05cm);         % step 1
    \path let \p9=(-D9) in coordinate (-D10) at (-0.25cm,\y9+0.25cm);   % step 2
    \path let \p10=(-D10) in coordinate (-D11) at (-0.1cm,\y10-0.05cm);     
    \draw[thick, blue] (-D1) -- (-D2) -- (-D3) -- (-D4) -- (-D5) -- (-D6) -- (-D7) -- (-D8) -- (-D9) -- (-D10) -- (-D11);%
    }%
}

\NewDocumentCommand{\doodle}{ O{black} O{0.18pt} r() }{
     \begin{tikzpicture}[overlay,remember picture]
     \pic[draw=#1, line width=#2] 
        at (#3) {my doodle};
    \end{tikzpicture}    
}

\doodle(0,-2)
\end{document}

答案1

我偶然发现了解决方案 - 将和都\p10更改\y10\p{10} \y{10}

问题在于 0,或者任何第二个数字。

相关内容