Beamer - 在 TOC 框架上使用自定义环境

Beamer - 在 TOC 框架上使用自定义环境

我定义了一个slide基于框架的环境来获取标题下方和页脚上方的规则并获取框架标题中的部分。

\newenvironment{slide}[1]
{\begin{frame}[environment=slide]
\frametitle{\textbf{\textcolor{black}{\insertsection}}\\#1\\\vspace*{-.38cm}\rule{1.12\textwidth}{0.08ex}}\vspace*{-.5cm}}
{\hfill\hspace*{-.8cm}\vspace*-.8cm}\color{itemizecolor}\rule{1.12\textwidth}{0.08ex}
\end{frame}}

我现在也想在 TOC 框架上使用这种样式。有没有办法告诉 latex 将此环境用于 TOC?

编辑:根据要求,这里是 MWE:

\documentclass[xcolor=dvipsnames]{beamer} 
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}


\definecolor{itemizecolor}{rgb}{0.18,0.22,0.60}
\newenvironment{slide}[1]
{\begin{frame}[environment=slide]
\frametitle{\textbf{\textcolor{black}{\insertsection}}\\#1\\\vspace*{-.38cm}\rule{1.12\textwidth}{0.08ex}}\vspace*{-.5cm}}
{\vfill\hspace*{-.8cm}\color{itemizecolor}\rule{1.12\textwidth}{0.08ex}
 \end{frame}}

 \begin{document}

%----------- titlepage ----------------------------------------------%
\begin{frame}[plain]
  \titlepage
\end{frame}

%----------- slide --------------------------------------------------%
\begin{frame}{Inhalt}
\tableofcontents
\end{frame}

\section{Section}


\begin{slide}{slide title}
Test
Test

\end{slide}

\end{document}

答案1

我是否遗漏了什么或者为什么不简单地写

\begin{slide}{Inhalt}
    \tableofcontents
\end{slide}

话虽如此,我本人不会将自定义环境定义为框架的包装器,因为根据我的个人经验,这会导致比解决的问题更多的问题。为什么不使用 beamer 自己的机制来修改框架标题并在页脚中放置一行?

\documentclass[xcolor=dvipsnames]{beamer} 
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}

\definecolor{itemizecolor}{rgb}{0.18,0.22,0.60}

\setbeamertemplate{frametitle}{%
    \textbf{\textcolor{black}{\insertsection}}\\%
    \insertframetitle \\%
    \vspace*{-.38cm}%
    \rule{1.12\textwidth}{0.08ex}%
    \vspace*{-.5cm}%
}

\setbeamertemplate{footline}{%
    \usebeamercolor[fg]{frametitle}
    \hspace{1cm}
    \rule{1.12\textwidth}{0.08ex}%
    \vspace*{0.2cm}
}

\begin{document}

%----------- titlepage ----------------------------------------------%
\begin{frame}[plain]
  \titlepage
\end{frame}

%----------- slide --------------------------------------------------%
\begin{frame}{Inhalt}
\tableofcontents
\end{frame}

\section{Section}

\begin{frame}{slide title}
    Test
    Test
\end{frame}

\end{document}

在此处输入图片描述

答案2

好的,经过一段时间后我让它全部工作了,这是一个完整的示例:

\documentclass[xcolor=dvipsnames]{beamer} 
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\newcommand{\btVFill}{\vskip0pt plus 1filll} % needed to push line to the bottom of the page

\newenvironment{slide} % wrapper for frame, wrting Section \\ Subsection in the header, adding lines below header and above footer
{\begin{frame}[environment=slide]
\frametitle{\textbf{\textcolor{black}{\insertsection}}\\\insertsubsection\\\vspace*{-.38cm}\rule{1.12\textwidth}{0.08ex}}}
{\btVFill\hspace*{-.8cm}\color{itemizecolor}\rule{1.12\textwidth}{0.08ex}
 \end{frame}}

\defbeamertemplate{footline}{myframe number} % moving the frame numbers up a bit, too close to bottom by default
{
  \hfill
  \usebeamercolor[itemizecolor]{page number in head/foot}%
  \usebeamerfont{page number in head/foot}
  \raisebox{-0.3cm}[0cm][.5cm]{% <--- change here
   \insertframenumber\,/\,\inserttotalframenumber\kern1em\hspace*{.3cm}}%
}

% some fumbling with the itemize symbols in toc etc., and genereal appereance - not strictly relevant for the problem, but maybe usefull for someone.

\definecolor{itemizecolor}{rgb}{0.18,0.22,0.60}
\defbeamertemplate{section in toc}{square unnumbered}{%
  \leavevmode\leftskip=1.75ex%
  \llap{{\color{itemizecolor}$\blacksquare$}}%
  \kern1.5ex\inserttocsection\par}
\defbeamertemplate{subsection in toc}{square unnumbered}{%
  \leavevmode\leftskip=4.6ex%
  \llap{{\color{itemizecolor}$\blacksquare$}}%
  \kern1.5ex\inserttocsubsection\par}

\usetheme{default} 
\setbeamertemplate{enumerate items}[none] 
\setbeamertemplate{blocks}[rounded][shadow=true] 
\setbeamertemplate{itemize item}{\color{itemizecolor}$\blacksquare$}
\setbeamertemplate{section in toc}[square unnumbered]
\setbeamertemplate{subsection in toc}[square unnumbered]
\setbeamertemplate{navigation symbols}{} 
\setbeamertemplate{footline}[myframe number]
\setbeamercolor{section in toc}{fg=Black}


% presentation boddy

\title{Interesting Topic}
\author{Ano Nym}

\begin{document}

% modified toc at start of each section
\AtBeginSection[]
{
\subsection*{Overview}
\begin{slide}
 \tableofcontents[currentsection,hideothersubsections]
\end{slide}
}

\begin{frame}[plain]
  \titlepage
\end{frame}

\section*{Table of Contents}
\subsection*{ }
\begin{slide}
\tableofcontents[subsectionstyle=hide]
\end{slide}


\section{Section1}
\subsection{subsec 1}
\begin{slide}
abc
\end{slide}
\subsection{subsec 2}
\begin{slide}
abc
\end{slide}
\section{Section 2}
\subsection{subsec 1}
\begin{slide}
abc
\end{slide}
\subsection{subsec 2}
\begin{slide}
abc
\end{slide}
\end{document}

输出: 标题页

目录

降低节前总有机碳 (TOC)

内容幻灯片示例

相关内容