
Я работаю над слайдами 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:
НМВЭ:
\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}