Redefinir la altura de la imagen con el comando de renovación

Redefinir la altura de la imagen con el comando de renovación

He definido \secimagecomo imagen en la página de título de mi sección:

\AtBeginSection[]{
  \begin{frame}
  \vfill
  \begin{center}
  %\centering
  \includegraphics[width=4cm]{\secimage}\\
  \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \end{center}
  \vfill
  \end{frame}
}

Y para cada sección redefino la imagen usando \renewcommand{\secimage}{figureofchoice}. Pero en una de las secciones también me gustaría redefinir el ancho/alto. Intenté \renewcommand{\secimage}[heigth=4cm]{image}que la documentación de renewcommand defina las opciones, pero tengo un error de compilación.

Si alguien pudiera decirme que estoy haciendo mal

Respuesta1

El siguiente código sugiere un cambio en su notación. En lugar de \renewcommand{\secimage}{<image>}, utiliza \setsecimage{[<options>]{<image>}}donde le permite especificar opciones adicionales.

\newcommand{\setsecimage}[1]{\gdef\secimagedetail{#1}}% Store section image detail
\let\secimagedetail\relax% Default definition of section image detail

\AtBeginSection{
  \begin{frame}
    \vfill
    \begin{center}
      \ifx\secimagedetail\relax\else % If section image exists
        \expandafter\includegraphics\secimagedetail \\
      \fi
      \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
        \usebeamerfont{title}\insertsectionhead\par%
      \end{beamercolorbox}
    \end{center}
    \vfill
  \end{frame}
  \let\secimagedetail\relax% Remove section image detail
}

con un uso típico parecido

\setsecimage{[width=50pt]{example-image}}

\section{A section}

\section{Another section}

\setsecimage{{example-image}}

\section{Final section}

Si \setsecimageno incluye ninguno <options>(para la sección final del código anterior), aún debe "poner doble llave" en el <image>argumento, como en \setsecimage{{<image>}}.

Respuesta2

Defina un \setsecimagecomando con la misma sintaxis que \includegraphics. El truco es que redefine otra macro.

\documentclass{beamer}

\AtBeginSection[]{
  \begin{frame}
  \vfill
  \begin{center}
  %\centering
  \addsecimage\\
  \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \end{center}
  \vfill
  \end{frame}
}

\newcommand{\setsecimage}[2][width=4cm]{%
  \renewcommand{\addsecimage}{\includegraphics[#1]{#2}}%
}
\newcommand{\addsecimage}{} % initialize

\begin{document}

\setsecimage{example-image}

\section{Normal}

\setsecimage[width=2cm]{example-image-a}

\section{Small}

\end{document}

ingrese la descripción de la imagen aquí

información relacionada