In the following minimal example, I am able to define a custom \if*
command based on ifcsname
, however when I use it inside \loop
construct I get Extra \fi
errors
\documentclass{article}
\makeatletter
\def\defMyCmd#1{%
\expandafter\def\csname @@included@entry@#1 \endcsname{Defined}}
\def\ifMyCmdDefined#1{%
\ifcsname @@included@entry@#1 \endcsname%
}
\makeatother
\begin{document}
\newcount\X
\X=10
\defMyCmd{temp}
% Works
\ifMyCmdDefined{temp} Hello\else Goodbye\fi{} World
\loop\unless\ifnum \X<0
\advance\X by -1
% Works
\ifcsname @@included@entry@temp \endcsname\else Goodbye\fi{} World
%
% Failes with Extra \fi.
\ifMyCmdDefined{temp} Hello\else Goodbye\fi{} World
\repeat
\end{document}
I am not sure what the reason is, or how to fix it. Any ideas?
\ifcondition
command in LuaTeX is designed for.