Expand `ifthenelse` immediately
you can't use \ifthenelse
inside \setcounter
. Change the order:
\documentclass{report}
\usepackage{ifthen}
\newcommand{\thesissize}{SHORT}
\begin{document}
\ifthenelse{\equal{\thesissize}{SHORT}}
{\setcounter{page}{3}}{\setcounter{page}{2}}
hey
\end{document}
Expandable tests are possible with expl3
and etoolbox
. For both you should store the reference text in a command:
\documentclass{report}
\usepackage{expl3,etoolbox}
\newcommand{\thesissize}{SHORT}
\newcommand{\shortsize}{SHORT}
\begin{document}
\ExplSyntaxOn
\setcounter{page}{\tl_if_eq:NNTF\thesissize\shortsize{3}{2}}
\ExplSyntaxOff
\setcounter{page}{\ifdefequal{\thesissize}{\shortsize}{3}{2}}
hey
\end{document}
Another version of a string comparison using the pdfTeX macro \pdfstrcmp
. The following uses the pdftexcmds
package to make it available to all engines under the same name:
\documentclass[]{article}
\usepackage{pdftexcmds}
\makeatletter
\newcommand\ifstreq[2]
{%
\ifnum\pdf@strcmp{#1}{#2}=0
}
\makeatother
\newcommand\thesissize{SHORT}
\begin{document}
\setcounter{page}{\ifstreq{\thesissize}{SHORT}3\else2\fi}
hey
\end{document}
If a LaTeX syntax is preferred one can use
\documentclass[]{article}
\usepackage{pdftexcmds}
\makeatletter
\newcommand\ifstreq[2]
{%
\ifnum\pdf@strcmp{#1}{#2}=0
\expandafter\@secondofthree
\fi
\@secondoftwo
}
\providecommand\@secondofthree[3]{#2}
\makeatother
\newcommand\thesissize{SHORT}
\begin{document}
\setcounter{page}{\ifstreq{\thesissize}{SHORT}{3}{2}}
hey
\end{document}