[Tex/LaTex] Beamer section – different color schemes

beamersectioning

In my Latex (sharelatex) beamer document, I do have a

\section{Section Title}

for showing a section. In the *.sty, sections are defined as

% begin Sections -

\if@doSectionPage\@empty 
\else
% Insert frame with section title at every section start
\AtBeginSection[]
{
  \begingroup
  \setbeamercolor{background canvas}{bg=blue_background}
  \begin{frame}[plain]
    \vspace{2em}\usebeamerfont{section title}
    \progressbar@progressbar%
  \end{frame}
 \endgroup
}
\fi

% end Sections

  1. I wonder if it's possible to switch background colors of sections, according to a pre-defined theme. Something like

    \section[blue_background]{Section Title} or
    \section[red_background]{Section Title}
    
  2. Also, is it possible to define a white font for slides with dark
    background (black) and a dark font for slides with bright (white)
    background?

Best Answer

You could define your own command for creating sections. As for your second questions, determining if a colour is dark or bright might be difficult, but maybe just taking the compliment colour might be a quick workaround:

\documentclass{beamer}

\newcommand{\mysection}[2][blue]{%
    \begingroup
    \setbeamercolor{background canvas}{bg=#1}
    \setbeamercolor{section title}{fg=-#1}
    \section{#2}
    \begin{frame}[plain]
      \vspace{2em}\usebeamercolor[fg]{section title}\usebeamerfont{section title}
      bla
    \end{frame}
    \endgroup
}

\begin{document}

\mysection[blue]{blue section}
\begin{frame}
    abc
\end{frame} 

\mysection[red]{red section}
\begin{frame}
    abc
\end{frame} 

\mysection{default colour}
\begin{frame}
    abc
\end{frame}     

\end{document}