在 Beamer 中修改部分

在 Beamer 中修改部分

通过编译以下 TeX 文件:

\documentclass[english]{beamer}

\mode<article> % only for the article version
{
  \usepackage{fullpage}
  \usepackage{hyperref}
}


\mode<presentation>
{
  %\setbeamertemplate{background canvas}[vertical shading][bottom=red!10,top=blue!10]
  \setbeamercovered{transparent}
  \usetheme{progressbar}
  \usefonttheme{serif}
  \usecolortheme{crane}
}

\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
\usepackage[latin1]{inputenc}
\usepackage{colortbl}

\setbeamercovered{dynamic}

\setbeamertemplate{items}[circle]


\begin{document}

\begin{frame}

\section{Section 1}

This is my first slide...
\end{frame}

\begin{frame}
\section{Section 2}

This is my second slide...
\end{frame}

\end{document}

我让标题“第 1 节”左对齐,让“第 2 节”右对齐。我想让第二张幻灯片中的“第 2 节”左对齐(替换“第 1 节”)。任何帮助都非常欢迎。汇编中需要以下五种样式的幻灯片;我无法上传这些文件,因此我将在下面发布相应的代码。

  1. beamercolorthemeprogressbar.sty
\ProvidesPackage{beamercolorthemeprogressbar}[2007/06/21]

\makeatletter

\usecolortheme{rose}

\definecolor{progressbar@bgblue}{rgb}{0.75,0.75,0.95} % use structure theme to change
\definecolor{progressbar@fgblue}{rgb}{0.1,0.1,0.9} % use structure theme to change

\setbeamercolor*{palette primary}{fg=progressbar@fgblue,bg=progressbar@bgblue}
\setbeamercolor*{palette secundary}{fg=progressbar@fgblue,bg=progressbar@bgblue}
\setbeamercolor*{palette tertiary}{fg=progressbar@fgblue,bg=progressbar@bgblue}

\setbeamercolor{section in head/foot}{parent=palette primary}

\makeatother

  1. beamerfontthemeprogressbar.sty
\ProvidesPackage{beamerfontthemeprogressbar}[2007/06/21]

\mode<presentation>

\usefonttheme{default}

\setbeamerfont{title}{size=\Large,series=\bfseries,parent=structure}

\setbeamertemplate{bibliography item}[mybibitem]
\setbeamerfont{bibliography entry author}{shape=\upshape,series=\bfseries,size=\normalsize}%
\setbeamerfont{bibliography entry title}{shape=\upshape,size=\small,series=\mdseries}
\setbeamerfont{bibliography entry journal}{shape=\upshape,size=\small,series=\mdseries}
\setbeamerfont{bibliography entry note}{shape=\upshape,size=\small,series=\mdseries}

\setbeamerfont{itemize/enumerate body}{size=\small}
\setbeamerfont{itemize/enumerate subbody}{size=\footnotesize}
\setbeamerfont{itemize/enumerate subsubbody}{size=\scriptsize}

\setbeamerfont{block title}{size=\normalsize,series=\bfseries,parent={structure,block body}}

