如何从顶部导航栏中删除特定框架,但保持其框架编号在 Beamer 中可见

如何从顶部导航栏中删除特定框架,但保持其框架编号在 Beamer 中可见

beamer我正在使用主题制作演示文稿。我正在使用命令从顶部导航栏中Madrid删除特定框架标题。但它也隐藏了框架编号。Special Frame\buttenoff

测试样式.sty

\mode<presentation>{
\usetheme{Madrid}
\useinnertheme{circles} % https://tex.stackexchange.com/a/47373/114006
\usecolortheme{whale}
\usefonttheme{serif}
\usefonttheme{structuresmallcapsserif}
}

% https://tex.stackexchange.com/a/437578/114006
\makeatletter
% Remember the way beamer did it before
\let\beamer@old@writeslidentry\beamer@writeslidentry
% Tell it to do nothing with the slides entry
\newcommand\bulletoff{\let\beamer@writeslidentry\relax}
% Reset it to the old ways
\newcommand\bulleton{\let\beamer@writeslidentry\beamer@old@writeslidentry}
\makeatother

\setbeamercolor{section in head/foot}{fg=white,bg=black}           % https://tex.stackexchange.com/a/326553/114006
\makeatletter
\setbeamertemplate{headline}{%
    \begin{beamercolorbox}[ht=2.25ex,dp=3.75ex]{section in head/foot}
        \insertnavigation{\paperwidth}
    \end{beamercolorbox}%
}%
\makeatother

\usepackage{ragged2e}   
\addtobeamertemplate{block begin}{}{\justifying}  % https://tex.stackexchange.com/a/148696/114006
\apptocmd{\frame}{}{\justifying}{} % https://tex.stackexchange.com/a/55590/114006

% https://tex.stackexchange.com/a/401409/114006
\usepackage{environ}

