The following works as expected:
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\makeatletter
\node (01) at (0, 0) {};
\draw (0, 0) -- (0, 01);
\makeatother
\end{tikzpicture}
\end{document}
But when I replace one of the 01
s with \@ifnextchar1001
, which should be equivalent according to my understanding, it breaks:
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\makeatletter
\node (\@ifnextchar1001) at (0, 0) {};
\makeatother
\end{tikzpicture}
\end{document}
gives
! Argument of \XC@definec@lor has an extra }. <inserted text> \par l.6 \node (\@ifnextchar1001) at (0, 0) {};
and
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\makeatletter
\draw (0, 0) -- (0, \@ifnextchar1001);
\makeatother
\end{tikzpicture}
\end{document}
yields
! Argument of \XC@definec@lor has an extra }. <inserted text> \par l.6 \draw (0, 0) -- (0, \@ifnextchar1001) ;
What is the relevant difference between 01
and \@ifnextchar1001
in this case?
How can I make this – or a similar construct – work as intended?
XC@
prefix suggests that the problem might stem from withinxcolor
. Hence the color tag.\begin{document}
. It is good practice to make sure the cat codes are what LaTeX expects when that stuff gets executed. Hence, if you change them in the preamble, you change them back. If you change them in the document, you change them back before\end{document}
. But you shouldn't usually change them in the document directly, of course.\@ifnextchar1001
is not the best way to explain the problem you have. Yes, the ultimate reason is that\futurelet
is involved, but that's all.