标题页显示导航圈,无子部分带有补丁

标题页显示导航圈,无子部分带有补丁

我正在尝试为 Beamer 创建自定义主题。但是,当我尝试修补导航圈以使其自动包含在没有子部分的情况下时(使用以下解决方案Beamer 导航圈没有子部分吗?) 标题页出现在导航圈中。

我尝试删除所有部分,但找不到为什么它一直将标题页添加到导航栏。我尽力将源代码简化为 MWE,而此代码(如下)产生了错误的圆圈。如果您需要更多信息,我可以提供完整或所需的文件。

在此处输入图片描述

\documentclass{beamer}
\usepackage{etoolbox}
\usepackage{tikz}

\makeatletter

\colorlet{firstColor}{gray!50}
\colorlet{secondColor}{red!80!black}

\beamer@compresstrue

\defbeamertemplate*{headline}{}
{%
\leavevmode
\ifnum\insertframenumber>0\relax%remove it for the title page
\begin{beamercolorbox}[wd=\the\paperwidth,ht=0.6cm]{section in head/foot}
  \begin{tikzpicture}
    \useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,0.6);
    \fill[secondColor] (0,0) rectangle(0.3,0.6);
    \fill[firstColor] (0.35,0) rectangle(\the\paperwidth,0.6);
    \node[anchor= west, white] at (0.3,0.3){\insertnavigation{0.85\paperwidth}};%
  \end{tikzpicture}
\end{beamercolorbox}
\fi
}%


\defbeamertemplate*{frametitle}{}
{%
\vskip-1pt%skip after the begginning of the slide
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle} 
  \begin{tikzpicture}
  \useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,0.6);
  \fill[secondColor] (0,0) rectangle(0.3,1);
  \fill[firstColor] (0.35,0) rectangle(\the\paperwidth,0.6);
  \node[anchor=west, white,font=\large] at (0.4,0.25){\insertframetitle};
  \end{tikzpicture}
  \end{beamercolorbox}
}

% fix the title page navigation bar
\let\oldtitlepage\titlepage
\renewcommand{\titlepage}{%
  \addtocounter{framenumber}{-1}%ensure that title page has 0 number
  \oldtitlepage%
}

% Patches beamer so that "subsections numbered 0" show their slide entries.
% Solution from: https://tex.stackexchange.com/questions/2072/beamer-navigation-circles-without-subsections
\patchcmd{\slideentry}{\ifnum#2>0}{\ifnum2>0}{}{\@error{unable to patch}}% replace the subsection number test with a test that always returns true

\makeatother

\title{Test}
\subtitle{test}
\author{Doe}

\begin{document}

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

\section{section name}
\begin{frame}
content...
\end{frame}

\end{document}

答案1

在您的情况下,标题幻灯片位于任何部分之外,因此您可以更改条件\slideentry以要求部分编号严格为正数。即将\patchcmd{\slideentry}行更改为以下内容:

\patchcmd{\slideentry}{\ifnum#2>0}{\ifnum#1>0}{}{\@error{unable to patch}}% require section number to be strictly positive

这就够了吗?

相关内容