% Custom font for a frame.
\newcommand{\customframefont}[1]{
\setbeamertemplate{itemize/enumerate body begin}{#1}
\setbeamertemplate{itemize/enumerate subbody begin}{#1}
}
\NewEnviron{framefont}[1]{
\customframefont{#1} % for itemize/enumerate
{#1 % For the text outside itemize/enumerate
\BODY
}
\customframefont{\normalsize}
}

\setbeamertemplate{caption}[numbered]

测试.tex

\documentclass[aspectratio=43]{beamer}  

\usepackage{teststyle}
% \graphicspath{ {./img/} }

\title{Presentation Title}
\titlegraphic{\includegraphics[width=1cm]{example-image}}

\author{Presenter Name} 
\date{August, 2021} 

\logo{\includegraphics[height=0.5cm,keepaspectratio]{example-image}}

\begin{document}

{
\setbeamercolor{page number in head/foot}{fg=date in head/foot.bg} % https://tex.stackexchange.com/a/412733/114006
\begin{frame}[noframenumbering, plain]
\titlepage
\end{frame}

\begin{frame}[noframenumbering]
\frametitle{Outline} 
\tableofcontents %[pausesections,pausesubsections,subsectionstyle=shaded]
\end{frame}
}

%------------------------------------------------
\section{Section 1} 
\begin{frame}
\frametitle{Section One}
Sed iaculis dapibus gravida.
\end{frame}
%------------------------------------------------
\section{Section 2}
\begin{frame}
\frametitle{Section 2}
Sed iaculis dapibus gravida.
\end{frame}
%------------------------------------------------

\bulletoff\section*{}
\begin{frame}{Special Frame}     % The frame number is not visible!
Sed iaculis dapibus gravida.
\end{frame}

%------------------------------------------------

\setbeamercolor{page number in head/foot}{fg=date in head/foot.bg}
% \bulletoff\section*{}
\begin{frame}[noframenumbering]
\Huge{\centerline{Thank You.}} 
\huge{\centerline{Any Question?}}
\end{frame}

%------------------------------------------------

\end{document}

我想让隐藏的帧编号在标题为 的特定帧上可见Special Frame。只有标题帧、目录帧、最后一帧不应受到影响,即它们不应有帧编号。我该如何修复它?

答案1

如果你查看重新定义的命令的定义\beamer@writeslidentry,你会看到

\def\beamer@writeslidentry{%
  \expandafter\ifblank\expandafter{\beamer@framestartpage}{}% does not happen normally
  {%else
    \addtocontents{nav}%
      {\protect\headcommand{%
          \protect\slideentry{\the\c@section}{\the\c@subsection}{\the\c@subsectionslide}%
          {\beamer@framestartpage/\beamer@frameendpage}{\lastsubsection}{\the\c@part}}}%
    \addtocontents{nav}%
      {\protect\headcommand{%
        \protect\beamer@framepages{\beamer@framestartpage}{\beamer@frameendpage}}}%
    \clearpage\beamer@notesactions%
  }%
}

因此它仅在某些条件下执行,然后写入一些辅助信息(可能影响顶部导航)并最终以 和 结束\clearpage\beamer@notesactions由于您只想避免影响顶部导航,因此仅删除调用似乎是个好主意\addtocontents

这似乎达到了预期的效果:

\documentclass[aspectratio=43]{beamer}  

\mode<presentation>{
\usetheme{Madrid}
\useinnertheme{circles} % https://tex.stackexchange.com/a/47373/114006
\usecolortheme{whale}
\usefonttheme{serif}
\usefonttheme{structuresmallcapsserif}
}

% https://tex.stackexchange.com/a/437578/114006
\makeatletter
% Remember the way beamer did it before
\let\beamer@old@writeslidentry\beamer@writeslidentry
\def\beamer@new@writeslidentry{%
  \expandafter\ifblank\expandafter{\beamer@framestartpage}{}% does not happen normally
  {\clearpage\beamer@notesactions}%
}

% Tell it to do nothing with the slides entry
\newcommand\bulletoff{\let\beamer@writeslidentry\beamer@new@writeslidentry}
% Reset it to the old ways
\newcommand\bulleton{\let\beamer@writeslidentry\beamer@old@writeslidentry}
\makeatother

\setbeamercolor{section in head/foot}{fg=white,bg=black}           % https://tex.stackexchange.com/a/326553/114006
\makeatletter
\setbeamertemplate{headline}{%
    \begin{beamercolorbox}[ht=2.25ex,dp=3.75ex]{section in head/foot}
        \insertnavigation{\paperwidth}
    \end{beamercolorbox}%
}%
\makeatother

\usepackage{ragged2e}   
\addtobeamertemplate{block begin}{}{\justifying}  % https://tex.stackexchange.com/a/148696/114006
\apptocmd{\frame}{}{\justifying}{} % https://tex.stackexchange.com/a/55590/114006

% https://tex.stackexchange.com/a/401409/114006
\usepackage{environ}

% Custom font for a frame.
\newcommand{\customframefont}[1]{
\setbeamertemplate{itemize/enumerate body begin}{#1}
\setbeamertemplate{itemize/enumerate subbody begin}{#1}
}
\NewEnviron{framefont}[1]{
\customframefont{#1} % for itemize/enumerate
{#1 % For the text outside itemize/enumerate
\BODY
}
\customframefont{\normalsize}
}

\setbeamertemplate{caption}[numbered]

\title{Presentation Title}
\titlegraphic{\includegraphics[width=1cm]{example-image}}

\author{Presenter Name} 
\date{August, 2021} 

\logo{\includegraphics[height=0.5cm,keepaspectratio]{example-image}}

\begin{document}

{
\setbeamercolor{page number in head/foot}{fg=date in head/foot.bg} % https://tex.stackexchange.com/a/412733/114006
\begin{frame}[noframenumbering, plain]
\titlepage
\end{frame}

\begin{frame}[noframenumbering]
\frametitle{Outline} 
\tableofcontents %[pausesections,pausesubsections,subsectionstyle=shaded]
\end{frame}
}

%------------------------------------------------
\section{Section 1} 
\begin{frame}
\frametitle{Section One}
Sed iaculis dapibus gravida.
\end{frame}
%------------------------------------------------
\section{Section 2}
\begin{frame}
\frametitle{Section 2}
Sed iaculis dapibus gravida.
\end{frame}
%------------------------------------------------

\bulletoff\section*{}
\begin{frame}{Special Frame}     % The frame number is not visible!
Sed iaculis dapibus gravida.
\end{frame}

%------------------------------------------------

\setbeamercolor{page number in head/foot}{fg=date in head/foot.bg}
% \bulletoff\section*{}
\begin{frame}[noframenumbering]
\Huge{\centerline{Thank You.}} 
\huge{\centerline{Any Question?}}
\end{frame}

%------------------------------------------------

\end{document}

在此处输入图片描述

相关内容