2

I would like to know if there is an easy way to get the total number of frames within a subsubsection in Beamer ?

I already managed to get the frame count in each subsubsection, as can be seen in the MWE.

\documentclass{beamer}

\newcounter{insub}
\AtBeginSubsection[]{\setcounter{insub}{0}}
\AtBeginEnvironment{frame}{\addtocounter{insub}{1}}
\setbeamertemplate{frametitle}{\subsecname{} -- \theinsub\ of XYZ slides in current subsubsection}

\begin{document}

\section{A}
\subsection{A.1}
\subsection{First subsubsection}
\begin{frame}{.}
    abc
    \pause 
    cdef
\end{frame} 

\begin{frame}{.}
   How to automatically get XYZ?
\end{frame}

\subsection{Second subsubsection}
\begin{frame}{.}
    abc
    \pause 
    cdef
\end{frame} 

\begin{frame}{.}

\end{frame}

\begin{frame}{.}
   How to automatically get XYZ?
\end{frame}

\end{document}
  • Have a look at the xcntperchap package – samcarter_is_at_topanswers.xyz Aug 30 '18 at 14:41
  • @samcarter : according to the author, this package is not working with beamer yet. – Bibi Aug 30 '18 at 14:45
  • do you mean "I already managed... subsection" rather than subsubsection? – user4686 Sep 6 '18 at 8:54
  • I feel like this can be done by reading .nav files. Simple Count how many \slideentry are there between the correct subsubsectionentry. – Symbol 1 Sep 7 '18 at 2:15
8
+100

So this is a proof of concept

\documentclass{beamer}
\usepackage{tikz}
\begin{document}

\makeatletter
\newif\ifincurrentsection
\newif\ifincurrentsubsection
\newif\ifincurrentsubsubsection
\newif\ifincurrentframe
\def\counteverything{
    \tikz[remember picture,overlay]{
        \def\drawsubsubsection##1{
            \ifx\subsubxpos\undefined\else
                \draw(\subsubxpos-.5,-2)--node[below]{this subsubsection}(##1-.5,-2);
                \global\let\subsubxpos\undefined
            \fi
        }
        \def\headcommand##1{##1}
        \def\beamer@documentpages##1{
            \drawsubsubsection{##1+1}
        }
        \def\sectionentry##1##2##3##4##5{
            \drawsubsubsection{##3}
        }
        \def\beamer@subsectionentry##1##2##3##4##5{
            \drawsubsubsection{##4}
        }
        \def\beamer@subsubsectionentry##1##2##3##4##5##6{
            \drawsubsubsection{##5}
            \ifnum\c@section=##2
                \incurrentsectiontrue
            \else
                \incurrentsectionfalse
            \fi
            \ifnum\c@subsection=##3
                \incurrentsubsectiontrue
            \else
                \incurrentsubsectionfalse
            \fi
            \ifnum\c@subsubsection=##4
                \incurrentsubsubsectiontrue
            \else
                \incurrentsubsubsectionfalse
            \fi
            \ifincurrentsection
                \ifincurrentsubsection
                    \ifincurrentsubsubsection
                        \xdef\subsubxpos{##5}
                    \fi
                \fi
            \fi
        }
        \def\slideentry##1##2##3##4##5##6{
            \ifnum\c@subsectionslide=##3
                \incurrentframetrue
            \else
                \incurrentframefalse
            \fi
        }
        \def\beamer@sectionpages##1##2{
            \ifincurrentsection
                \draw(##1-.5,-4)--node[below]{this section}(##2+.5,-4);
            \fi
        }
        \def\beamer@subsectionpages##1##2{
            \ifincurrentsection
                \ifincurrentsubsection
                    \ifnum##1<##2
                        \draw(##1-.5,-3)--node[below]{this subsection}(##2+.5,-3);
                    \fi
                \fi
            \fi
        }
        \def\beamer@framepages##1##2{
            \draw foreach\x in{##1,...,##2}{
                \ifnum\c@page=\x
                    (\x,0)circle(2pt)
                \else
                    (\x,0)circle(1pt)
                \fi
            };
            \ifincurrentsection
                \ifincurrentsubsection
                    \ifincurrentsubsubsection
                        \ifincurrentframe
                            \draw(##1-.5,-1)--node[below]{this frame}(##2+.5,-1);
                        \fi
                    \fi
                \fi
            \fi
        }
        \tikzset{shift={(2,-2)},x=4pt,y=9pt}
        \input{\jobname.nav}
    }
}
\setbeamertemplate{headline}{
    \counteverything
}