\setbeamerfont{section in head/foot}{size=\tiny,series=\bfseries}
\renewcommand{\emph}[1]{\color{structure.fg}\textbf{#1}\color{fg}\xspace}

\setbeamerfont{section in toc}{parent=structure,series=\bfseries}

\mode
<all>

  1. beamerinnerthemeprogressbar.sty
\ProvidesPackage{beamerinnerthemeprogressbar}[2007/06/21]

\RequirePackage{tikz}

\useinnertheme{rounded}

\defbeamertemplate*{bibliography item}{progressbar theme}{
  \begin{tikzpicture}
    \useasboundingbox (0, 0.2) rectangle (0.5, 0.7);
    \fill[fill=bg!85!blue] (0, 0.25) rectangle (0.4, 0.5);
    \shade[bottom color=bg,top color=bg!85!blue] (0, 0) -- (0.3, 0) -- (0.4, 0.12) -- (0.4, 0.3) -- (0, 0.3) -- cycle;
    \shade[left color=bg,right color=bg!85!blue] (0,0.27) .. controls (0.25,0.25) .. (0.4,0.5) -- (0,0.5) -- cycle;
    \fill[fill=bg!90!blue] (0,0) rectangle (0.3,0.05);
    \shade[left color=bg!95!blue,right color=bg!90!blue] (0,0) rectangle (0.05,0.5);
    \shade[left color=bg,right color=bg!80!black,shading angle=45] (0.3,0) -- (0.3,0.12) -- (0.4,0.12) -- cycle;
    \draw[draw=fg!35!bg] (0,0) -- (0.3,0) -- (0.4,0.12) -- (0.4,0.5) -- (0,0.5) -- cycle;
    \draw[draw=fg!35!bg](0.3,0) -- (0.3,0.12) -- (0.4,0.12);
  \end{tikzpicture}
}

\defbeamertemplate*{frametitle}{progressbar theme}{
  \begin{centering}
    \textbf{\insertframetitle}
    \par
  \end{centering}
}

\mode
<all>

  1. beamerouterthemeprogressbar.sty
\ProvidesPackage{beamerouterthemeprogressbar}[2007/06/21]

\RequirePackage{tikz}

\makeatletter

\setbeamercolor{progressbar primary}{parent=palette primary}
\setbeamercolor{progressbar secondary}{parent=palette secondary}
\setbeamercolor{progressbar tertiary}{parent=palette tertiary}
\setbeamercolor{progressbar quaternary}{parent=palette quaternary}

\newdimen\progressbar@currentbarlength
\newdimen\progressbar@framenumberrectangle
\newdimen\progressbar@titlerectangle
\newdimen\progressbar@leftbar
\newdimen\progressbar@barlengthmm

\newcount\progressbar@tmpresult
\newcount\progressbar@numer
\newcount\progressbar@denom
\newcount\progressbar@barlength

\progressbar@framenumberrectangle=\paperwidth
\progressbar@titlerectangle=\paperwidth

\advance\progressbar@framenumberrectangle by -0.9cm
\advance\progressbar@titlerectangle by -1.1cm

\progressbar@barlength=115 % (in millimeters)
\progressbar@barlengthmm=\progressbar@barlength mm
\progressbar@leftbar=\progressbar@titlerectangle
\advance\progressbar@leftbar by -\progressbar@barlength mm

\def\insertprogressbar{
  \ifnum\inserttotalframenumber=1\else
    \progressbar@numer=\insertframenumber
    \advance\progressbar@numer by -1
    \progressbar@denom=\inserttotalframenumber
    \advance\progressbar@denom by -1
    \progressbar@tmpresult=\progressbar@barlength
    \multiply\progressbar@tmpresult by \progressbar@numer
    \divide\progressbar@tmpresult by \progressbar@denom
    \progressbar@currentbarlength=\progressbar@tmpresult mm

    \begin{tikzpicture}
      \shade[top color=bg, bottom color=bg!80!fg] (0, 0) rectangle  (\paperwidth, 0.6cm);
      \shade[left color=bg,right color=bg!70!fg] (.5\paperwidth, 0.2cm) rectangle (\paperwidth, 0.22cm);
      \draw (\progressbar@framenumberrectangle, 0.21cm) node [anchor=mid west, draw=bg!70!fg, fill=bg] {\color{structure.fg!70!bg}\insertframenumber~/~\inserttotalframenumber};
      \draw (\progressbar@titlerectangle, 0.32cm) node [anchor=south east] {\color{bg!70!fg}\inserttitle};
      \fill (\progressbar@leftbar, 0.12cm) [fill=bg, rounded corners=0.1cm] rectangle (\progressbar@titlerectangle, 0.3cm);
      \ifnum\insertframenumber=1\else
      \shade[left color=progressbar primary.fg!10!bg, right color=progressbar primary.fg!20!bg, rounded corners=0.1cm] (\progressbar@leftbar, 0.12cm) rectangle ++(\progressbar@currentbarlength, 0.2cm);
      \fi
      \draw (\progressbar@leftbar, 0.11cm) [draw=bg!70!fg, rounded corners=0.1cm] rectangle ++(\progressbar@barlengthmm, 0.2cm);
    \end{tikzpicture}
  \fi
}

\mode<presentation>

\newlength\progressbar@sectionboxwidth
\newlength\progressbar@sectionboxheight
\newbox\progressbar@sectionbox
\newbox\progressbar@sectionboxbox

\usesectionheadtemplate
  {\hfill
    \setbox\progressbar@sectionbox=\hbox{\insertsectionhead}%
    \progressbar@sectionboxwidth=\wd\progressbar@sectionbox
    \advance\progressbar@sectionboxwidth by 4pt
    \setbox\progressbar@sectionbox=\hbox{\pgfinterruptpicture t \endpgfinterruptpicture}%
    \progressbar@sectionboxheight=\ht\progressbar@sectionbox
    \advance\progressbar@sectionboxheight by 4pt
    \begin{tikzpicture}
      \useasboundingbox (-0.5\progressbar@sectionboxwidth, 0pt) rectangle (0.5\progressbar@sectionboxwidth, \progressbar@sectionboxheight);
      \draw[anchor=base] (0pt, 2pt) node {\color{structure.fg!80!bg} \insertsectionhead};
      \draw[rounded corners=3pt, draw=structure.fg!80!bg] (-0.5\progressbar@sectionboxwidth, 0pt) rectangle (0.5\progressbar@sectionboxwidth, \progressbar@sectionboxheight);
    \end{tikzpicture}
  }
  {\hfill
    \setbox\progressbar@sectionbox=\hbox{\pgfinterruptpicture\insertsectionhead\endpgfinterruptpicture}%
    \progressbar@sectionboxwidth=\wd\progressbar@sectionbox
    \advance\progressbar@sectionboxwidth by 4pt
    \setbox\progressbar@sectionboxbox=\hbox{\pgfinterruptpicture t \endpgfinterruptpicture}%
    \progressbar@sectionboxheight=\ht\progressbar@sectionboxbox
    \advance\progressbar@sectionboxheight by 4pt
    \begin{tikzpicture}
      \useasboundingbox (-0.5\progressbar@sectionboxwidth, 0pt) rectangle (0.5\progressbar@sectionboxwidth, \progressbar@sectionboxheight);
      \draw[anchor=base] (0pt, 2pt) node {\color{structure.fg!50!bg} \insertsectionhead};
    \end{tikzpicture}
  }

\defbeamertemplate*{headline}{progressbar theme}
{%
  \leavevmode%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,dp=1.125ex]{section in head/foot}%
    \insertsectionnavigationhorizontal{\paperwidth}{}{}%\hskip0pt plus1filll}{}%
  \end{beamercolorbox}%
}

