입력을 하나 더 받으려면 \section을 재정의하세요.

입력을 하나 더 받으려면 \section을 재정의하세요.

\section하나의 입력을 받을 수 있도록 명령을 재정의하고 싶습니다 \sectiondesc. 그것에 대한 설명이 포함되어 있습니다. MWE를 고려해보세요.

\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

내 관점에서는 xparseand 를 사용하는 방법이 가장 쉬운 방법입니다.\RenewDocumentCommand

그러나 사용하는 것이 좋습니다 \section[]{}[]. 즉, 섹션 설명을 생략할 수 있습니다.

매크로 는 호출 \sectiondesc할 때마다 아무것도 확장되지 않도록 재정의되므로 \section4번째 인수를 생략하면 섹션 설명이 제공되지 않습니다.

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

관련 정보