# Avoid empty first slide with xsavebox in beamer

The following code, where I want to define some saved boxes I refer to throughout the document, produces an empty slide before the title slide (compiled with mklatex -pdfxe, it works fine with pdflatex):

\documentclass{beamer}

\usepackage{xsavebox}

\begin{document}
\begin{xlrbox}{A}
A
\end{xlrbox}%
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\theA
\end{frame}
\end{document}


How can I avoid the empty slide? I don't understand where that slide comes from either.

• I do not get an empty slide when I compile your document on an updated TeXLive 2019 installation.
– user194703
Jan 14 '20 at 17:59
• @Schrödinger'scat ah, it only happens with xelatex. Try latexmk -pdfxe Jan 14 '20 at 18:04
• (reasons not to use xelatex)++. ;-)
– user194703
Jan 14 '20 at 18:05
• Move the box creation to the same frame as title is. I mean, \begin{frame} \titlepage \begin{xlrbox}{A} A \end{xlrbox} \end{frame} Jan 14 '20 at 18:12
• @Sigur right, that works, but then I always need to include the titleframe if I reference the box right? So it breaks \includeonlyframes{current}. My workaround is to use \includeonlyframes{title,current} but that's not nice :) Jan 14 '20 at 18:19

With all workflows that involve DVI/XDVI, making a PDF XObject (e. g. through xsavebox) needs to happen on a document page. It is implemented through specials (\special{ps: ...} and \special{pdf: ...}) for these workflows.

To avoid the extra page with the beamer class, put xlrbox/\xsbox in a frame, as suggested by user Sigur.

\documentclass{beamer}

\usepackage{xsavebox}

\begin{document}
\begin{frame}
\begin{xlrbox}{A}
A
\end{xlrbox}%
\titlepage
\end{frame}

\begin{frame}
\theA
\end{frame}

\end{document}