Beamer 中的幻影部分/子部分/子部分

Beamer 中的幻影部分/子部分/子部分

我试图创建一些标准的 (sub(sub)) 部分,其中 beamer 会自动创建一个专门用于分隔它们的幻灯片,在其他情况下,一个部分将出现在 pdf 导航栏和 TOC 幻灯片中,但不会创建分隔部分的幻灯片(我用于制作分隔部分的幻灯片的代码在问题的末尾)。我将其称为幻影部分,但如果有更好的名称,请编辑问题的标题以帮助其他人找到这个问题。

接近期望行为的一种方法可以在这个问题,但它没有将超链接添加到目录中正确的幻灯片编号,也没有将该部分添加到 pdf 导航栏。我尝试调整其代码以与子部分一起使用:

\makeatletter
\newcommand{\phantomsectionfortoc}[1]{%%
  \global\advance\beamer@tocsectionnumber by 1%%
  \addtocontents{toc}{\protect\beamer@sectionintoc{0}{#1}{0}{0}%%
    {\the\beamer@tocsectionnumber}}}
\makeatother
\makeatletter
\newcommand{\phantomsubsectionfortoc}[1]{%%
  \global\advance\beamer@tocsubsectionnumber by 1%%
  \addtocontents{toc}{\protect\beamer@subsectionintoc{0}{#1}{0}{0}%%
    {\the\beamer@tocsubsectionnumber}}}
\makeatother
\makeatletter
\newcommand{\phantomsubsubsectionfortoc}[1]{%%
  \global\advance\beamer@tocsubsubsectionnumber by 1%%
  \addtocontents{toc}{\protect\beamer@subsubsectionintoc{0}{#1}{0}{0}%%
    {\the\beamer@tocsubsubsectionnumber}}}
\makeatother

但它的局限性在于无法正确使用超链接。我需要更改 {0} 输入以指向正确的幻灯片编号。此外,子部分没有任何效果。


那么,我如何才能创建出现在目录和 pdf 导航栏中的幻影部分,但不创建分隔幻灯片?


接下来我提供一个起始代码示例。假设 Subsection1.2 和 Subsection2.1.1 之间不应该有分隔幻灯片,该如何实现?

% Package options:
\PassOptionsToPackage{table,xcdraw}{xcolor}
\documentclass[table,svgnames,smaller,11pt]{beamer}
%% Add slide numbers
\newcommand*\oldmacro{}%%
\let\oldmacro\insertshorttitle%%
\renewcommand*\insertshorttitle{%%
   \oldmacro\hfill%%
   \insertframenumber\,/\,\inserttotalframenumber}
% For more themes, color themes and font themes, see:
\mode<presentation>
{
  \usetheme{Berlin}             % or try default, Darmstadt, Warsaw, Boadilla ...
  \usecolortheme{default}   % or try albatross, beaver, crane, ...
  \usefonttheme{serif}          % or try default, structurebold, ...
  %\usefonttheme{professionalfonts} % or try default, structurebold, ...
  %\usefonttheme{serif}             % or try default, structurebold, ...
  %\setmainfont{Helvetica}
  \setbeamertemplate{caption}[numbered]
}
%----------------------PACKAGES-|-SEGAKCAP---------------------
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{multicol}
\usepackage{chemfig}
\usepackage{etoolbox}
\usepackage{moresize}
\usepackage[percent]{overpic}
\usepackage[version=3]{mhchem}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{anyfontsize}
%---------------END-OF-PACKAGES-|-SEGAKCAP-FO-DNE--------------
\title{Report}
\author{[email protected]}
\institute{ATLAS Internal}
\date{\today}
\setbeamerfont{frametitle}{size=\small}
\useinnertheme{rounded}
\useoutertheme{smoothtree}
\setbeamertemplate{headline}
{%
  \pgfuseshading{beamer@treeshade}%
  \vskip-10.25ex%
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.125ex,dp=1.125ex,ignorebg,%
    leftskip=.3cm,rightskip=.3cm plus1fil]{section in head/foot}
    \usebeamerfont{section in head/foot}%
    \insertsectionhead
  \end{beamercolorbox}
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.125ex,dp=1.125ex,ignorebg,%
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
    \usebeamerfont{subsection in head/foot}%
    \hskip6pt\insertsubsectionhead
  \end{beamercolorbox}
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.125ex,dp=1.125ex,ignorebg,%
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsubsection in head/foot}
    \usebeamerfont{subsection in head/foot}%
    \hskip12pt\insertsubsubsectionhead
  \end{beamercolorbox}
}
\defbeamertemplate{subsubsection in toc}{subsubsections numbered}
{\leavevmode\leftskip=3em%
 \rlap{\hskip-3em\inserttocsectionnumber.\inserttocsubsectionnumber.\inserttocsubsubsectionnumber}%
 \inserttocsubsubsection\par}
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\setbeamertemplate{subsubsection in toc}[subsubsections numbered]
\AtBeginSection[]{
  \frame<beamer>{
  \frametitle{Outline}
  \tableofcontents[
    sectionstyle=show/shaded,
    subsectionstyle=show/shaded/hide,
    subsubsectionstyle=show/hide/hide/hide,
    ]
 }
}
\AtBeginSubsection[]{
  \frame<beamer>{
  \frametitle{Outline}
  \tableofcontents[
    sectionstyle=show/shaded,
    subsectionstyle=show/shaded/hide,
    subsubsectionstyle=show/shaded/hide/hide
    ]
 }
}
\AtBeginSubsubsection[]{
  \frame<beamer>{
  \frametitle{Outline}
  \tableofcontents[
    sectionstyle=show/shaded,
    subsectionstyle=show/shaded/hide,
    subsubsectionstyle=show/shaded/hide/hide
    ]
 }
}
\begin{document}
%--------------------------------------------------------------
\titlepage
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\section*{Outline}
%--------------------------------------------------------------
\begin{frame}
[allowframebreaks]
\frametitle{Outline}
\tableofcontents
\end{frame}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\section{Section1}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\subsection{Subsection1.1}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide1}
\end{frame}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide2}
\end{frame}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\subsection{Subsection1.2}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide3}
\end{frame}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide4}
\end{frame}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\section{Section2}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\subsection{Subsection2.1}
%--------------------- --------- -------- ---------------------
\subsubsection{Subsection2.1.1}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide5}
\end{frame}
%--------------------- --------- -------- ---------------------
\subsubsection{Subsection2.1.2}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide6}
\end{frame}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\subsection{Subsection2.2}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide7}
\end{frame}
\end{document}

