编辑部分 Beamer 标题(使用现有主题内容)

编辑部分 Beamer 标题(使用现有主题内容)

分数维:

考虑以下最小工作示例:

\documentclass{beamer}
\usetheme{CambridgeUS}

\begin{document}

\section{Section1}
\subsection{Subsection1}
\begin{frame}
\end{frame}

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

\end{document}

呈现如下: 在此处输入图片描述


问题 :

我想删除放置在标题右侧的自动内容(内容subsection),并在那里放置一些计算当前剩余的幻灯片数量section。通过我是说 :

  • 的数量告诉我们该部分有多少张幻灯片(不考虑停顿!);
  • 如果它们是白色的,我们读幻灯片
  • 如果为空:
    1. 空白一片,我们正在读它;
    2. 如果它们是空的灰色,则表示我们尚未读取它们。

看起来它已经存在了:

我在其他一些主题上也看到过这种点,比如法兰克福

在此处输入图片描述 (来源 :http://www.hartwork.org/beamer-theme-matrix/

我猜想它可以被利用,但是我对乳胶的了解不够深入,无法做到这一点。


预期显示示例:

在此示例中,我们有 6 页针对此 Section1,并且我们当前位于此部分的第二页。

在此处输入图片描述

(当然背景不一定是黑色的,只是手工编辑得不好)


概括 :

我怎样才能把这些点而不是小节放在这个美国剑桥大学主题?是否可以整合法兰克福关于这些点的代码美国剑桥大学主题 ?

在此先感谢您的帮助。


答案1

这是另一种方法,尝试将法兰克福主题中的实际迷你框架导航嵌入剑桥主题。这需要大刀阔斧,我建议用它制作自定义主题。

首先,我们需要设置迷你框架的颜色,我darkredbeaver主题中选择了颜色以匹配主题的其余部分。

\setbeamercolor{迷你框架}{fg=darkred}

现在到了棘手的部分:我们将从 中取出代码\insertsubsectionnavigationhorizontal,删除其自身的\slideentry宏并添加从文件中取出的宏beamerbasenavigation.sty。由于我的etoolboxfu 不够好,我只会发布整个修改后的\slideentry。为了代码可读性等,这应该放在另一个文件中或用 完成etoolbox

\def\insertsubsectionnavigationhorizontal#1#2#3{%
    \hbox to #1{{%
        \usebeamerfont{subsection in head/foot}\usebeamercolor[fg]{subsection in head/foot}
        \beamer@currentsubsection=0%
        \def\sectionentry##1##2##3##4##5{}%
        \def\slideentry##1##2##3##4##5##6{\ifnum##6=\c@part\ifnum##1=\c@section%
      \ifnum##2>\beamer@currentsubsection%
      \box\beamer@sectionbox\hskip1.875ex plus1fill%
            \hbox to 0pt{%
                    \global\beamer@section@min@dim\beamer@tempdim
                        \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\fi\ignorespaces
        }%
        #2\hskip.3cm\setbox\beamer@sectionbox=\hbox{}%
        \hskip-1.875ex plus-1fill\dohead%
        \box\beamer@sectionbox\hfil\hskip.3cm%
        #3
    }}
}

最后一步是重新设置标题模板,以便它调用我们定制的水平小框架导航:

    \setbeamertemplate{headline}
    {
        \leavevmode%
        \hbox{%
        \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,right]{section in head/foot}%
            \usebeamerfont{section in head/foot}\bfseries\insertsectionhead\hspace*{2ex}
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,left]{subsection in head/foot}%
            \usebeamerfont{subsection in head/foot}\setbeamercolor{section in head/foot}{fg=black,bg=white}
            \vspace*{.01cm}\insertsubsectionnavigationhorizontal{0cm}{\hskip-.1cm}{}
        \end{beamercolorbox}}%
        \vskip0pt%
    }

结果。

