如何使用 TikZ 在 beamer 中创建进度条?

如何使用 TikZ 在 beamer 中创建进度条?

我想在我的 Beamer 演示文稿中创建自己的进度条。这是我的序言代码:

\documentclass[9pt, hyperref={pdfpagemode=FullScreen}]{beamer}

\usepackage[utf8]{inputenc}

\definecolor{whitesmoke}{rgb}{0.96, 0.96, 0.96}

\title{\textbf{COMPLEJOS INTERMOLECULARES DE BASES DE ADN EN ESTADOS ELECTRÓNICOS EXCITADOS}}

\definecolor{ghostwhite}{rgb}{0.97, 0.97, 1.0}

\definecolor{columbiablue}{rgb}{0.61, 0.87, 1.0}

\usefonttheme{serif}

\usepackage{lewis} 

\usepackage{tikz}

\usetikzlibrary{calc}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PROGRESS BAR 


\newcommand{\progressbar}{

\begin{tikzpicture}

    \fill [gray] (10,0) rectangle (13.0,0.5) ;

    \fill [blue] (0,0) rectangle (10,0.5);  


\end{tikzpicture}


}

\setbeamertemplate{headline}{ \progressbar}

....

\begin{document} 

.....
\end{document} 

所有幻灯片的顶部都有相同的矩形:

在此处输入图片描述

我希望所有幻灯片中的灰色矩形都填充任意颜色,直到演示结束,并包含下方的帧编号。

答案1

我以前为自己做过这个。

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = pdflatex
% !TEX spellcheck = English
% !TEX pdfSinglePage



\documentclass[14pt]{beamer}
    \beamertemplatenavigationsymbolsempty

\usepackage{tikz}

\title[Math of Communication]{A Mathematical Theory of Communication}
\author[C.~E.~Shannon]{Claude E.~Shannon}
\institute{University of Informatics}
\date[2020-10]{2020-10-10}

\begin{document}

\frame\maketitle

\makeatletter\defbeamertemplate*{sidebar right}{pro-bar}{
    \pgfmathsetmacro\safetotalframenumber{max(\insertmainframenumber-1,1)}
    \tikz[remember picture,overlay,x=3mm,y=\paperheight]{\footnotesize
        \pgfmathsetmacro\overlaytotal{\insertframeendpage+1-\insertframestartpage}
        \pgfmathsetmacro\overlayfraction{\insertoverlaynumber/\overlaytotal}
        \path[save path=\stare,yscale=1/\safetotalframenumber]
            (-1,0)-|(0,1-\insertframenumber)-|+(-\overlayfraction,1)-|cycle;
        \tikzset{bar/.pic={\node at(-.55,-.5)[rotate=-90]
            {\beamer@shorttitle~\beamer@shortdate~\beamer@shortauthor};}}
        \fill[use path=\stare,gray]pic[blue]{bar};
        \clip[use path=\stare]pic[green]{bar};
    }
}\makeatother

\frame{{Doe, a deer, a female deer}
    Beamer is a LaTeX document class for creating presentation slides,
    \pause\vfill
    with a wide range of templates and a set of features for making slideshow effects.
}

\frame{{Ray, a drop of golden sun}
    It supports pdfLaTeX, LaTeX + dvips, LuaLaTeX and XeLaTeX.[1]
    \pause\vfill
    The name is taken from the German word "Beamer"
    \pause\vfill
    as a pseudo-anglicism for "video projector".
}

\frame{{Me, a name I call myself}
    The Beamer class is not the first LaTeX class for creating presentations,
    \pause\vfill
    and like many of its predecessors
    \pause\vfill
    (such as slides, seminar, prosper, powerdot),[2]
    \pause\vfill
    it has special syntax for defining "slides"
    \pause\vfill
    (known in Beamer as "frames").
}

\frame{{Far, a long, long way to run}
    Slides can be built up on-screen in stages
    as if by revealing text that was previously hidden or covered.
    \pause\vfill
    This is handled with PDF output by creating successive pages
    that preserve the layout but add new elements,
    \pause\vfill
    so that advancing to the next page in the PDF file
    appears to add something to the displayed page,
    \pause\vfill
    when in fact it has merely redrawn the page.
}

\frame{{Sew, a needle pulling thread}
    The list of features supported by Beamer is quite long.
    \pause\vfill
    The most important features, according to the user guide[1] are:
}

\frame{{La, a note to follow Sew}
    \begin{itemize}[<+->]
        \item   Beamer can be used with pdfLaTeX, LaTeX+dvips, LuaLaTeX and XeLaTeX.
                LaTeX+dvipdfm isn’t supported.
        \item   The standard commands of LaTeX still work.
                A tableofcontents will still create a table of contents,
                section is still used to create structure,
                and itemize still creates a list.
        \item   Overlays and dynamic effects can be easily created.
        \item   The appearance of presentations can be modified using themes.
    \end{itemize}
}

\frame{{Tea, a drink with jam and bread}
    \begin{itemize}[<+->]
        \item   The layout, the colors, and the fonts
                used in a presentation can easily be changed globally,
                while preserving control over the most minute detail.
        \item   A special style file allows for the use the LaTeX source of
                a presentation directly in other LaTeX classes such as article or book.
                This makes it easy to create presentations out of
                lecture notes or lecture notes out of presentations.
        \item   The final output is typically a PDF file, making it highly portable
                and worry-free, in the sense that a given presentation
                will always look the same no matter the machine it is opened on.
    \end{itemize}
}

\end{document}

相关内容