\defbeamertemplate*{footline}{progressbar theme}{
  \begin{beamercolorbox}[wd=\paperwidth,ht=0.6cm,dp=0ex]{progressbar in head/foot}%
    \insertprogressbar
  \end{beamercolorbox}%
}

%\institute{(void)}

\defbeamertemplate*{title page}{progressbar theme}{
  \pgfdeclarehorizontalshading{separationtitlepagelineshading}{0.5pt}{color(0cm)=(bg); color(0.5\textwidth)=(structure.fg); color(\textwidth)=(bg)}

  \makeatletter
  \begin{center}
    \textbf{\textcolor{structure.fg}\large\inserttitle}

    \pgfuseshading{separationtitlepagelineshading}
    \vskip\baselineskip
    \footnotesize\insertauthor\\[\baselineskip]
    \ifx\insertinstitute\@empty \else\tiny\insertinstitute\\[\baselineskip]\fi
    \insertlogo
    \vskip\baselineskip
    \pgfuseshading{separationtitlepagelineshading}
    \vfill
    \footnotesize
    \insertdate
  \end{center}
  \makeatother
}
\setbeamertemplate{title page}[mytitlepage]

\defbeamertemplate*{background canvas}{progressbar theme}{\pgfuseshading{background shading}}%[action]

\AtBeginDocument{%
  {
    \usebeamercolor{progressbar primary}
    \pgfdeclareverticalshading{background shading}{\the\paperwidth}{color(0cm)=(normal text.bg); color(0.8\paperheight)=(normal text.bg); color(0.95\paperheight)=(progressbar primary.bg); color(\paperheight)=(progressbar primary.bg)
    }
  }
}

\mode
<all>

\makeatother

  1. beamerthemeprogressbar.sty
\ProvidesPackage{beamerthemeprogressbar}[2007/06/21]

\RequirePackage{tikz}


\usecolortheme{progressbar}
\useinnertheme{progressbar}
\usefonttheme{progressbar}
\useoutertheme{progressbar}

\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamertemplate{navigation symbols}{}

\AtBeginDocument{%
  \typeout{..................................................................}
  \typeout{You are using the progressbar beamer theme (Sylvain B.)}
  \typeout{Version: 0.32. Jun. 2007.}
  \typeout{..................................................................}
}

答案1

  • 切勿\section在框架内部使用分段命令。它们应始终位于外部

  • 使用latin1inputenc 选项很可能是错误的。仔细检查你的文件是否真的是用 latin1 编码的,而不是 utf8 编码的

  • 如果你只想显示当前部分,你可以重新定义标题模板,并\insertsectionnavigationhorizontal用简单的替换\insertsection


\documentclass[english]{beamer}

\mode<article> % only for the article version
{
  \usepackage{fullpage}
  \usepackage{hyperref}
}


\mode<presentation>
{
  %\setbeamertemplate{background canvas}[vertical shading][bottom=red!10,top=blue!10]
  \setbeamercovered{transparent}
  \usetheme{progressbar}
  \usefonttheme{serif}
  \usecolortheme{crane}
}

\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
%\usepackage[latin1]{inputenc}
%\usepackage{colortbl}

\setbeamercovered{dynamic}

\setbeamertemplate{items}[circle]

\setbeamertemplate{headline}
{%
  \leavevmode%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,dp=1.125ex]{section in head/foot}%
     \quad\usebeamerfont{section in head/foot}\insertsection
  \end{beamercolorbox}%
}


\begin{document}

\section{Section 1}
\begin{frame}
This is my first slide...
\end{frame}

\section{Section 2}
\begin{frame}
This is my second slide...
\end{frame}

\end{document}

在此处输入图片描述

相关内容