答案1

此处,命令\outlinesection\outlinesubsections\outlinesubsubsection被定义为生成一个以大纲框架开头的节、小节或小小节。除了大纲框架之外,\outlinesection和 的\section工作方式完全相同。这也适用于小节和小小节。

为此,\outlineframe定义了命令,该命令也可以在演示文稿的任何位置在帧之间使用(参见幻灯片 3 和 4 之间)。

怎么运行的:

它通过\outlineframe\AtBeginSection条件中使用 \ifdooutline.\outlinesection集来工作\dooutlinetrue,因此显示轮廓框架。在 的末尾\AtBeginSection \dooutlinefalse设置为切换回默认行为。(小节和小子节相同。)

注意 很重要\section位于 定义的最后\outlinesection。这样\outlinesection本身不需要任何参数。后面的 是 使用的\section。因此\outlinesection可以像 一样使用,即使用相同的参数。和 也是\section一样。\outlinesubsection\outlinesubsubsection

\PassOptionsToPackage{table,xcdraw}{xcolor}
\documentclass[table,svgnames,smaller,11pt]{beamer}
%% Add slide numbers
\newcommand*\oldmacro{}%%
\let\oldmacro\insertshorttitle%%
\renewcommand*\insertshorttitle{%%
   \oldmacro\hfill%%
   \insertframenumber\,/\,\inserttotalframenumber}
