编辑

编辑

我想知道是否有一种简单的方法可以获取 Beamer 中的总帧数subsubsection

我已经设法获得了每个帧的数量subsubsection,如在 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}

答案1

这是一个概念证明

\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}

编辑

这就是 OP 想要的。这个想法是使用诸如此类的钩子\slideentry来帮助你积累。

\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}

相关内容