Redefina \section para receber mais uma entrada

Redefina \section para receber mais uma entrada

Quero redefinir \sectiono comando para que ele possa receber uma entrada \sectiondesc; que conteria uma descrição sobre ele. Considere o 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}

Responder1

O caminho com xparsee \RenewDocumentCommandé o mais fácil, no meu ponto de vista.

Sugiro usar \section[]{}[]entretanto, ou seja, é possível omitir a descrição da seção.

A \sectiondescmacro é redefinida para ser expandida para nada a cada \sectionchamada, portanto, a omissão do quarto argumento não fornecerá nenhuma descrição da seção.

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

informação relacionada