我想在每次开始新的部分时删除框架标题行。
我创建了自己的命令来执行此操作,但是该命令存在一些问题\ifnum
。
我尝试将其用作\ifnum\insertframenumber=\insertsectionstartpage
条件来检查新部分是否开始,然后删除标题(如框架 2)。LaTeX 似乎总是执行 else 分支,尽管条件应该计算为 true... 我也尝试了该\ifthenelse
命令,但它也不起作用。
有人可以解释一下这个吗?
这是我的最小工作示例:
\documentclass[t,8pt]{beamer}
\usepackage{ifthen}
\usetheme{Warsaw}
\newcommand{\HeaderFrame}[2]{
\ifnum\insertframenumber=\insertsectionstartpage
{
\makeatletter
\setbeamertemplate{headline}[default]
\def\beamer@entrycode{\vspace*{-\headheight}}
\makeatother
\begin{frame}{#1}
#2
\end{frame}
}
\else
\begin{frame}{#1}
\insertframenumber~\insertsectionstartpage
\end{frame}
\fi
}
\begin{document}
\section{Test1}
\HeaderFrame{Test}{
That is a test
}
\section{Test2}
{
\makeatletter
\setbeamertemplate{headline}[default]
\def\beamer@entrycode{\vspace*{-\headheight}}
\makeatother
\begin{frame}{New Frame}
Test
\end{frame}
}
\section{Test3}
\end{document}
答案1
\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{etoolbox}
\makeatletter
\newcount\beamer@sectionstartframe
\beamer@sectionstartframe=1
\apptocmd{\beamer@section}{\addtocontents{nav}{\protect\headcommand{%
\protect\beamer@sectionframes{\the\beamer@sectionstartframe}{\the\c@framenumber}}}}{}{}
\apptocmd{\beamer@section}{\beamer@sectionstartframe=\c@framenumber\advance\beamer@sectionstartframe by1\relax}{}{}
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
{\noexpand\headcommand{\noexpand\beamer@sectionframes{\the\beamer@sectionstartframe}{\the\c@framenumber}}}}}{}{}
\def\beamer@startframeofsection{1}
\def\beamer@endframeofsection{1}
\def\beamer@sectionframes#1#2{%
\ifnum\c@framenumber<#1%
\else%
\ifnum\c@framenumber>#2%
\else%
\gdef\beamer@startframeofsection{#1}%
\gdef\beamer@endframeofsection{#2}%
\fi%
\fi%
}
\newcommand\insertsectionstartframe{\beamer@startframeofsection}
\newcommand\insertsectionendframe{\beamer@endframeofsection}
\setbeamertemplate{headline}{%
\ifnum\insertsectionstartframe=\insertframenumber%
\vskip-\headheight%
\else%
\leavevmode%
\@tempdimb=2.4375ex%
\ifnum\beamer@subsectionmax<\beamer@sectionmax%
\multiply\@tempdimb by\beamer@sectionmax%
\else%
\multiply\@tempdimb by\beamer@subsectionmax%
\fi%
\ifdim\@tempdimb>0pt%
\advance\@tempdimb by 1.825ex%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\insertsectionnavigation{.5\paperwidth}\vfil}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{subsection in head/foot}%
\vbox to\@tempdimb{\vfil\insertsubsectionnavigation{.5\paperwidth}\vfil}%
\end{beamercolorbox}%
\fi%
\vskip-0.2pt
\pgfuseshading{beamer@topshade}
\vskip-2pt
\fi%
}
\makeatother
\begin{document}
\section{The First}
\begin{frame}
First slide
\end{frame}
\begin{frame}
Second slide
\end{frame}
\begin{frame}
Third slide
\end{frame}
\begin{frame}
Fourth slide
\end{frame}
\section{The Second}
\begin{frame}
First slide
\end{frame}
\begin{frame}
Second slide
\end{frame}
\begin{frame}
Third slide
\end{frame}
\end{document}