5

I'm working on a beamer theme in which each of the title page elements is optional; for example, I don't want defining an empty date to produce a large empty space on the title slide. I figured I could do this by wrapping the layout for each element in a conditional like so:

\ifx\insertdate\empty%
\else
   ...
   \insertdate
   \vskip{1em}
   ...
\fi

And this pattern works as expected... except for the author. For whatever reason, \ifx\insertauthor\empty never seems to evaluate to true, unlike the other title page elements:

\documentclass{beamer}
\author{}
\date{}
\begin{document}
  \ifx\insertauthor\empty
    empty
  \else
    nonempty
  \fi
  % outputs "nonempty"

  \ifx\insertdate\empty
    empty
  \else
    nonempty
  \fi
  % outputs "empty"
\end{document}

Why is this? Is there any workaround that would let me test for an empty author?

3

The definition text of \insertauthor is not empty, which is quite obvious, because the macro is meant to do something with data that should already have been given.

From beamerbasetitle.sty, line 149 and following:

% The \author command
%
%
\def\author{\@dblarg\beamer@author}
\long\def\beamer@author[#1]#2{%
  \def\insertauthor{\def\inst{\beamer@insttitle}\def\and{\beamer@andtitle}#2}%
  \def\beamer@shortauthor{#1}%
  \ifbeamer@autopdfinfo%
    \def\beamer@andstripped{}%
    \beamer@stripands#2 \and\relax
    {\let\inst=\@gobble\let\thanks=\@gobble\def\and{, }\hypersetup{pdfauthor={\beamer@andstripped}}}
  \fi%
}

So when you specify \author (with or without the optional argument), \insertauthor is defined (and not empty). Since on line 173 we find

\author{}

we deduce that \insertauthor is initialized and is never empty at the start of a beamer job.

You're probably better served by testing \beamer@shortauthor, which will be indeed empty at the start of a job, until another \author command appears.

\documentclass{beamer}
\author{}
\date{}
\begin{document}

\makeatletter
\ifx\beamer@shortauthor\empty
  empty
\else
  nonempty
\fi
\makeatother

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.