# In Beamer, how can one have strikethrough text in the author setting (defined by a command) in the preamble?

I have some beamer slides for which many commands are defined in the preamble before the document environment. The author setting is defined by an author variable which contains strikethrough text provided by the package ulem. The author setting is defined using this variable in the preamble for technical reasons.

\documentclass{beamer}
% strikethrough
\usepackage[normalem]{ulem}

\newcommand{\authorSpecification}{
}

\title{title}
%\author{test}
\author{\authorSpecification}
\date{\today}

\begin{document}

\frame{\titlepage}

\end{document}


When I try to compile this, I am presented with the following error:

! Argument of \UL@word has an extra }.
<inserted text>
\par
l.11 \author{\authorSpecification}


How can I fix this?

• I've added a better solution, which works for the preamble too – user31729 Sep 22 '15 at 20:11

The problem is that beamer wants to pass the author information also as metadata for the PDF file and of course it's impossible to apply \sout there.

The usual solution is to exploit \texorpdfstring:

\documentclass{beamer}

\usepackage[normalem]{ulem}

\newcommand{\authorSpecification}{%
}

\title{title}
\author{\authorSpecification}
\date{\today}

\begin{document}

\frame{\titlepage}

\end{document}


And pdfinfo will show the following information:

Title:          title
Subject:
Keywords:
Creator:        LaTeX with Beamer class version 3.36


Having \author after \begin{document} would make the Author field empty.

One can avoid \texorpdfstring by providing a replacement for \sout:

\documentclass{beamer}

\usepackage[normalem]{ulem}

\makeatletter
% in PDF strings, we want \sout to be a no-op
% \@iden = \@firstofone just strips the braces off
\pdfstringdefDisableCommands{\let\sout\@iden}
\makeatother

\newcommand{\authorSpecification}{%
}

\title{title}
\author{\authorSpecification}
\date{\today}

\begin{document}

\frame{\titlepage}

\end{document}


Using \robustify{\sout} (as proposed in another answer) would issue the warning

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing \sout' on input line 13.


and the \pdfstringdefDisableCommands command would be needed anyway to get rid of it.

Apparently \sout{...} conflicts with beamer's \author command, perhaps it tries to make a typesetting in the preamble already.

Shifting the \author command into the document body works however:

\documentclass{beamer}
% strikethrough
\usepackage[normalem]{ulem}

\newcommand{\authorSpecification}{%
}

\title{title}
%\author{test}

\date{\today}

\begin{document}
\author{\authorSpecification}
\frame{\titlepage}

\end{document}


Edit

The problem is the fragile command \sout: Robustifying helps and \author{\authorSpecification} can be used in the preamble.

\documentclass{beamer}
% strikethrough
\usepackage[normalem]{ulem}

\usepackage{etoolbox}

\robustify\sout

\newcommand{\authorSpecification}{%
}

\title{title}
\author{\authorSpecification}
\date{\today}

\begin{document}

\frame{\titlepage}

\end{document}

• @ChristienHupfer, I can use \sout{...} directly in title whitout any complain of LaTeX. I have installed recent beamer (3.36 from 2015/01.05). – Zarko Sep 21 '15 at 12:48
• @Zarko: Well, I can't, but I haven't updated on my notebook for some days – user31729 Sep 21 '15 at 12:51
• @Zarko: I just updated and still can't compile the example by the O.P. – user31729 Sep 21 '15 at 19:02
• @Zarko: I found the culprit: sout is fragile and must be robustified. – user31729 Sep 22 '15 at 20:40
• this is nice to hear (see :-)). Meantime I test package soul and its st` had the same problem. And thank you to pointed me to possibilities for robusting of macros. I was not aware before for this. Good to know this! – Zarko Sep 22 '15 at 21:37