它的工作原理与法兰克福迷你框架导航完全相同,因为它实际上法兰克福小型框架导航。

完整的 MWE。

\documentclass{beamer}
\usetheme{CambridgeUS}

\setbeamercolor{mini frame}{fg=darkred}

\makeatletter
\def\insertsubsectionnavigationhorizontal#1#2#3{%
    \hbox to #1{{%
        \usebeamerfont{subsection in head/foot}\usebeamercolor[fg]{subsection in head/foot}
        \beamer@currentsubsection=0%
        \def\sectionentry##1##2##3##4##5{}%
        \def\slideentry##1##2##3##4##5##6{\ifnum##6=\c@part\ifnum##1=\c@section%
      \ifnum##2>\beamer@currentsubsection%
      \box\beamer@sectionbox\hskip1.875ex plus1fill%
            \hbox to 0pt{%
                    \global\beamer@section@min@dim\beamer@tempdim
                        \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\fi\ignorespaces
        }%
        #2\hskip.3cm\setbox\beamer@sectionbox=\hbox{}%
        \hskip-1.875ex plus-1fill\dohead%
        \box\beamer@sectionbox\hfil\hskip.3cm%
        #3
    }}
}
\makeatother

\setbeamertemplate{headline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,right]{section in head/foot}%
    \usebeamerfont{section in head/foot}\bfseries\insertsectionhead\hspace*{2ex}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,left]{subsection in head/foot}%
    \usebeamerfont{subsection in head/foot}\setbeamercolor{section in head/foot}{fg=black,bg=white}
    \vspace*{.01cm}\insertsubsectionnavigationhorizontal{1cm}{\hskip-.1cm}{}
  \end{beamercolorbox}}%
  \vskip0pt%
}


\begin{document}
\section{Section 1}
\subsection{Subsection1}
\frame{S1s1f1}
\frame{S1s1f2}

\subsection{Subsection2}
\frame{S1s2}

\subsection{Subsection3}
\frame{S1s3}

\section{Section 2}
\subsection{Subsection1}
\frame{S2s1}

\subsection{Subsection2}
\frame{S2s2}

\subsection{Subsection3}
\frame{S2s3}

\subsection{Subsection4}
\frame{S2s4}
\end{document}

在此处输入图片描述

答案2

在此处输入图片描述

基于显示带有分割外部主题的迷你框架

\documentclass[compress]{beamer}
\usetheme{CambridgeUS}
\useoutertheme{miniframes}
\useoutertheme{split}
%\usecolortheme{whale}


\makeatletter

\newcount\beamer@xoff
\newcount\beamer@prev@section
\newcount\beamer@prev@miniframes
\beamer@xoff=0
\beamer@prev@section=0
\beamer@prev@miniframes=0

