我想在演示文稿的每个部分开头添加目录,但不在导航栏中显示框架。我尝试了以下操作:
\AtBeginSection[]
{
{
\makeatletter
\def\beamer@writeslidentry{\clearpage\beamer@notesactions}
\makeatother
\frame{
\frametitle{Table of contents}
\tableofcontents[
currentsection,
subsectionstyle=show/show/hide
]
}
}
}
这样可以正确显示框架,但不会将其从导航栏中隐藏。如果我手动将内部块移动到每个部分的开头,则此操作可以正常工作(请参阅下面的完整代码)。
我怎样才能解决这个问题?
我在这里找到了上述内容,但它不在AtBeginSection
:
完整示例:
\documentclass[usenames,dvipsnames,svgnames,table]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetheme{Madrid}
\useoutertheme{miniframes}
\useinnertheme{circles}
% This one shows in the navigation bar -> Not good.
\AtBeginSection[]
{
{
\makeatletter
\def\beamer@writeslidentry{\clearpage\beamer@notesactions}
\makeatother
\frame{
\frametitle{Table of contents}
\tableofcontents[
currentsection,
subsectionstyle=show/show/hide
]
}
}
}
\begin{document}
\section{Section 1}
% This one does not show in the navigation bar -> Ok.
{
\makeatletter
\def\beamer@writeslidentry{\clearpage\beamer@notesactions}
\makeatother
\frame{
\frametitle{Table of contents}
\tableofcontents[
currentsection,
subsectionstyle=show/show/hide
]
}
}
\end{document}
答案1
非常肮脏的黑客行为:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetheme{Madrid}
\useoutertheme{miniframes}
\makeatletter
\let\beamer@writeslidentry@miniframeson=\beamer@writeslidentry%
\def\beamer@writeslidentry@miniframesoff{%
\expandafter\beamer@ifempty\expandafter{\beamer@framestartpage}{}% does not happen normally
{%else
% removed \addtocontents commands
\clearpage\beamer@notesactions%
}
}
\newcommand*{\miniframeson}{\let\beamer@writeslidentry=\beamer@writeslidentry@miniframeson}
\newcommand*{\miniframesoff}{\let\beamer@writeslidentry=\beamer@writeslidentry@miniframesoff}
\makeatother
\setbeamertemplate{section in head/foot}{\hspace*{1.7ex}\insertsectionhead}
\makeatletter
\setbeamertemplate{headline}{%
\begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
\end{beamercolorbox}
\begin{beamercolorbox}{section in head/foot}
\vskip2pt\hspace*{-1.7ex}\insertnavigation{1.01\paperwidth}\vskip2pt
\end{beamercolorbox}%
\ifbeamer@theme@subsection%
\begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
\end{beamercolorbox}
\begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
\usebeamerfont{subsection in head/foot}\insertsubsectionhead
\end{beamercolorbox}%
\fi%
\begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
\end{beamercolorbox}
}
\makeatother
\AtBeginSection[]{%
\miniframesoff
\begin{frame}
\frametitle{Table of contents}
\tableofcontents[
currentsection,
subsectionstyle=show/show/hide
]
\end{frame}
\miniframeson
}
\begin{document}
\section{Section 1}
\begin{frame}
\end{frame}
\begin{frame}
\end{frame}
\section{Section 2}
\begin{frame}
\end{frame}
\end{document}
答案2
您可以重新定义 \section
为在执行旧代码后始终执行目录代码\section
。将以下内容添加到您的序言中:
\makeatletter
\newcommand\mytableofcontents{%
\begingroup
\def\beamer@writeslidentry{\clearpage\beamer@notesactions}%
\frame{%
\frametitle{Table of contents}%
\tableofcontents[%
currentsection,
subsectionstyle=show/show/hide
]%
}%
\endgroup
}
\let\orig@section\section
\renewcommand\section[1]{\orig@section{#1}\mytableofcontents}
\makeatother
如果您决定也使用某处的可选参数\section
,则必须\section
相应地重新定义以处理它。