使用 xparse 定义宏时出现问题

使用 xparse 定义宏时出现问题

\def\drawcircle#1 {\node [draw] at (\getFromList{#1}{1}) [circle through={(\getFromList{#1}{2})}] {};}

我得到了我想要的,但是

\NewDocumentCommand{\drawcircle}{m} { node [draw] at (\getFromList{#1}{1}) [circle through={(\getFromList{#1}{2})}] {}; }

出事了。

\documentclass{article}
\usepackage{xparse,tikz}
\usetikzlibrary{through}

\ExplSyntaxOn
\NewDocumentCommand{\newList}{m}
 {\seq_new:c { l_am_list_#1_seq }}
\NewDocumentCommand{\addToList}{mm}
 {\seq_put_right:cn { l_am_list_#1_seq } { #2 }}
\NewDocumentCommand{\getFromList}{mm}
 {\seq_item:cn { l_am_list_#1_seq } { #2 }}
 \NewDocumentCommand{\drawcircle}{m}
 {
 node [draw] at (\getFromList{#1}{1}) [circle through={(\getFromList{#1}{2})}] {};
 }
\ExplSyntaxOff

% \def\drawcircle#1
% {\node [draw] at (\getFromList{#1}{1}) [circle through={(\getFromList{#1}{2})}] {};}

\begin{document}

\newList{C_1}
\addToList{C_1}{A}
\addToList{C_1}{B}
\newList{C_2}
\addToList{C_2}{B}
\addToList{C_2}{C}

\begin{tikzpicture}
  \coordinate (A) at (0,0);
  \coordinate (B) at (2,2);
  \coordinate (C) at (0,-3);
  \drawcircle{C_1}
  \drawcircle{C_2}
\end{tikzpicture}

\end{document}

答案1

您处于 状态\ExplSyntaxOn,因此您应该写circle~through而不是circle through

相关内容