\def\insertsubsectionnavigationhorizontalminiframes#1#2#3{%
    \hbox to #1{{%
            \usebeamerfont{subsection in head/foot}\usebeamercolor[fg]{subsection in head/foot}%
            \beamer@currentsubsection=0%
            \def\sectionentry##1##2##3##4##5{}%
            \def\slideentry##1##2##3##4##5##6{%
                \ifnum##1>\beamer@prev@section%
                \beamer@xoff=##3\relax%
                \beamer@prev@miniframes=0\relax%
                \fi
                \ifnum##6=\c@part\ifnum##1=\c@section%
                \ifnum##2>\beamer@currentsubsection%
                \beamer@xoff=0\relax%
                \beamer@currentsubsection=##2%
                \box\beamer@sectionbox\hskip1.875ex plus1fill%
                \ifnum\beamer@prev@miniframes>0\relax%
                \beamer@tempdim=\beamer@boxsize%
                \multiply\beamer@tempdim by \beamer@prev@miniframes%
                \advance\beamer@tempdim by -\beamer@boxsize%
                \advance\beamer@tempdim by 2pt%
                \ifnum##2>1%
                \advance\beamer@tempdim by 1.875ex%
                \else
                \advance\beamer@tempdim by -\beamer@boxsize%
                \fi
                \else
                \beamer@tempdim=0pt%
                \fi
                \setbox\beamer@sectionbox=
                \hbox{\def\insertsubsectionhead{\kern\beamer@tempdim##5}%
                    \def\insertsectionheadnumber{##1}%
                    \def\insertsubsectionheadnumber{##2}%
                    \def\insertpartheadnumber{##6}%
                    \ifnum\c@subsection=##2%
                    \beamer@link(##4){{\usebeamertemplate{subsection in head/foot}}}\else%
                    \beamer@link(##4){{\usebeamertemplate{subsection in head/foot shaded}}}\fi}%
                \ht\beamer@sectionbox=1.875ex%
                \dp\beamer@sectionbox=0.75ex%
                \else%
                \beamer@prev@miniframes=##3%
                \fi%
                \setbox0=\hbox{\insertsectionhead\unskip}\ifdim\wd0>0pt\ifnum##3>0%
                \beamer@xpos=##3\relax%
                \advance\beamer@xpos by -\beamer@xoff%
                \hbox to 0pt{%
                    \beamer@tempdim=0.5pt%
                    \raise\beamer@tempdim\hbox{%
                        \ifnum##2>0%
                        \beamer@tempdim=\beamer@boxsize%
                        \multiply\beamer@tempdim by\beamer@xpos%
                        \advance\beamer@tempdim by -\beamer@boxsize%
                        \advance\beamer@tempdim by 2pt%
                        \advance\beamer@tempdim by \wd\beamer@sectionbox%
                        \else%
                        \beamer@tempdim=\beamer@boxsize%
                        \multiply\beamer@tempdim by\beamer@xpos%
                        \advance\beamer@tempdim by 1.875ex%
                        \fi%
                        \kern\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}%
                                \else%
                                \usebeamertemplate{mini frame in current subsection}%
                                \fi%
                                \else%
                                \usebeamercolor{mini frame}%
                                \usebeamertemplate{mini frame in other subsection}%
                                \fi%
                                \else%
                                \usebeamercolor{mini frame}%
                                \usebeamertemplate{mini frame in other subsection}%
                                \fi%
                            }}}\hskip-10cm plus 1fil%
                        }\fi\fi%
                        \else%
                        \fakeslideentry{##1}{##2}{##3}{##4}{##5}{##6}%
                        \fi\fi%
                        \beamer@prev@section=##1%
                        \ignorespaces}%
                    #2\hskip.3cm\setbox\beamer@sectionbox=\hbox{}%
                    \hskip-1.875ex plus-1fill\dohead%
                    \box\beamer@sectionbox\hfil\hskip.3cm%
                    #3}}}

        \setbeamercolor{mini frame}{parent=subsection in head/foot}
        \setbeamercolor{section in head/foot}{fg=white}

        \ifbeamer@compress

        \defbeamertemplate*{headline}{split theme miniframes}
        {%
            \leavevmode%
            \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex]{palette tertiary}%
                \usebeamercolor{palette tertiary} \insertsectionnavigationhorizontal{.5\paperwidth}{\hskip0pt plus1filll}{}%
            \end{beamercolorbox}%
            \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex]{subsection in head/foot}%
                \insertsubsectionnavigationhorizontalminiframes{.5\paperwidth}{}{\hskip0pt plus1filll}%
            \end{beamercolorbox}%
        }

        \else

        \defbeamertemplatealias{headline}{split theme miniframes}{split theme}
        \setbeamertemplate{headline}[split theme miniframes]

        \fi

        \makeatother

        % This is to enable the feature
        \setbeamertemplate{headline}[split theme miniframes]
        \setbeamertemplate{footline}[infolines theme]


\begin{document}

\section{Section1}

\begin{frame}
\end{frame}

\begin{frame}
\end{frame}

\end{document}

相关内容