如何在包含 miniframe 的投影仪标题末尾添加页码(总计)

如何在包含 miniframe 的投影仪标题末尾添加页码(总计)

我使用带有包含微型框架导航内容的标题的 beamer:

\documentclass[compress]{beamer}

\useoutertheme[subsection=false]{miniframes}
\setbeamercolor{section in head/foot}{fg=white, bg=black}

\begin{document}
    \section{First}
    \frame{First-first}
    \frame{First-second}
    \section{Second}
    \frame{Second-first}
    \frame{Second-second}
\end{document}

这给出了一个充满小框架的标题:

完整标题的剪切

我想在标题末尾(右边缘)添加页码(总计,即 x/y)。我希望能够控制小框架部分(最后一节)和页码部分之间的间距。

可以在那里添加页码吗?如果可以,如何添加?

答案1

由于我们正在重新定义您上一个问题的标题,您可以page number in head/foot像这样将模板添加到标题中(根据需要更改导航的宽度):

\documentclass[compress]{beamer}

\useoutertheme[subsection=false]{miniframes}
\setbeamercolor{section in head/foot}{fg=white, bg=black}
%\setbeamercolor{page number in head/foot}{fg=white}

\setbeamertemplate{page number in head/foot}[totalframenumber]

\makeatletter
\setbeamertemplate{headline}
{%
  \begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
  \end{beamercolorbox}
  \begin{beamercolorbox}{section in head/foot}
    \vskip2pt
    \begin{minipage}[c]{.8\paperwidth}
      \insertnavigation{\linewidth}
    \end{minipage}%
    \begin{minipage}[c]{.2\paperwidth}
      \hfill\usebeamercolor[fg]{page number in head/foot}\usebeamertemplate{page number in head/foot}\quad\mbox{}
    \end{minipage}%
    \vskip4pt % <- change here
  \end{beamercolorbox}%
  \ifbeamer@theme@subsection%
    \begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
    \end{beamercolorbox}
    \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
      \usebeamerfont{subsection in head/foot}\insertsubsectionhead
    \end{beamercolorbox}%
  \fi%
  \begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
  \end{beamercolorbox}
}
\makeatother

\begin{document}
    \section{First}
    \frame{First-first}
    \frame{First-second}
    \section{Second}
    \frame{Second-first}
    \frame{Second-second}
\end{document}

在此处输入图片描述

相关内容