I am creating my CV with LaTeX on Overleaf. I defined a custom command \cvpub in my .cls file to typeset publication entries. It takes 8 arguments (tag, authors, title, venue, year, conference, DOI, award).
Here is the definition:
\newcommand{\cvpub}[8]{%
\noindent
\begin{tabular}{@{}p{2em}@{\hspace{1em}}p{0.85\linewidth}}%
\textcolor{black}{#1} % Tag
& #2 \\ % Authors
& \textbf{#3} \\ % Title
& \textit{#4}, #5 #6 \\ % Venue + Year
\ifx&% If DOI is empty
\ifx& % If Award is empy
% Both DOI and Award are empty: do nothing
\else % If Award is not empty (and DOI is not empty)
& \textbf{\textcolor{black}{#8}} \\ % Award
\fi
\else % If DOI is not empty
\ifx&% If Award is empty
& \textnormal{doi: #7} % DOI
\else %If DOI is not empty and Award is not empty
& \textnormal{doi: #7}, \textbf{\textcolor{black}{#8}} \\ % DOI, Award
\fi
\fi
\end{tabular}%
}
When I use \cvpub in cv.tex, if the DOI exists but the award does not, it causes an error.
For example, in the following code from cv.tex, P1 and P2 work correctly, but P3 does not. What’s particularly confusing is that the DOI shows up twice in P3.
Output PDF:
Code:
\cvpub % Works well
{P1}
{Author, Author, Author} %Authors
{Title} %Title
{Journal name} %Venue
{2025} %Year
{(Conference))} %Conference tag
{} %DOI
{Award} %Award
\cvpub % Works Well
{P2}
{Author, Author, Author} %Authors
{Title} %Title
{Journal name} %Venue
{2025} %Year
{(Conference))} %Conference tag
{} %DOI
{} %Award
\cvpub{P3} % Does Not Work
{Author, Author, Author} %Authors
{Title} %Title
{Journal name} %Venue
{2025} %Year
{(Conference))} %Conference tag
{10.1111/XXXX.1234.56789} %DOI
{} %Award %Line 94
Overleaf errors:
Incomplete \ifx; all text was ignored after line 94.
Missing } inserted.
Extra alignment tab has been changed to \cr.
Extra \fi.
Underfull \hbox (badness 10000) in paragraph at lines 94--94
Overfull \hbox (88.24603pt too wide) in paragraph at lines 94--94
Question: Why does case P3 (DOI present but Award empty) fail? How should I revise this macro to make it works in all three cases (DOI only, Award only, or both)?


\ifxtests the expansion the tokens and&will not expand to something it likes inside atabular. if you still have problems, please provide complete but minimal code we can compile to reproduce the problem.\IfBlankTF{arg}{true code}{false code}.