2

I have this MWE (follow-up from this)

\documentclass{beamer}
\usepackage{graphicx}

\usepackage{xparse}

\let\beameroldsection\section% Store the old definition first

\def\sectiondesc{}
\RenewDocumentCommand{\section}{sO{#3}m O{}}{%
    \gdef\sectiondesc{}
    \IfBooleanTF{#1}{% Grab the starred version, i.e. \section*
        \beameroldsection*{#3}%
    }{%
        \beameroldsection[#2]{#3}%
        \gdef\sectiondesc{#4}% Store argument 4
    }%
}

\setbeamertemplate{section page}
{
    \begin{centering}
        \begin{beamercolorbox}[sep=12pt,center]{part title}
            \usebeamerfont{section title}{\insertsection}\par \insertsectionhead
        \end{beamercolorbox}
    \end{centering}

    \begin{center}
        \sectiondesc        
    \end{center}

}


\AtBeginSection[]{
    \begin{frame}{Overview}
        \hfill
        \begin{minipage}{.45\textwidth}
            nothing?\sectionpage%\sectiondesc %%% Tried both `\sectionpage` and `\sectiondesc`
        \end{minipage}
    \end{frame}
}


\begin{document}


    \section[short title]{Long Title}[Really long description \\ multiple lines, often with graphics \includegraphics[width=.5\textwidth]{example-image-a}]

    \begin{frame}
    \sectionpage
    \end{frame}


%   \section*{Foo}
%   \begin{frame}
%   \sectionpage
%   \end{frame}

\end{document}

What I tried to do is to have the \sectionpage at the beginning of every section. However, the \sectiondesc is empty at this page.

What should I do to print \sectiondesc in the beginiing slide?

3

The \AtBeginSection code is 'executed', before the rest of \section is called, i.e. the real section code (\beameroldsection). In the definition of the answer in the linked question the \sectiondesc is \gdefed to be {}, so this is empty in the beginning always.

\gdef\sectiondesc{#4} works, if there is no description (i.e. the 4th argument is empty) the \sectiondesc macro expands to nothing.

\documentclass{beamer}
\usepackage{graphicx}

\usepackage{xparse}

\let\beameroldsection\section% Store the old definition first

\def\sectiondesc{}
\RenewDocumentCommand{\section}{sO{#3}m O{}}{%
  \gdef\sectiondesc{#4}% Store the 4th argument beforehand
    \IfBooleanTF{#1}{% Grab the starred version, i.e. \section*
        \beameroldsection*{#3}%
    }{%
        \beameroldsection[#2]{#3}%
     }%
}

\setbeamertemplate{section page}
{
    \begin{centering}
        \begin{beamercolorbox}[sep=12pt,center]{part title}
            \usebeamerfont{section title}{\insertsection}\par \insertsectionhead
        \end{beamercolorbox}
    \end{centering}

    \begin{center}
      \sectiondesc
    \end{center}

}


\AtBeginSection[]{
    \begin{frame}{Overview}
        \hfill
        \begin{minipage}{.45\textwidth}
            \sectionpage%%% Tried both `\sectionpage` and `\sectiondesc`
        \end{minipage}
    \end{frame}
}


\begin{document}


\section[short title]{Long Title}[Really long description \\ multiple lines, often with graphics \includegraphics[width=.5\textwidth]{example-image-a}]

\begin{frame}
  \sectionpage
\end{frame}


\end{document}

enter image description here

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.