我喜欢 Beamer 中的达姆施塔特主题,但我的演示文稿的标题部分太多。我试图找到一个优雅的解决方案,但目前还没有成功。
你知道是否可以只显示标题的一部分吗?我的想法是让标题显示当前部分周围(即之前和/或之后)的尽可能多的部分。
感谢您的帮助。
干杯
以下是 MWE:
\documentclass{beamer}
\usetheme{Darmstadt}
\begin{document}
\section{Section 1}
\subsection{Subsection 1.1}
\begin{frame}{Frame 1.11}
...
\end{frame}
\begin{frame}{Frame 1.12}
...
\end{frame}
\begin{frame}{Frame 1.13}
...
\end{frame}
\subsection{Subsection 1.2}
\begin{frame}{Frame 1.21}
...
\end{frame}
\begin{frame}{Frame 1.22}
...
\end{frame}
\begin{frame}{Frame 1.23}
...
\end{frame}
\section{Section 2}
\begin{frame}{Frame 2}
...
\end{frame}
\section{Section 3}
\begin{frame}{Frame 3}
...
\end{frame}
\section{Section 4}
\begin{frame}{Frame 4}
...
\end{frame}
\section{Section 5}
\begin{frame}{Frame 5}
...
\end{frame}
\section{Section 6}
\begin{frame}{Frame 6}
...
\end{frame}
\section{Section 7}
\begin{frame}{Frame 7}
...
\end{frame}
\section{Section 8}
\begin{frame}{Frame 8}
...
\end{frame}
\section{Section 9}
\subsection{Subsection 9.1}
\begin{frame}{Frame 9.11}
...
\end{frame}
\begin{frame}{Frame 9.12}
...
\end{frame}
\begin{frame}{Frame 9.13}
...
\end{frame}
\subsection{Subsection 9.2}
\begin{frame}{Frame 9.21}
...
\end{frame}
\begin{frame}{Frame 9.22}
...
\end{frame}
\begin{frame}{Frame 9.23}
...
\end{frame}
\section{Section 10}
\begin{frame}{Frame 10}
...
\end{frame}
\section{Section 11}
\begin{frame}{Frame 11}
...
\end{frame}
\section{Section 12}
\begin{frame}{Frame 12}
...
\end{frame}
\section{Section 13}
\begin{frame}{Frame 13}
...
\end{frame}
\section{Section 14}
\begin{frame}{Frame 14}
...
\end{frame}
\section{Section 15}
\begin{frame}{Frame 15}
...
\end{frame}
\section{Section 16}
\subsection{Subsection 16.1}
\begin{frame}{Frame 16.11}
...
\end{frame}
\begin{frame}{Frame 16.12}
...
\end{frame}
\begin{frame}{Frame 16.13}
...
\end{frame}
\subsection{Subsection 16.2}
\begin{frame}{Frame 16.21}
...
\end{frame}
\begin{frame}{Frame 16.22}
...
\end{frame}
\begin{frame}{Frame 16.23}
...
\end{frame}
\section{Section 17}
\begin{frame}{Frame 17}
...
\end{frame}
\section{Section 18}
\begin{frame}{Frame 18}
...
\end{frame}
\section{Section 19}
\subsection{Subsection 19.1}
\begin{frame}{Frame 19.11}
...
\end{frame}
\begin{frame}{Frame 19.12}
...
\end{frame}
\begin{frame}{Frame 19.13}
...
\end{frame}
\subsection{Subsection 19.2}
\begin{frame}{Frame 19.21}
...
\end{frame}
\begin{frame}{Frame 19.22}
...
\end{frame}
\begin{frame}{Frame 19.23}
...
\end{frame}
\section{Section 20}
\begin{frame}{Frame 20}
...
\end{frame}
\end{document}
答案1
以下将显示当前节 +-2 节。如果要显示更多或更少的节,请更改\mymin=3
和的值\mymax=3
[并为第一节、第二节、倒数第二节和最后一节添加相应的例外]。
\documentclass{beamer}
\usetheme{Darmstadt}
% based on the original definitions in beamerbasenavigation.sty
\makeatletter
\def\sectionentry#1#2#3#4#5{% section number, section title, page
%
\newcount\mymin%
\mymin=3
\ifnum\c@section=1%
\mymin=5
\fi%
\ifnum\c@section=2%
\mymin=4
\fi%
%
\newcount\mymax%
\mymax=3
\ifnum\c@section=\beamer@sectionmax%
\mymax=5
\fi%
\ifnum\c@section=\numexpr\beamer@sectionmax-1%
\mymax=4
\fi%
%
\ifnum\numexpr\c@section-#1<\mymax%
\ifnum\numexpr#1-\c@section<\mymin%
\ifnum#5=\c@part%
\beamer@section@set@min@width
\box\beamer@sectionbox\hskip1.875ex plus 1fill%
\beamer@xpos=0\relax%
\beamer@ypos=1\relax%
\setbox\beamer@sectionbox=
\hbox{
\def\insertsectionhead{#2}%
\def\insertsectionheadnumber{#1}%
\def\insertpartheadnumber{#5}%
{%
\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
\ifnum\c@section=#1%
\hyperlink{Navigation#3}{{\usebeamertemplate{section in head/foot}}}%
\else%
\hyperlink{Navigation#3}{{\usebeamertemplate{section in head/foot shaded}}}%
\fi%
}%
}%
\ht\beamer@sectionbox=1.875ex%
\dp\beamer@sectionbox=0.75ex%
\fi%
\fi%
\fi%
\ignorespaces%
}
\def\slideentry#1#2#3#4#5#6{%
%section number, subsection number, slide number, first/last frame, page number, part number
%
\newcount\mymin%
\mymin=3
\ifnum\c@section=1%
\mymin=5
\fi%
\ifnum\c@section=2%
\mymin=4
\fi%
%
\newcount\mymax%
\mymax=3
\ifnum\c@section=\beamer@sectionmax%
\mymax=5
\fi%
\ifnum\c@section=\numexpr\beamer@sectionmax-1%
\mymax=4
\fi%
%
\ifnum\numexpr\c@section-#1<\mymax%
\ifnum\numexpr#1-\c@section<\mymin%
\ifnum#6=\c@part\ifnum#2>0\ifnum#3>0%
\ifbeamer@compress%
\advance\beamer@xpos by1\relax%
\else%
\beamer@xpos=#3\relax%
\beamer@ypos=#2\relax%
\fi%
\hbox to 0pt{%
\beamer@tempdim=-\beamer@vboxoffset%
\advance\beamer@tempdim by-\beamer@boxsize%
\multiply\beamer@tempdim by\beamer@ypos%
\advance\beamer@tempdim by -.05cm%
\raise\beamer@tempdim\hbox{%
\beamer@tempdim=\beamer@boxsize%
\multiply\beamer@tempdim by\beamer@xpos%
\advance\beamer@tempdim by -\beamer@boxsize%
\advance\beamer@tempdim by 1pt%
\kern\beamer@tempdim
\global\beamer@section@min@dim\beamer@tempdim
\hbox{\beamer@link(#4){%
\usebeamerfont{mini frame}%
\ifnum\c@section=#1%
\ifnum\c@subsection=#2%
\usebeamercolor[fg]{mini frame}%
\ifnum\c@subsectionslide=#3%
\usebeamertemplate{mini frame}%\beamer@minislidehilight%
\else%
\usebeamertemplate{mini frame in current subsection}%\beamer@minisliderowhilight%
\fi%
\else%
\usebeamercolor{mini frame}%
%\color{fg!50!bg}%
\usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
\fi%
\else%
\usebeamercolor{mini frame}%
%\color{fg!50!bg}%
\usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
\fi%
}}}\hskip-10cm plus 1fil%
}\fi\fi%
\else%
\fakeslideentry{#1}{#2}{#3}{#4}{#5}{#6}%
\fi%
\fi%
\fi%
\ignorespaces%
}
\makeatother
\begin{document}
\section{Section 1}
\subsection{Subsection 1.1}
\begin{frame}{Frame 1.11}
...
\end{frame}
\begin{frame}{Frame 1.12}
...
\end{frame}
\begin{frame}{Frame 1.13}
...
\end{frame}
\subsection{Subsection 1.2}
\begin{frame}{Frame 1.21}
...
\end{frame}
\begin{frame}{Frame 1.22}
...
\end{frame}
\begin{frame}{Frame 1.23}
...
\end{frame}
\section{Section 2}
\begin{frame}{Frame 2}
...
\end{frame}
\section{Section 3}
\begin{frame}{Frame 3}
...
\end{frame}
\section{Section 4}
\begin{frame}{Frame 4}
...
\end{frame}
\section{Section 5}
\begin{frame}{Frame 5}
...
\end{frame}
\section{Section 6}
\begin{frame}{Frame 6}
...
\end{frame}
\section{Section 7}
\begin{frame}{Frame 7}
...
\end{frame}
\section{Section 8}
\begin{frame}{Frame 8}
...
\end{frame}
\section{Section 9}
\subsection{Subsection 9.1}
\begin{frame}{Frame 9.11}
...
\end{frame}
\begin{frame}{Frame 9.12}
...
\end{frame}
\begin{frame}{Frame 9.13}
...
\end{frame}
\subsection{Subsection 9.2}
\begin{frame}{Frame 9.21}
...
\end{frame}
\begin{frame}{Frame 9.22}
...
\end{frame}
\begin{frame}{Frame 9.23}
...
\end{frame}
\section{Section 10}
\begin{frame}{Frame 10}
...
\end{frame}
\section{Section 11}
\begin{frame}{Frame 11}
...
\end{frame}
\section{Section 12}
\begin{frame}{Frame 12}
...
\end{frame}
\section{Section 13}
\begin{frame}{Frame 13}
...
\end{frame}
\section{Section 14}
\begin{frame}{Frame 14}
...
\end{frame}
\section{Section 15}
\begin{frame}{Frame 15}
...
\end{frame}
\section{Section 16}
\subsection{Subsection 16.1}
\begin{frame}{Frame 16.11}
...
\end{frame}
\begin{frame}{Frame 16.12}
...
\end{frame}
\begin{frame}{Frame 16.13}
...
\end{frame}
\subsection{Subsection 16.2}
\begin{frame}{Frame 16.21}
...
\end{frame}
\begin{frame}{Frame 16.22}
...
\end{frame}
\begin{frame}{Frame 16.23}
...
\end{frame}
\section{Section 17}
\begin{frame}{Frame 17}
...
\end{frame}
\section{Section 18}
\begin{frame}{Frame 18}
...
\end{frame}
\section{Section 19}
\subsection{Subsection 19.1}
\begin{frame}{Frame 19.11}
...
\end{frame}
\begin{frame}{Frame 19.12}
...
\end{frame}
\begin{frame}{Frame 19.13}
...
\end{frame}
\subsection{Subsection 19.2}
\begin{frame}{Frame 19.21}
...
\end{frame}
\begin{frame}{Frame 19.22}
...
\end{frame}
\begin{frame}{Frame 19.23}
...
\end{frame}
\section{Section 20}
\begin{frame}{Frame 20}
...
\end{frame}
\end{document}