% For more themes, color themes and font themes, see:
\mode<presentation>
{
  \usetheme{Berlin}             % or try default, Darmstadt, Warsaw, Boadilla ...
  \usecolortheme{default}   % or try albatross, beaver, crane, ...
  \usefonttheme{serif}          % or try default, structurebold, ...
  %\usefonttheme{professionalfonts} % or try default, structurebold, ...
  %\usefonttheme{serif}             % or try default, structurebold, ...
  %\setmainfont{Helvetica}
  \setbeamertemplate{caption}[numbered]
}
%----------------------PACKAGES-|-SEGAKCAP---------------------
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
% commented out some packages not installed here and
% added lmodern to get rid of an error regarding fontsize
\usepackage{lmodern}
\usepackage{multicol}
%\usepackage{chemfig}
\usepackage{etoolbox}
%\usepackage{moresize}
%\usepackage[percent]{overpic}
%\usepackage[version=3]{mhchem}
\usepackage{graphicx}
\usepackage{booktabs}
%\usepackage{anyfontsize}
%---------------END-OF-PACKAGES-|-SEGAKCAP-FO-DNE--------------
\title{Report}
\author{[email protected]}
\institute{ATLAS Internal}
\date{\today}
\setbeamerfont{frametitle}{size=\small}
\useinnertheme{rounded}
\useoutertheme{smoothtree}
\setbeamertemplate{headline}
{%
  \pgfuseshading{beamer@treeshade}%
  \vskip-10.25ex%
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.125ex,dp=1.125ex,ignorebg,%
    leftskip=.3cm,rightskip=.3cm plus1fil]{section in head/foot}
    \usebeamerfont{section in head/foot}%
    \insertsectionhead
  \end{beamercolorbox}
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.125ex,dp=1.125ex,ignorebg,%
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
    \usebeamerfont{subsection in head/foot}%
    \hskip6pt\insertsubsectionhead
  \end{beamercolorbox}
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.125ex,dp=1.125ex,ignorebg,%
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsubsection in head/foot}
    \usebeamerfont{subsection in head/foot}%
    \hskip12pt\insertsubsubsectionhead
  \end{beamercolorbox}
}
\defbeamertemplate{subsubsection in toc}{subsubsections numbered}
{\leavevmode\leftskip=3em%
 \rlap{\hskip-3em\inserttocsectionnumber.\inserttocsubsectionnumber.\inserttocsubsubsectionnumber}%
 \inserttocsubsubsection\par}
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\setbeamertemplate{subsubsection in toc}[subsubsections numbered]


\newif\ifdooutline

\newcommand{\outlineframe}{%
  \frame<beamer>{
  \frametitle{Outline}
  \tableofcontents[
    sectionstyle=show/shaded,
    subsectionstyle=show/shaded/hide,
    subsubsectionstyle=show/hide/hide/hide,
    ]
 }
}

\newcommand{\outlinesection}{\dooutlinetrue\section}
\newcommand{\outlinesubsection}{\dooutlinetrue\subsection}
\newcommand{\outlinesubsubsection}{\dooutlinetrue\subsubsection}

\AtBeginSection[]{
  \ifdooutline\outlineframe\fi
  \dooutlinefalse
}
\AtBeginSubsection[]{
  \ifdooutline\outlineframe\fi
  \dooutlinefalse
}
\AtBeginSubsubsection[]{
  \ifdooutline\outlineframe\fi
  \dooutlinefalse
}

\begin{document}
%--------------------------------------------------------------
\titlepage
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\section*{Outline}
%--------------------------------------------------------------
\begin{frame}
[allowframebreaks]
\frametitle{Outline}
\tableofcontents
\end{frame}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\section{Section1}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\subsection{Subsection1.1}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide1}
\end{frame}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide2}
\end{frame}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\outlinesubsection{Subsection1.2}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide3}
\end{frame}
%--------------------------------------------------------------
\outlineframe
\begin{frame}
\frametitle{Slide4}
\end{frame}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\outlinesection{Section2}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\subsection{Subsection2.1}
%--------------------- --------- -------- ---------------------
\subsubsection{Subsection2.1.1}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide5}
\end{frame}
%--------------------- --------- -------- ---------------------
\outlinesubsubsection{Subsection2.1.2}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide6}
\end{frame}
%--------------------- --------- -------- ---------------------
%--------------------- --------- -------- ---------------------
\outlinesubsection{Subsection2.2}
%--------------------------------------------------------------
\begin{frame}
\frametitle{Slide7}
\end{frame}
\end{document}

相关内容