\section{Sec1}
    \subsection{Sec1-Ssec1}
        \subsubsection{Sec1-Ssec1-sssec1}
            \frame{A}
            \frame{B\pause C}
        \subsubsection{Sec1-Ssec1-sssec2}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
    \subsection{Sec1-Ssec2}
        \subsubsection{Sec1-Ssec2-sssec1}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
            \frame{G\pause H\pause I\pause J}
        \subsubsection{Sec1-Ssec2-sssec2}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
            \frame{G\pause H\pause I\pause J}
            \frame{K\pause L\pause M\pause N\pause O}

\section{Sec2}
    \subsection{Sec2-Ssec1}
        \subsubsection{Sec2-Ssec1-sssec1}
            \frame{A}
            \frame{B\pause C}
        \subsubsection{Sec2-Ssec1-sssec2}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
    \subsection{Sec1-Ssec2}
        \subsubsection{Sec2-Ssec2-sssec1}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
            \frame{G\pause H\pause I\pause J}
        \subsubsection{Sec2-Ssec2-sssec2}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
            \frame{G\pause H\pause I\pause J}
            \frame{K\pause L\pause M\pause N\pause O}

\end{document}

EDIT

This is what OP wants. The idea is to uses hooks such as \slideentry to help you accumulate.

\documentclass{beamer}
\usepackage{tikz}
\begin{document}

\makeatletter
\newif\ifincurrentsection
\newif\ifincurrentsubsection
\newif\ifincurrentsubsubsection
\newif\ifincurrentframe
\def\counteverything{
    \tikz[remember picture,overlay]{
        \def\stopcountingsubsubsection{
            \ifx\subsubcount\undefined\else
                \draw(2,-2)node[align=center]{
                    \subsubindex-th frame out of \\
                    \subsubcount\ frames in current subsubsection
                };
                \global\let\subsubcount\undefined
            \fi
        }
        \def\headcommand##1{##1}
        \def\beamer@documentpages##1{
            \stopcountingsubsubsection
        }
        \def\sectionentry##1##2##3##4##5{
            \stopcountingsubsubsection
        }
        \def\beamer@subsectionentry##1##2##3##4##5{
            \stopcountingsubsubsection
        }
        \def\beamer@subsubsectionentry##1##2##3##4##5##6{
            \stopcountingsubsubsection
            \ifnum\c@section=##2
                \incurrentsectiontrue
            \else
                \incurrentsectionfalse
            \fi
            \ifnum\c@subsection=##3
                \incurrentsubsectiontrue
            \else
                \incurrentsubsectionfalse
            \fi
            \ifnum\c@subsubsection=##4
                \incurrentsubsubsectiontrue
            \else
                \incurrentsubsubsectionfalse
            \fi
            \ifincurrentsection
                \ifincurrentsubsection
                    \ifincurrentsubsubsection
                        \xdef\subsubcount{0}
                    \fi
                \fi
            \fi
        }
        \def\slideentry##1##2##3##4##5##6{
            \ifnum\c@subsectionslide=##3
                \incurrentframetrue
            \else
                \incurrentframefalse
            \fi
        }
        \def\beamer@sectionpages##1##2{}
        \def\beamer@subsectionpages##1##2{}
        \def\beamer@framepages##1##2{
            \ifincurrentsection
                \ifincurrentsubsection
                    \ifincurrentsubsubsection
                        \pgfmathtruncatemacro\subsubcount{\subsubcount+1}
                        \ifincurrentframe
                            \xdef\subsubindex{\subsubcount}
                        \fi
                    \fi
                \fi
            \fi
        }
        \tikzset{shift={(2,-2)}}
        \input{\jobname.nav}
    }
}
\setbeamertemplate{headline}{
    \counteverything
}

\section{Sec1}
    \subsection{Sec1-Ssec1}
        \subsubsection{Sec1-Ssec1-sssec1}
            \frame{A}
            \frame{B\pause C}
        \subsubsection{Sec1-Ssec1-sssec2}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
    \subsection{Sec1-Ssec2}
        \subsubsection{Sec1-Ssec2-sssec1}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
            \frame{G\pause H\pause I\pause J}
        \subsubsection{Sec1-Ssec2-sssec2}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
            \frame{G\pause H\pause I\pause J}
            \frame{K\pause L\pause M\pause N\pause O}

\section{Sec2}
    \subsection{Sec2-Ssec1}
        \subsubsection{Sec2-Ssec1-sssec1}
            \frame{A}
            \frame{B\pause C}
        \subsubsection{Sec2-Ssec1-sssec2}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
    \subsection{Sec1-Ssec2}
        \subsubsection{Sec2-Ssec2-sssec1}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
            \frame{G\pause H\pause I\pause J}
        \subsubsection{Sec2-Ssec2-sssec2}
            \frame{A}
            \frame{B\pause C}
            \frame{D\pause E\pause F}
            \frame{G\pause H\pause I\pause J}
            \frame{K\pause L\pause M\pause N\pause O}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.