I'm trying to set a conditional \if...
to true or false based on another condition. Something similar to this:
\documentclass{article}
\newif\iffirst
\iftrue
\let\iffirst\iftrue% ... similar to \firsttrue
\else
\let\iffirst\iffalse% ... similar to \firstfalse
\fi
\begin{document}
\iffirst
First
\else
Not first
\fi
\end{document}
The output logically should be First
, since \iffirst
is set to \iftrue
. However, it doesn't work. Why not? I thought once the condition is evaluated (\iftrue
or \iffalse
), it executes the true/false clause, with \let<cmdA><cmdB>
being valid.
Instead of \let\iffirst\iftrue
/\let\iffirst\iffalse
, one can use \firsttrue
/\firstfalse
. However, these both have the same meaning (that is, \show\firsttrue
reveals \let\iffirst\iftrue
and similarly \show\firstfalse
reveals \let\iffirst\iffalse
). So, why does \firsttrue
/\firstfalse
work, but specifying \let\iffirst\iftrue
/\let\iffirst\iffalse
explicitly doesn't?
The following workaround also helps but doesn't answer the question:
\documentclass{article}
\newcommand{\firstoftwo}[2]{#1}% Similar to \@firstoftwo
\newcommand{\secondoftwo}[2]{#2}% Similar to \@secondoftwo
\iftrue
\let\firstsecond\firstoftwo
\else
\let\firstsecond\secondoftwo
\fi
\begin{document}
\firstsecond{%
First
}{%
Not first
}
\end{document}