I'm recently using a lot of macros that have to check if an argument is supplied empty (usually an optional argument, but I don't suppose that matters). In other people's code I noticed two typical ways of doing it in plain LaTeX.
Code: Select all
\documentclass{minimal}
\newcommand*{\detokenizetest}[1][]{\if\relax\detokenize{#1}\relax Empty.\else Not empty.\fi}
\newcommand*{\emptytest}[1][]{\def\optional{#1}\ifx\optional\empty Empty.\else Not empty.\fi}
\begin{document}
\detokenizetest[]
\emptytest[]
\detokenizetest[foo]
\emptytest[foo]
\end{document}
Many thanks for any advice! (and happy holidays)