我想重现“迷你框架”外部主题中的部分名称下的各个“项目符号”,这些项目符号位于“侧边栏”外部主题中创建的导航侧边栏中的子部分名称下。
来自另一个问题,Beamer 中一帧中有多个导航点,我发现生成每个迷你框架的代码来自函数 \slideentry。
到目前为止,我所做的就是修改侧边栏外主题中的导航命令 \insertverticalnavigation(beamerbasenavigation.sty,第 548-627 行),使其不再将 \slideentry 重新定义为空白(第 572 行)。例如,这将给出一个 MWE:
\documentclass[compress]{beamer}
\useoutertheme[right,width=50pt,height=25pt]{sidebar}
\usetheme{Copenhagen}
\makeatletter
%Sidebar navigation code
\def\insertverticalnavigation#1{%
\vbox{%
\def\sectionentry##1##2##3##4##5{%
\ifnum##5=\c@part%
\def\insertsectionhead{##2}%
\def\insertsectionheadnumber{##1}%
\def\insertpartheadnumber{##5}%
\hbox{{%
\usebeamerfont{section in sidebar}\usebeamercolor[fg]{section in sidebar}%
\hyperlink{Navigation##3}{%
\ifnum\c@section=##1%
\ifnum\c@subsection=0\relax%
{\usebeamertemplate{section in sidebar}}%
\else%
\ifx\beamer@nav@css\beamer@hidetext%
{\usebeamertemplate{section in sidebar}}%
\else%
{\usebeamertemplate{section in sidebar shaded}}%
\fi%
\fi%
\else
{\usebeamertemplate{section in sidebar shaded}}%
\fi}}}%
\beamer@currentsubsection=0\relax\fi}%
%code commented out:
%\def\slideentry##1##2##3##4##5##6{}%
%
\def\beamer@subsectionentry##1##2##3##4##5{%
\ifnum##1=\c@part%
\def\insertpartheadnumber{##1}%
\def\insertsectionheadnumber{##2}%
\def\insertsubsectionheadnumber{##3}%
\def\insertsubsectionhead{##5}%
\beamer@tocifnothide{\ifnum\c@section=##2\ifnum\c@subsection=##3\beamer@nav@css\else\beamer@nav@oss\fi\else\beamer@nav@ooss\fi}%
{\hbox{{%
\usebeamerfont{subsection in sidebar}\usebeamercolor[fg]{subsection in sidebar}%
\hyperlink{Navigation##4}{%
\ifnum\c@section=##2%
\ifnum\c@subsection=##3%
\ifnum\c@subsubsection=0\relax%
{\usebeamertemplate{subsection in sidebar}}%
\else%
{\usebeamertemplate{subsection in sidebar shaded}}%
\fi%
\else%
{\usebeamertemplate{subsection in sidebar shaded}}%
\fi%
\else%
{\usebeamertemplate{subsection in sidebar shaded}}%
\fi}}}%
}%
\fi}%
\def\beamer@subsubsectionentry##1##2##3##4##5##6{%
\ifnum##1=\c@part%
\def\insertpartheadnumber{##1}%
\def\insertsectionheadnumber{##2}%
\def\insertsubsectionheadnumber{##3}%
\def\insertsubsubsectionheadnumber{##3}%
\def\insertsubsubsectionhead{##6}%
\beamer@tocifnothide{\ifnum\c@section=##2\ifnum\c@subsection=##3\beamer@nav@css\else\beamer@nav@oss\fi\else\beamer@nav@ooss\fi}%
{\hbox{{%
\usebeamerfont{subsubsection in sidebar}\usebeamercolor[fg]{subsubsection in sidebar}%
\hyperlink{Navigation##5}{%
\ifnum\c@section=##2%
\ifnum\c@subsection=##3%
\ifnum\c@subsubsection=##4%
{\usebeamertemplate{subsubsection in sidebar}}%
\else
{\usebeamertemplate{subsubsection in sidebar shaded}}%
\fi%
\else%
{\usebeamertemplate{subsubsection in sidebar shaded}}%
\fi%
\else%
{\usebeamertemplate{subsubsection in sidebar shaded}}%
\fi}}}%
}%
\fi}%
%\beamer@currentsubsection=0\relax%
\dohead%
}%
}
\makeatother
\begin{document}
\section{Foo}
\begin{frame}{Test1}
content...
\end{frame}
\subsection{foo}
\begin{frame}{Test2}
content...
\end{frame}
\begin{frame}{Test3}
content...
\end{frame}
\begin{frame}{Test4}
content...
\end{frame}
\begin{frame}{Test5}
content...
\end{frame}\section{Goo}
\begin{frame}{Test6}
content...
\end{frame}
\begin{frame}{Test7}
content...
\end{frame}
\section{goo}
\begin{frame}{Test8}
content...
\end{frame}
\begin{frame}{Test9}
content...
\end{frame}
\begin{frame}{Test10}
content...
\end{frame}
\begin{frame}{Test11}
content...
\end{frame}
\end{document}
然而,迷你框架的格式与标准迷你框架外部主题不同。请参见下图(我对 MWE 中的格式不佳表示歉意,它太小了)。
从 MWE 的图片中您可以看到,每个新的迷你框架不是在每个小节下方的一行上对齐,而是出现在单独的一行上。有谁知道如何正确生成迷你框架,或者我可以破解哪些代码来尝试获得正确的行为?
干杯。
答案1
对于小型框架,beamer 执行以下操作:
每个框架(圆圈/点)都以零宽度绘制
\hbox
。圆圈/点的位置通过明确指定坐标来控制。(例如\hbox to0cm{\kern1cm O} \hbox to0cm{\kern2cm O} \hbox to0cm{\kern3cm O}
)
这些框(圆圈/点)被放入另一个框中
\hbox
。默认情况下,框中的材料\hbox
将水平对齐。
另一方面,\vbox
的定义中有一个\insertverticalnavigation
,它强制所有\hbox
es 垂直对齐。因此圆圈/点确实位于同一条线上。
为了解决这个问题,你必须补偿行高,在本例中,行高似乎正好是 5pt。因此,%\def\slideentry##1##2##3##4##5##6{}%
你可以使用来代替
\def\slideentry#1#2#3#4#5#6{%
%section number, subsection number, slide number, first/last frame, page number, part number
\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%
\kern-3pt% compensate line break
\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%
}%
\kern-2pt% compensate line break
\fi\fi%
\else%
\fakeslideentry{#1}{#2}{#3}{#4}{#5}{#6}%
\fi\ignorespaces
}
这是 的原始定义,\slideentry
只是\kern
添加了两个 s。
播放代码
\documentclass[compress]{beamer}
\useoutertheme[right,width=50pt,height=25pt]{sidebar}
\usetheme{Copenhagen}
\makeatletter
\def\slideentry#1#2#3#4#5#6{%
%section number, subsection number, slide number, first/last frame, page number, part number
\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%
\kern-3pt% compensate line break
\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%
}%
\kern-2pt% compensate line break
\fi\fi%
\else%
\fakeslideentry{#1}{#2}{#3}{#4}{#5}{#6}%
\fi\ignorespaces
}
%Sidebar navigation code
\def\insertverticalnavigation#1{%
\vbox{%
\def\sectionentry##1##2##3##4##5{%
\ifnum##5=\c@part%
\def\insertsectionhead{##2}%
\def\insertsectionheadnumber{##1}%
\def\insertpartheadnumber{##5}%
\hbox{{%
\usebeamerfont{section in sidebar}\usebeamercolor[fg]{section in sidebar}%
\hyperlink{Navigation##3}{%
\ifnum\c@section=##1%
\ifnum\c@subsection=0\relax%
{\usebeamertemplate{section in sidebar}}%
\else%
\ifx\beamer@nav@css\beamer@hidetext%
{\usebeamertemplate{section in sidebar}}%
\else%
{\usebeamertemplate{section in sidebar shaded}}%
\fi%
\fi%
\else
{\usebeamertemplate{section in sidebar shaded}}%
\fi}}}%
\beamer@currentsubsection=0\relax\fi}%
\def\beamer@subsectionentry##1##2##3##4##5{%
\ifnum##1=\c@part%
\def\insertpartheadnumber{##1}%
\def\insertsectionheadnumber{##2}%
\def\insertsubsectionheadnumber{##3}%
\def\insertsubsectionhead{##5}%
\beamer@tocifnothide{\ifnum\c@section=##2\ifnum\c@subsection=##3\beamer@nav@css\else\beamer@nav@oss\fi\else\beamer@nav@ooss\fi}%
{\hbox{{%
\usebeamerfont{subsection in sidebar}\usebeamercolor[fg]{subsection in sidebar}%
\hyperlink{Navigation##4}{%
\ifnum\c@section=##2%
\ifnum\c@subsection=##3%
\ifnum\c@subsubsection=0\relax%
{\usebeamertemplate{subsection in sidebar}}%
\else%
{\usebeamertemplate{subsection in sidebar shaded}}%
\fi%
\else%
{\usebeamertemplate{subsection in sidebar shaded}}%
\fi%
\else%
{\usebeamertemplate{subsection in sidebar shaded}}%
\fi}}}%
}%
\fi}%
\def\beamer@subsubsectionentry##1##2##3##4##5##6{%
\ifnum##1=\c@part%
\def\insertpartheadnumber{##1}%
\def\insertsectionheadnumber{##2}%
\def\insertsubsectionheadnumber{##3}%
\def\insertsubsubsectionheadnumber{##3}%
\def\insertsubsubsectionhead{##6}%
\beamer@tocifnothide{\ifnum\c@section=##2\ifnum\c@subsection=##3\beamer@nav@css\else\beamer@nav@oss\fi\else\beamer@nav@ooss\fi}%
{\hbox{{%
\usebeamerfont{subsubsection in sidebar}\usebeamercolor[fg]{subsubsection in sidebar}%
\hyperlink{Navigation##5}{%
\ifnum\c@section=##2%
\ifnum\c@subsection=##3%
\ifnum\c@subsubsection=##4%
{\usebeamertemplate{subsubsection in sidebar}}%
\else
{\usebeamertemplate{subsubsection in sidebar shaded}}%
\fi%
\else%
{\usebeamertemplate{subsubsection in sidebar shaded}}%
\fi%
\else%
{\usebeamertemplate{subsubsection in sidebar shaded}}%
\fi}}}%
}%
\fi}%
%\beamer@currentsubsection=0\relax%
\dohead%
}%
}
\begin{document}
\section{Foo}
\begin{frame}{Test1}
content...
\end{frame}
\subsection{foo}
\begin{frame}{Test2}
content...
\end{frame}
\begin{frame}{Test3}
content...
\end{frame}
\begin{frame}{Test4}
content...
\end{frame}
\begin{frame}{Test5}
content...
\end{frame}
\section{Goo}
\begin{frame}{Test6}
content...
\end{frame}
\begin{frame}{Test7}
content...
\end{frame}
\section{goo}
\begin{frame}{Test8}
content...
\end{frame}
\begin{frame}{Test9}
content...
\end{frame}
\begin{frame}{Test10}
content...
\end{frame}
\begin{frame}{Test11}
content...
\end{frame}
\end{document}
答案2
为此,有一个特殊的 Beamer 主题,即sidebarwithminiframes
外部主题。可以在以下位置找到:http://mirrors.ctan.org/macros/latex/contrib/beamer-contrib/themes/beamerauxtheme/themes/beamerouterthemesidebarwithminiframes.sty
\documentclass[compress]{beamer}
\useoutertheme[right,width=50pt,height=25pt]{sidebarwithminiframes}
\usetheme{Copenhagen}
\begin{document}
\section{Foo}
\begin{frame}{Test1}
content...
\end{frame}
\subsection{foo}
\begin{frame}{Test2}
content...
\end{frame}
\begin{frame}{Test3}
content...
\end{frame}
\begin{frame}{Test4}
content...
\end{frame}
\begin{frame}{Test5}
content...
\end{frame}\section{Goo}
\begin{frame}{Test6}
content...
\end{frame}
\begin{frame}{Test7}
content...
\end{frame}
\section{goo}
\begin{frame}{Test8}
content...
\end{frame}
\begin{frame}{Test9}
content...
\end{frame}
\begin{frame}{Test10}
content...
\end{frame}
\begin{frame}{Test11}
content...
\end{frame}
\end{document}