
我有這個 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
其餘部分之前被“執行”,即真正的部分程式碼( )。在連結問題的答案的定義中,ed 為,因此一開始始終為空。\section
\beameroldsection
\sectiondesc
\gdef
{}
\gdef\sectiondesc{#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}