2

I want to test if a given page is a section page in beamer.

The idea is to draw a progress bar, and 'mark' the positions of the next section. However, for that I need to know if a given page is a section page, and if it is then do something.

This is how I draw the progressbar:

\setbeamertemplate{background}{%
    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@progresswidth
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

    \begin{tikzpicture}
        \useasboundingbox (0,0) rectangle (\the\paperwidth, \the\paperheight);
        \fill[color=FuwaWhite] (0,0) rectangle (12.8cm, 9.6cm);

        \ifnum\thepage=1\relax\else
            \draw[fill=FuwaGreen,draw=none] (0cm, 0cm) rectangle (\progressbar@tmpdim,0.05cm);
            \node[anchor=south] at(6.4cm, 0.1cm) {\color{FuwaAnthrazit}\tiny\insertdate};
            \node[anchor=south east] at(12.8cm, 0.1cm) {\color{FuwaAnthrazit}\tiny\insertframenumber/%
                \inserttotalframenumber};
        \fi
        \foreach \x in {1,...,\inserttotalframenumber} {%
            \progressbar@tmpdim=\progressbar@progresswidth
            \divide\progressbar@tmpdim by \totvalue{section}
            \draw[fill=FuwaGreen!50!FuwaBlack,draw=none] (\x*\progressbar@tmpdim, 0) rectangle (\x*\progressbar@tmpdim+0.05cm, 0.05cm);
        }
   \end{tikzpicture}
}

However they are evenly spaced, I want them to be spaced to be like the sections. So I would instead iterate over each page and check if that page is a section page (i.e., what beamer considers a section page) and then draw something.

6
  • What do you mean by a section page? Are you looking for \AtBeginSection[]?
    – cfr
    Apr 3, 2016 at 3:05
  • Can you show, how you create the progress bar? Apr 3, 2016 at 9:45
  • cfr samcarter: Added the code I am using
    – Neikos
    Apr 3, 2016 at 18:31
  • Please make your code compilable, or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. Right now pasting your code in an otherwise empty beamer document, just gives me tons of errors... Apr 3, 2016 at 20:04
  • tex.stackexchange.com/a/285383/36296 might be of help, especially how to get frame number of the section start. Apr 3, 2016 at 20:05

1 Answer 1

3

I might not be able to check if its a section page, but I can check if a page is the first page of a section. Is it save to assume that every first page of your sections is a section page?

\documentclass{beamer}

\usepackage{etoolbox}
\makeatletter
\newcount\beamer@sectionstartframe
\beamer@sectionstartframe=1
\apptocmd{\beamer@section}{\addtocontents{nav}{\protect\headcommand{%
            \protect\beamer@sectionframes{\the\beamer@sectionstartframe}{\the\c@framenumber}}}}{}{}
\apptocmd{\beamer@section}{\beamer@sectionstartframe=\c@framenumber\advance\beamer@sectionstartframe by1\relax}{}{}
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
        {\noexpand\headcommand{\noexpand\beamer@sectionframes{\the\beamer@sectionstartframe}{\the\c@framenumber}}}}}{}{}
\def\beamer@startframeofsection{1}
\def\beamer@endframeofsection{1}
\def\beamer@sectionframes#1#2{%
    \ifnum\c@framenumber<#1%
    \else%
    \ifnum\c@framenumber>#2%
    \else%
    \gdef\beamer@startframeofsection{#1}%
    \gdef\beamer@endframeofsection{#2}%
    \fi%
    \fi%
}
\newcommand\insertsectionstartframe{\beamer@startframeofsection}
\newcommand\insertsectionendframe{\beamer@endframeofsection}
\makeatother

\setbeamertemplate{headline}{%
    \ifnum\insertsectionstartframe=\insertframenumber%
        \Huge I'm section!
    \fi%
    }

\begin{document}

    \section{The First}

    \begin{frame}
        First slide
    \end{frame}

    \begin{frame}
        Second slide
    \end{frame}

    \begin{frame}
        Third slide
    \end{frame}

    \begin{frame}
        Fourth slide
    \end{frame}

    \section{The Second}

    \begin{frame}
        First slide
    \end{frame}

    \begin{frame}
        Second slide
    \end{frame}

    \begin{frame}
        Third slide
    \end{frame}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .