AtBeginSection Beamerを適切に使用する

AtBeginSection Beamerを適切に使用する

私はMWE(フォローアップから)を持っていますこれ

\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}

\sectionpage私がやろうとしたのは、各セクションの始めにを置くことです。しかし、\sectiondescこのページでは は空です。

\sectiondesc最初のスライドに印刷するにはどうすればいいですか?

答え1

コード\AtBeginSectionは、 の残りの部分\section、つまり実際のセクション コード ( ) が呼び出される前に「実行」されます\beameroldsection。リンクされた質問の回答の定義では、 はと\sectiondesc\gdefれている{}ため、最初は常に空です。

\gdef\sectiondesc{#4}動作しますが、説明がない場合 (つまり、4 番目の引数が空の場合)、\sectiondescマクロは何も展開されません。

\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}

ここに画像の説明を入力してください

関連情報