投影仪标题中的自定义导航点

投影仪标题中的自定义导航点

我正在制作幻灯片beamer,我想在页眉中添加一些点,以指示当前部分(左侧)和子部分(右侧)。不应包含部分/子部分的名称。

以下是 MWE:

\documentclass{beamer}

\makeatletter
\setbeamertemplate{headline}
{%
    \leavevmode%
    \hbox{%
        \begin{beamercolorbox}[wd=0.5\paperwidth,ht=2.25ex,dp=1ex,left]{section in head/foot}
            section dots
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=0.5\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}
            subsection dots (of current section)
        \end{beamercolorbox}}%
}
\makeatother

\begin{document}    
    \section{Section1}
    \begin{frame}
        \frametitle{Frame11}
    \end{frame}

    \subsection{Subsection1}
    \begin{frame}
        \frametitle{Frame12}
    \end{frame}

    \subsection{Subsection2}
    \begin{frame}
        \frametitle{Frame13}
    \end{frame}


    \section{Section2}
    \begin{frame}
        \frametitle{Frame21}
    \end{frame}

    \subsection{Subsection1}
    \begin{frame}
        \frametitle{Frame22}
    \end{frame}

    \subsection{Subsection2}
    \begin{frame}
        \frametitle{Motivation}
    \end{frame}

    \subsection{Subsection3}
    \begin{frame}
        \frametitle{Frame23}
    \end{frame}
\end{document}

对于这个特定的帧数,我希望在左上角有两个点表示部分,在右上角有两个或三个点分别表示第 1 部分和第 2 部分的子部分。显然,我想要一个不特定于此示例的通用解决方案。

在我的当前设置下这是否可以轻松完成,还是需要一些完全不同的东西?

答案1

可能有更好的方法可以做到这一点,但我不想弄乱投影仪导航,而是想尝试一些新的东西并使用该xcntperchap软件包。

\documentclass{beamer}
\usepackage{tikz}

\usepackage{totcount}
\regtotcounter{section}

\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}

\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}
\usepackage{etoolbox}

\preto\frame{\ifnum\thesection>0\setcounter{totalsubsection}{\ObtainTrackedValueExp[\thesection]{section}{subsection}}\fi}

\setbeamertemplate{headline}{%
\hbox{%
\begin{beamercolorbox}[wd=.48\paperwidth,ht=2.25ex,dp=1ex]{section in head/foot}%
\hfill%
\ifnum\totvalue{section}>0%
\ifnum\thesection>0%
\foreach\x in {1,...,\totvalue{section}}{%
\ifnum\x=\thesection%
\usebeamertemplate{mini frame}~%
\else%
\usebeamertemplate{mini frame in other section}~%
\fi%
}%
\fi%
\fi%
\end{beamercolorbox}%
\qquad%
\begin{beamercolorbox}[wd=.48\paperwidth,ht=2.25ex,dp=1ex]{subsection in head/foot}%
\ifnum\thetotalsubsection>0%
\foreach\x in {1,...,\thetotalsubsection}{%
\ifnum\x=\thesubsection%
\usebeamertemplate{mini frame}~%
\else%
\usebeamertemplate{mini frame in other subsection}~%
\fi%
}%
\fi%
\end{beamercolorbox}%
}}

\title{title}
\author{author}

\begin{document}

    \begin{frame}
        \titlepage
    \end{frame}


\section{Section1}

\frame{}

\subsection{Subsection1}
\begin{frame}
\frametitle{Frame11}
\end{frame}

\subsection{Subsection2}
\begin{frame}
\frametitle{Frame12}
\end{frame}

\section{Section2}
\begin{frame}
\frametitle{Frame2}
\end{frame}

\subsection{Subsection1}
\begin{frame}
\frametitle{Frame21}
\end{frame}

\subsection{Subsection2}
\begin{frame}
\frametitle{Frame22}
\end{frame}

\subsection{Subsection3}
\begin{frame}
\frametitle{Frame23}
\end{frame}

\section{Section3}
\begin{frame}
\frametitle{Frame3}
\end{frame}

\end{document}

在此处输入图片描述

答案2

我只是想回答一下,以展示已接受解决方案的灵活性。所有功劳都归功于 samcarter。通过更改 if/else 中的小内容并将内容从页眉移到页脚,我获得了以下 nMWE 结果:

前四张幻灯片

幻灯片 5-8

nMWE:

\documentclass{beamer}

\beamertemplatenavigationsymbolsempty
\usetheme{rochester}
\usecolortheme{beaver}

\usepackage{tikz}

\usepackage{totcount}
\regtotcounter{section}

\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}

\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}
\usepackage{etoolbox}

\preto\frame{\ifnum\thesection>0\setcounter{totalsubsection}{\ObtainTrackedValueExp[\thesection]{section}{subsection}}\fi}

\setbeamertemplate{footline}{%
    \hbox{%
        \begin{beamercolorbox}[wd=0.2\paperwidth,ht=2.25ex,dp=1ex,left,leftskip=1ex]{subsection in head/foot}%
            \ifnum\totvalue{section}>0%
            \foreach\x in {1,...,\totvalue{section}}{%
                \ifnum\numexpr\x-1<\thesection%
                \usebeamertemplate{mini frame}~%
                \else%
                \usebeamertemplate{mini frame in other section}~%
                \fi%
            }%
            \fi%
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=0.6\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}
            \usebeamerfont{title in head/foot} \inserttitle
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=0.2\paperwidth,ht=2.25ex,dp=1ex,right,rightskip=1ex]{subsection in head/foot}%
            \ifnum\thetotalsubsection>0%
            \foreach\x in {1,...,\thetotalsubsection}{%
                \ifnum\x>\numexpr\thetotalsubsection-\thesubsection%
                \usebeamertemplate{mini frame}~%
                \else%
                \usebeamertemplate{mini frame in other subsection}~%
                \fi%
            }%
            \fi%
        \end{beamercolorbox}%
    }}


\title{Super fancy long title which will fit in the footer}
\author{The Champion}
\date{\today}


\begin{document}

    \begin{frame}
        \thispagestyle{empty}
        \maketitle
    \end{frame}


    \begin{frame}
        \thispagestyle{empty}
        \frametitle{Outline}
        \tableofcontents
    \end{frame}


    \section{The first section}
    \subsection{The first subsection}
    \begin{frame}
        \frametitle{The first section}
        \framesubtitle{The first subsection}
    \end{frame}

    \subsection{The second subsection}
    \begin{frame}
        \frametitle{The first section}
        \framesubtitle{The second subsection}
    \end{frame}

    \subsection{The third subsection}
    \begin{frame}
        \frametitle{The first section}
        \framesubtitle{The third subsection}
    \end{frame}


    \section{The second section}
    \subsection{The first subsection}
    \begin{frame}
        \frametitle{The second section}
        \framesubtitle{The first subsection}
    \end{frame}

    \subsection{The second subsection}
    \begin{frame}
        \frametitle{The second section}
        \framesubtitle{The second subsection}
    \end{frame}


    \section{The third section}
    \subsection{The first subsection}
    \begin{frame}
        \frametitle{The third section}
        \framesubtitle{The first subsection}
    \end{frame}

\end{document}

相关内容