% !TEX root = ./testing/talktest.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The spectrum beamer/ltx-talk theme
% A clean beamer/ltx-talk theme with a big title graphic
% Maintained by samcarter
%
% Project repository and bug tracker:
% https://github.com/samcarter/beamertheme-spectrum
%
% Released under the LaTeX Project Public License v1.3c or later
% See https://www.latex-project.org/lppl.txt
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesPackage{talkthemespectrum}[2026/02/12 version v0.6 Spectrum beamer theme]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% option handling
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\titlegraphic}[1]{\def\@titlegraphic{#1}\def\@sectiongraphic{#1}}
\newcommand{\sectiongraphic}[1]{\def\@sectiongraphic{#1}}
\newcommand\titlecredit[1]{\def\@titlecredit{#1}}

\DeclareColor{spectrum@colour}[RGB]{38, 38, 134}

\ExplSyntaxOn
\keys_define:nn { talk@spectrum } {
  themecolor.code=\colorlet{structure}{#1},
  themecolor.initial:n=spectrum@colour,
  titlegraphic.code=\titlegraphic{#1},
  titlegraphic.initial:n=beamertheme-spectrum-bg.jpg,
  titlecredit.code=\titlecredit{#1},
  titlecredit.initial:n={},
  sectiongraphic.code=\sectiongraphic{#1},
  sectiongraphic.initial:n=beamertheme-spectrum-bg.jpg,
}
\ProcessKeyOptions[talk@spectrum]
\ExplSyntaxOff

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% header area with frame title
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% adjust space above/below frametitle -> this sets position within the coloured background
\geometry{
  tmargin = 1.8cm,
  headsep = 0.8cm,
}

% header settings
\EditInstance{header}{std}{
  background-color = structure,
  color = white,
  height = 1.8cm
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% footer
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\EditInstance{footer}{std}{
  color = gray,
  separator = {\hfill|\hfill},
  element-order = {date,author,title,institute,framenumber},
  right-hspace = 3mm,
  left-hspace = 3mm,
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ExplSyntaxOn
\DeclareTemplateInterface { titlepage } { talk } { 0 } { }
\DeclareTemplateCode { titlepage } { talk } { 0 } { } {
  \thispagestyle{plain}
  \centerline{
    \setlength\unitlength{1cm}
    \begin{picture}(\paperwidth,\paperheight)(0,\dimeval{-\Gm@tmargin-\headsep})
      \put(0,2.1cm){\color{structure}\rule{\paperwidth}{\dimeval{\paperheight-2.1cm}}}
      \str_if_eq:eeF {\@titlegraphic} {none} {
        \put(0,2.45cm){\includegraphics[width=\paperwidth,artifact]{\@titlegraphic}}
      }
      \ifx\@title\empty\else
        \str_if_eq:eeF {\@titlegraphic} {none} {
          \put(\dimeval{\Gm@lmargin+0.15em},\dimeval{\paperheight-\Gm@lmargin-1cm-0.15em}){
            \parbox[t]{\linewidth}{
              \opacity_select:n { 0.5 }
              \UseInstance { titlepage-element } {title} { \color{black}\@title }\par
              \ifx\@subtitle\empty\else
                \medskip
                \UseInstance { titlepage-element } {subtitle} { \color{black}\@subtitle }\par
              \fi
            }% parbox
          }% put
        }
        \put(\Gm@lmargin,\dimeval{\paperheight-\Gm@lmargin-1cm}){
          \parbox[t]{\linewidth}{
            \UseInstance { titlepage-element } {title} { \@title }\par
            \ifx\@subtitle\empty\else
              \medskip
              \UseInstance { titlepage-element } {subtitle} { \@subtitle }\par
            \fi
          }% parbox
        }% put
      \fi % empty title
      \put(\Gm@lmargin,-0.1cm){
        \parbox[b]{\linewidth}{
          \ifx\@author\@empty \else
            \UseInstance { titlepage-element } {author} { \@author }\par\smallskip
          \fi
          \ifx\@institute\@empty \else
            \UseInstance { titlepage-element } {institute} { \@institute }\par\smallskip
          \fi
          \ifx\@date\@empty \else
            \UseInstance { titlepage-element } {date} { \@date }\par
          \fi
        }% parbox
      }% put
      \put(\dimeval{\paperwidth-2mm},-0.5cm){
        \makebox[0pt][r]{\tiny\@titlecredit}
      }% put
    \end{picture}
  }% centerline
  \vskip-\Gm@tmargin
  \vskip-\headsep
}
\ExplSyntaxOff

\EditInstance{titlepage-element}{title}{
  font=\Huge\bfseries,
  color=white,
  before-skip = 0em,
  after-skip = 0em
}
\EditInstance{titlepage-element}{subtitle}{
  font=\LARGE\bfseries,
  color=white,
  before-skip = 0em,
  after-skip = 0em
}
\EditInstance{titlepage-element}{author}{
  font=\normalsize,
  color=black,
  before-skip = 0em,
  after-skip = 0em
}
\EditInstance{titlepage-element}{institute}{
  font=\normalsize,
  color=black,
  before-skip = 0em,
  after-skip = 0em
}
\EditInstance{titlepage-element}{date}{
  font=\normalsize,
  color=black,
  before-skip = 0em,
  after-skip = 0em
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Section page
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn
\NewTemplateType { sectionpage } { 0 }
\DeclareTemplateInterface { sectionpage } { talk } { 0 } { }
\DeclareTemplateCode { sectionpage } { talk } { 0 } { } {
  \begin{frame}
    \centerline{
      \setlength\unitlength{1cm}
      \begin{picture}(\paperwidth,\paperheight)(0,\dimeval{-\Gm@tmargin-\headsep})
        \put(0,\dimeval{\paperheight-3.5cm}){\color{structure}\rule{\paperwidth}{3.5cm}}
        \str_if_eq:eeF {\@sectiongraphic} {none} {
          \put(0,\dimeval{\paperheight-3.15cm}){\includegraphics[width=\paperwidth,artifact]{\@sectiongraphic}}
        }
        \put(\Gm@lmargin,\dimeval{\paperheight-6cm}){
          \LARGE\bfseries\l__talk_section_tl\par
        }
      \end{picture}
    }% centerline
    \vskip-\Gm@tmargin
    \vskip-\headsep
  \end{frame}
}
\ExplSyntaxOff
