[texhax] \newif, \csname and \endcsname

jfbu jfbu at free.fr
Mon Jan 31 08:39:06 CET 2011


> \documentclass{article}
> \newif\ifok
> \newif\ifnotok
> \newcommand{\printtest}{%
> \csname ifok\endcsname\csname ifnotok\endcsname print test\fi\fi}
> \begin{document}
> This is a test
> \printtest
> \end{document}
>
> Tex complains that there is an "Extra \fi", why?

I can not say why, but

1. the problem does not arise if the first line is \newif\ifok\oktrue

2. the problem seems to be fixed by that version:

\newcommand{\printtest}{%
\expandafter\expandafter\csname ifok\endcsname\csname ifnotok\endcsname 
print test\fi\fi}

regards
Jean-Francois



More information about the texhax mailing list