This question is an extension of conditionals inside newcommand with empty argument
I have a macro that looks like
\newcommand{\pcs}[3]{{#1}_{#2}^{(#3)}}
It is the third input where I would like to perform conditionals. If #3 is empty, I want nothing (not even the round brackets).
A desired output for
\begin{itemize}
\item $\pcs{a}{b}{c}$
\item $\pcs{a}{b}{}$
\end{itemize}
should look like
etoolbox
, then\ifblank{#3}{}{^{(#3)}}
might be what you are after. Note that here I'd use^{\smash{(}#3\smash{)}}
as the^{(...)}
often gets excessively large and disturbs line spacing.etoolbox
with a reasonable up to date LaTeX installation. You can use\IfBlankF{#3}{^{(#3)}}
instead.