DormanResearch : LaTeXIfThenElse?

Referers: 20080610KSD :: LatexHints :: (Remote :: Orphans :: Tree )

Dorman Wiki
Dorman Lab Wiki
# For numeric comparisons
\ifnum#1=0
\dosomething
\else
\ifnum#1>1
\dosomethingelse
\else
\doyetsomethingelse
\fi
\fi

# For string comparisons
\newif\ifstringeq # define a new boolean variable
\def\teststringeq#1#2{%
\edef\tempa{#1} # expand macros in argument 1 and define \tempa to the result
\edef\tempb{#2}
\ifx\tempa\tempb # \ifx compares two macros, without expansion
\stringeqtrue # set boolean variable defined above to true
\else
\stringeqfalse
\fi
}

\teststringeq{hello}{hello}
\ifstringeq
\dosomething
\else
\dosomethingelse
\fi
There is no comment on this page. [Display comments/form]