0

I am trying to determine if there are pages in the appendix. If there are I want to show a separation page/frame as indicator but in the handout mode only. In my current setup (due to some peculiarities of the beamer modes) there is ALWAYS an \appendix command, so hooking into that would not work. However, when looking at the implementations of \insertpresentationendpage and \insertappendixendpage I am quite sure that I can determine it by looking at the value of \beamer@startpageofappendix but for some reason I am not able to even though I have used \makeatletter. I have tried with \value, prepending \the etc. to no avail... in the end I ended up with various error message, especially:

! Undefined control sequence.
<argument> ...pendix\@ empty \else \ifnum \beamer 
                                                 @startpageofappendix=\beam...

So my question is: how to avoid rendering a frame if there are frames after the \appendix command?

3
  • Can you try using \typeout to determine what \beamer@startpageofappendix really is or does?
    – user121799
    Nov 30, 2018 at 19:02
  • Well, no, because that too gives me an undefined control sequence message. :) I'll try to create a MWE.
    – stefanct
    Nov 30, 2018 at 19:05
  • 1
    Lesson learned (again): try creating a MWE if you get stuck instead of staring at error messages for hours ;)
    – stefanct
    Dec 1, 2018 at 2:45

2 Answers 2

0

This can happen if you try to access the counters within \mode<handout> (I have no idea why though). Just putting the mode switch within the if as below works fine.

\documentclass[handout]{beamer}
\usepackage[utf8]{inputenc}
\begin{document}
% To test this MWE set \test below and compile two times.
% test=1 shall render the first page only, test=0 will print 3 pages
\def\test{1}

\begin{frame}{}
    Main content\\
    Always shown.
\end{frame}


\makeatletter
\typeout{startpageofappendix=\beamer@startpageofappendix, endpageofdocument=\beamer@endpageofdocument}
\ifx\beamer@startpageofappendix\@empty
\else
    \ifnum\beamer@startpageofappendix=\beamer@endpageofdocument
        \mode<handout>{
            \begin{frame}{}
                Appendix follows...\\
                on pages \beamer@startpageofappendix{} to \beamer@endpageofdocument{}\\
                This frame should not be rendered w/o the last frame!
            \end{frame}
        }
    \fi
\fi
\makeatother

\appendix

\ifnum\test=0%
    \begin{frame}{}
        Appendix slide 1.\\
        If this is shown the previous frame should be shown as well.
    \end{frame}
\fi

\end{document}
0

I would add this separation frame to the definition of the \appendix and check if \inserttotalframenumber is equal to \insertmainframenumber

\documentclass{beamer}

\makeatletter
\renewcommand<>\appendix{%
    \ifnum\inserttotalframenumber=\insertmainframenumber
    \else
    \begin{frame}
        APPENDIX
    \end{frame}
    \fi
  \beamer@inappendixtrue%
  \only#1{\part{\appendixname}%
  \immediate\write\@auxout{\string\@writefile{nav}%
    {\noexpand\headcommand{\noexpand\gdef\noexpand\insertmainframenumber{\the\c@framenumber}}}}%
  \addtocontents{nav}{\protect\headcommand{\protect\beamer@appendixpages{\the\c@page}}}%
  \beamer@resetappendix}%
}
\makeatother

\begin{document}

\begin{frame}
content...
\end{frame}

\appendix

\begin{frame}
content...
\end{frame}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .