The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

\documentclass{article}
\usepackage{ifthen}
\begin{document}
\def\foo{23}
23 \ifthenelse{\isodd{\foo}}{is odd}{is even} \\
42 \ifthenelse{\isodd{42}}{is odd}{is even} \\
!42 \ifthenelse{\not \isodd{42}}{is odd}{is even} \\
23 \&\& !42 \ifthenelse{\isodd{23} \and \not \isodd{42}}{true}{false} \\
23 \&\& 33 \ifthenelse{\isodd{23} \AND \isodd{33}}{true}{false} \\
23 $|$$|$ 42 \ifthenelse{\isodd{23} \or \isodd{42}}{true}{false} \\
23 \&\& !42 \&\& 13 \ifthenelse{\isodd{23} \and \not \isodd{42} \and \isodd{13}}{true}{false} \\
\textbackslash foobar \ifthenelse{\isundefined{\foobar}}{is undefined}{is defined} \\
! \textbackslash string \ifthenelse{\not \isundefined{\string}}{is undefined}{is defined} \\
%
21 = 21 : \ifthenelse{21 = 21}{true}{false} \\
42 $>$ 21 : \ifthenelse{42 > 21}{true}{false} \\
-3 $<$ 21 : \ifthenelse{-3 < 21}{true}{false} \\
1 = 1 \&\& 2 = 2 : \ifthenelse{1 = 1 \and 2 = 2}{true}{false} \\
1 = 2 \&\& 2 = 2 : \ifthenelse{1 = 2 \and 2 = 2}{true}{false} \\
1 = 2 $|$$|$ ! 2 = 2 : \ifthenelse{1 = 2 \or \not 2 = 2}{true}{false} \\
%
\newboolean{myBool}
\setboolean{myBool}{true}
myBool is \ifthenelse{\boolean{myBool}}{true}{false} \\
\setboolean{myBool}{false}
myBool is \ifthenelse{\boolean{myBool}}{true}{false} \\
\newboolean{myOtherBool}
\setboolean{myOtherBool}{true}
myOtherBool is \ifthenelse{\boolean{myOtherBool}}{true}{false} \\
myBool $\&\&$ myOtherBool is \ifthenelse{\boolean{myBool} \and \boolean{myOtherBool}}{true}{false} \\
myBool $|$$|$ myOtherBool is \ifthenelse{\boolean{myBool} \or \boolean{myOtherBool}}{true}{false} \\
%
\ifthenelse{\equal{hello}{you}}{yay}{nay}
\ifthenelse{\equal{hello}{hello}}{yay}{nay}
\ifthenelse{\not \equal{hello}{you}}{yay}{nay}
\ifthenelse{\NOT \equal{hello}{hello}}{yay}{nay}
\def\tok1{horray} \ifthenelse{\equal{\tok1}{horray}}{YAY}{NAY}
\ifthenelse{\equal{\tok1}{\LaTeX}}{YAY}{NAY} \\
1 = 1 \&\& hello = hello \ifthenelse{1 = 1 \and \equal{hello}{hello}}{yay}{nay} \\
1 = 1 \&\& hello = hello $|$$|$ 2 $<$ -1 \ifthenelse{1 = 1 \and \equal{hello}{hello} \or 2 < -1}{yay}{nay} \\
1 = 1 \&\& hello = hello \&\& 2 $<$ -1 \ifthenelse{1 = 1 \and \equal{hello}{hello} \and 2 < -1}{yay}{nay} \\
%
\def\counter{c}
\whiledo{\not \equal{\counter}{ccccccc}}{\counter - \let\tmp\counter\edef\counter{c\tmp}} \\
%
( 23 ) \ifthenelse{\( \isodd{23} \)}{is odd}{is even} \\
( 1 = 1 ) : \ifthenelse{\( 1 = 1 \)}{true}{false} \\
!( 1 $>$ 2 ) : \ifthenelse{\not \( 1 > 2 \)}{true}{false} \\
23 \&\& ( 1 = 2 ) : \ifthenelse{\isodd{23} \and \( 1 = 2 \)}{true}{false} \\
23 \&\& ! ( 1 = 2 ) \&\& ( 3 $>$ 2 $|$$|$ 4 = 2 ) \ifthenelse{\isodd{23} \and \not \( 1 = 2 \) \and \( 3 > 2 \or 4 = 2 \) }{true}{false} \\
! ( ( 42 ) ) : \ifthenelse{\not \( \( \isodd{42} \) \)}{true}{false} \\
( !42 ) : \ifthenelse{\( \not \isodd{42} \)}{true}{false} \\
( ! ( 42 ) ) : \ifthenelse{\( \not \( \isodd{42} \) \)}{true}{false} \\
( ! ( ! ( !42 ) ) ) : \ifthenelse{\( \not \( \not \( \not \isodd{42} \) \) \) }{true}{false} \\
%
\ifthenelse{\( 1 = 1 \and 3 < 4 \) \or \( 5 = 5 \and 3 > 23 \)}{T}{F}
\ifthenelse{\not \( 1 = 1 \and \( \not 1 < -1 \and 24 = 24 \) \)}{T}{F}
\ifthenelse{\not \( \not \( 1 = 1 \and \not \( 1 > 3 \) \) \)}{T}{F}
\ifthenelse{\not \isodd{72} \or \( \not 1 = 5 \and \( 1 = 2 \or 2 = 1 \) \)}{T}{F}
\end{document}