2

With

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

I get what I want but with

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

Something's wrong.

\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}
0

1 Answer 1

3

You are in \ExplSyntaxOn and that's why you should write circle~through instead of circle through.

5
  • Sorry just fine ! May 15, 2020 at 11:34
  • Where is in the documentation ? May 15, 2020 at 11:52
  • 1
    In ExplSyntax, the spaces are not significant. However, the space in the Tikz option circle through must be a real space (otherwise, it will become the option circlethrough which does not exist). That's why we have to put a significant space (~ in ExplSyntax). There are often such ~ to put in Tikz instructions in ExplSyntax. May 15, 2020 at 12:18
  • 1
    In fact, if your definition by \def was in ExplSyntax, we would have to put the ~ and if you have used your \NewDocumentCommand outside ExplSyntax, it would have worked without the ~. In fact, the problem has nothing to oo with \NewDocumentCommand and \def. It's only a problem at the intersection of Tikz and ExplSyntax. May 15, 2020 at 12:23
  • Thanks for all your comments ! very useful !! I start with l3 May 15, 2020 at 12:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .