在投影仪底部显示除 0 之外的部分编号

在投影仪底部显示除 0 之外的部分编号

我正在使用马德里主题制作一个 Beamer 演示文稿,并且创建了自己的脚注。一切都很好,但我想在标题下方的脚注中包含部分信息,具体来说,格式为“Sec. # - 部分标题”,其中 # 是部分编号。我可以很好地做到这一点,只是在第一部分之前我有“Sec. 0 - ”,我想知道是否有一种简单的方法可以隐藏它,或者让它在到达第一部分之前不显示。

\documentclass{beamer}
\usepackage{ amsmath, amssymb}
\setbeamertemplate{navigation symbols}{}
\usetheme{Madrid}
\setbeamertemplate{blocks}[rounded][shadow=true]

\definecolor{darkblue}{RGB}{0,0,120}

\setbeamercolor{author in head/foot}{fg=white,bg=black}
\setbeamercolor{title in head/foot}{fg=white,bg=darkerblue}
\setbeamercolor{date in head/foot}{fg=white,bg=darkblue}
\setbeamercolor{frametitle}{fg=white,bg=darkblue}
\makeatletter
\setbeamertemplate{footline}
{
  \leavevmode
  \hbox{

  \begin{beamercolorbox}[wd=.5\paperwidth,ht=4ex,left]{author in head/foot}% 
    \usebeamerfont{author in head/foot}
        \begin{tabular}{l}
        \insertshortauthor\\
        \insertshortinstitute
        \end{tabular}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=4ex,left]{title in head/foot}%

    \usebeamerfont{title in head/foot}
        \vspace*{-2pt}
        \begin{tabular}{l}
        \insertshorttitle\\
        \insertsection~~\beamer@ifempty{\phantom{section}}{}{}
        \end{tabular}
  \end{beamercolorbox}
}
  \vskip0pt
}
\makeatother


\title{A Title}
\author{The Author}
\institute{The Institute}
\date{\today}

\begin{document}
\begin{frame}
\titlepage
\end{frame}

\begin{frame}{Outline}
An outline.
\end{frame}

\section{The First Section}
\begin{frame}
A frame.
\end{frame}
\end{document}

答案1

插入关于章节编号的查询,如果大于零,则插入章节编号和标题,否则保留该空行,以便周围tabular环境真正打印出该行。

\ifnumgreater使用包中的命令可以轻松完成查询etoolbox

\ifnumgreater{\arabic{section}}{0}{% True branch
   Sec. \thesection~ -- \insertsection~~ \beamer@ifempty{\phantom{section}}{}{} % line 
}{% False branch
  ~~\beamer@ifempty{\phantom{section}}{}%  Empty fake row
}%

但是,如果偶然出现\chapter这种情况,章节计数器也会重置为零,并且出现在第一章节之前的章节的第一帧将不会显示章节标题,但这可能是想要的。


最终代码如下:

\documentclass{beamer}
\usepackage{ amsmath, amssymb}
\usepackage{etoolbox}%
\setbeamertemplate{navigation symbols}{}
\usetheme{Madrid}
\setbeamertemplate{blocks}[rounded][shadow=true]

\definecolor{darkblue}{RGB}{0,0,120}

\setbeamercolor{author in head/foot}{fg=white,bg=black}
\setbeamercolor{title in head/foot}{fg=white,bg=darkblue}
\setbeamercolor{date in head/foot}{fg=white,bg=darkblue}
\setbeamercolor{frametitle}{fg=white,bg=darkblue}
\makeatletter
\setbeamertemplate{footline}
{
  \leavevmode
  \hbox{

  \begin{beamercolorbox}[wd=.5\paperwidth,ht=4ex,left]{author in head/foot}% 
    \usebeamerfont{author in head/foot}
        \begin{tabular}{l}
        \insertshortauthor\\
        \insertshortinstitute
        \end{tabular}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=4ex,left]{title in head/foot}%

    \usebeamerfont{title in head/foot}
        \vspace*{-2pt}
        \begin{tabular}{l}
        \insertshorttitle\\
        \ifnumgreater{\arabic{section}}{0}{Sec. \thesection~ -- \insertsection~~\beamer@ifempty{\phantom{section}}{}{}}{%
          ~~\beamer@ifempty{\phantom{section}}{}%
          }%
        \end{tabular}
  \end{beamercolorbox}
}
  \vskip0pt
}
\makeatother


\title{A Title}
\author{The Author}
\institute{The Institute}
\date{\today}

\begin{document}
\begin{frame}
\titlepage
\end{frame}

\begin{frame}{Outline}
An outline.
\end{frame}

\section{The First Section}
\begin{frame}
A frame.
\end{frame}

\section{The Second Section}
\begin{frame}
Another frame.
\end{frame}

\section{Third Section}%
\begin{frame}
Yet Another frame.
\end{frame}

\end{document}

第一部分之前的标题和框架--未编号 在此处输入图片描述

部分中的框架已编号 在此处输入图片描述

相关内容