我正在使用 Beamer 模板,但有些东西让我感到困惑。如果我在括号环境中设置 Beamer 模板,我得到的结果与在另一个 Beamer 模板中设置并在框架内使用时得到的结果不同。
以下是我想做的 MWE:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{metropolis}
\defbeamertemplate{background canvas}{section perso}{%
\tikz[overlay,remember picture]{
\fill[color=gray] (1.,-1.) rectangle (15.,-8.);%
}%
}
\defbeamertemplate{frametitle}{section perso}[1][]{\insertframetitle}
\defbeamertemplate*{toc page}{perso}[1][]
{%
\setbeamertemplate{background canvas}[section perso]%
\setbeamertemplate{frametitle}[section perso]%
\setbeamercolor{frametitle}{fg=gray}%
\setbeamercolor{section in toc}{fg=white}%
\setbeamercolor{subsection in toc}{fg=white}%
\setbeamercolor{subsubsection in toc}{fg=white}%
}
\begin{document} %
\begin{frame}{first}
tata
\end{frame}
{
%% WORKING
% \setbeamertemplate{frametitle}[section perso]
% \setbeamertemplate{background canvas}[section perso]
% \setbeamercolor{frametitle}{fg=gray}
% \setbeamercolor{section in toc}{fg=white}
% \setbeamercolor{subsection in toc}{fg=white}
% \setbeamercolor{subsubsection in toc}{fg=white}
% \setbeamertemplate{toc page}[perso] % NOT WORKING
% \setbeamertemplate*{toc page}[perso] % NOT WORKING
\begin{frame}{TOC}
\usebeamertemplate{toc page}%[perso] % NOT WORKING
% \usebeamertemplate*{toc page}%[perso] % NOT WORKING
% \usebeamertemplate**{toc page}%[perso] % NOT WORKING
% \usebeamertemplate***{toc page}%[perso] % NOT WORKING
% \setbeamertemplate{toc page}[perso] % NOT WORKING
% \setbeamertemplate*{toc page}[perso] % NOT WORKING
\begin{columns}
\column{0.30\textwidth}
\column{0.70\textwidth}
test
\tableofcontents
\end{columns}
\end{frame}
\begin{frame}{title}
toto
\end{frame}
}
\section{Chapiter}
\subsection{sub sec}
\end{document}
所以我的问题是如何设置一个仅为某些幻灯片调用其他 beamer 模板的 beamer 模板?
答案1
如果你发明了一个新的模板(如toc page
),而该模板不被 beamer 使用,那么仅仅设置它是不够的,你还必须实际使用该模板:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{moloch}% modern fork of the metropolis theme
\defbeamertemplate{background canvas}{section perso}{%
\tikz[overlay,remember picture]{
\fill[color=gray] (1.,-1.) rectangle (15.,-8.);%
}%
}
\defbeamertemplate{frametitle}{section perso}[1][]{\insertframetitle}
\defbeamertemplate*{toc page}{perso}[1][]
{%
\setbeamertemplate{background canvas}[section perso]%
\setbeamertemplate{frametitle}[section perso]%
\setbeamercolor{frametitle}{fg=gray}%
\setbeamercolor{section in toc}{fg=white}%
\setbeamercolor{subsection in toc}{fg=white}%
\setbeamercolor{subsubsection in toc}{fg=white}%
}
\begin{document} %
\begin{frame}{first}
tata
\end{frame}
{
\setbeamertemplate{toc page}[perso]
\usebeamertemplate{toc page}
\begin{frame}{TOC}
\begin{columns}
\column{0.30\textwidth}
\column{0.70\textwidth}
test
\tableofcontents
\end{columns}
\end{frame}
\begin{frame}{title}
toto
\end{frame}
}
\section{Chapiter}
\subsection{sub sec}
\end{document}