[Tex/LaTex] Including an image on the section title page of beamer

beamergraphicssectioningtitles

I'm making a presentation on beamer and I was able to create a frame with the section title with the code: (I'm sorry for the code, didn't quite understand how to insert it correctly)

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

but now I would like to include an image on the page as well, not the same one for every section, but a particular one for each section.

Thank you

Best Answer

An easy solution would be to store the image name in a macro and redefine it where needed.

\documentclass{beamer}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Section title frame 
\AtBeginSection[]{
  \begin{frame}
     \vfill
     \centering
     \includegraphics[width=4cm]{\secimage}

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

\newcommand{\secimage}{example-image-a}

\begin{document}

  \section{A}

  {
    \renewcommand{\secimage}{example-image-b}
  \section{B}
    }

  \section{C}

\end{document} 

enter image description here