2

I am reporting here an issue that (in a way) has been discovered by the user Blitz of another LaTeX forum here.

Consider the MWE

\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{What's going on here?}
\xdef\mytext{\underline{duck}}
\underline{underline is not the problem}
\end{frame}
\end{document}

On my TeXLive 2017 distribution, it throws the error

! Use of \beamer@@frametitle doesn't match its definition.
\new@ifnextchar ...served@d = #1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...
l.7 \end{frame}

If I replace \xdef by \def, no error occurs, and when I do not use \underline but nothing or \textbf, say, everything goes well. After some amount of playing, my impression is that the error appears if \xdef and \underline are used simultaneously.

QUESTION: Why is that and how can it be fixed?

6
  • My general rule of thumb: do definitions outside of frames. If \xdef\mytext{\underline{duck}} is moved to the preamble it seems to work fine. Apr 22, 2018 at 19:45
  • @samcarter Did you mean "no definitions inside frames"? And sometimes one has to do definitions inside frames, or at least things get much simpler that way.
    – user121799
    Apr 22, 2018 at 19:49
  • Yes, no definitions inside frames. Sometimes it works, but it can cause many funny errors - one of which you found. Apr 22, 2018 at 19:52
  • I just had a look at the answer you linked to. Can't you simply use the if case inside the node? \node[right=2cm of pointer\X.one east,murmel] (murmel\X) { \ifnum\X=4 MSVCRTexhandler \else Exception\underline{~~}handler\X () \fi }; Apr 22, 2018 at 19:58
  • \xdef isn't a latex command.... Apr 22, 2018 at 20:00

1 Answer 1

3

\underline in beamer is a fragile command and any such command will give more or less arbitrary errors in \edef or \xdef or any other moving argument.

It isn't clear why \xdef is being used at all, but you can make \underline safe in the \xdef with \noexpand

\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{What's going on here?}
\xdef\mytext{\noexpand\underline{duck}}
\underline{underline is not the problem}
\end{frame}
\end{document}

You must log in to answer this question.