
コマンドを再定義して、コマンドについての説明を含む\section
1 つの入力を受け取ることができるようにします。MWE を考えてみましょう。\sectiondesc
\documentclass{beamer}
\usepackage{graphicx}
\begin{document}
%%% old definition
\section[short title]{Long Title}
%%% new definition
%\section[short title]{Long Title}{Really long description \\ multiple lines, often with graphics \includegraphics[width=.5\textwidth]{example-image-a}}
\begin{frame}
\sectionpage
\begin{center}
\normalfont
% \sectiondesc
\end{center}
\end{frame}
\end{document}
答え1
私の見解では、xparse
とを使用する方法が最も簡単です。\RenewDocumentCommand
\section[]{}[]
ただし、セクションの説明を省略できる、つまりを使用することをお勧めします。
マクロは、呼び出し\sectiondesc
ごとに何も展開されないように再定義されるため\section
、4 番目の引数を省略するとセクションの説明は提供されません。
\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
}%
}
\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
\begin{center}
\normalfont
\sectiondesc
\end{center}
\end{frame}
\section*{Foo}
\begin{frame}
\sectionpage
\begin{center}
\normalfont
\sectiondesc
\end{center}
\end{frame}
\end{document}