进度条相对主题元素的定位

进度条相对主题元素的定位

我试图在华沙主题的框架标题和框架标题 + 框架子标题栏下方放置一个最小进度条:

\documentclass[compress]{beamer}

\mode<presentation>
{
 \usetheme{Warsaw}
}

\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}

% Progressbar
\usepackage{tikz}
\usetikzlibrary{calc}

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\paperwidth
\progressbar@pbht=1pt

\def\progressbar@progressbar{%

\progressbar@tmpcounta=\insertframenumber
\progressbar@tmpcountb=\inserttotalframenumber
\progressbar@tmpdim=\progressbar@pbwd
\multiply\progressbar@tmpdim by \progressbar@tmpcounta
\divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}[very thin]

  \shade[draw=red,top color=red!10,bottom color=red!10,middle color=red] %
    (0pt, 0pt) rectangle ++ (\progressbar@tmpdim, \progressbar@pbht);

  \end{tikzpicture}%
 }

\addtobeamertemplate{frametitle}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=1pt,dp=1pt]{}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}%
\makeatother

\begin{document}
\section{Section}
\subsection{Subsection}
\begin{frame}{Frametitle}{Framesubtitle}
\end{frame}

\begin{frame}{Frametitle}
\end{frame}
\end{document}

但是,这会使所有框架的进度条位于框架标题下方约 20pt 的位置(见下文)。如何解决这个问题?

输出

答案1

\vspace*{-20pt}简单地添加一个进度条怎么样?

\addtobeamertemplate{frametitle}{}
{%
  \vspace*{-20pt}
  \begin{beamercolorbox}[wd=\paperwidth,ht=1pt,dp=1pt]{}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}%

在此处输入图片描述

相关内容