我设法重复这个例子用于自定义 beamer 样式。现在我想自动将节和子节标题插入到每张幻灯片的顶部,无需设置\frametitle
,最好通过.sty
文件(即 beamer 外部主题)而不是在.tex
文件中进行设置。
我beamerouterthemetexsx.sty
按照以下方式改编了所引用的示例(参见评论):
\mode<presentation>
% Frame title
\defbeamertemplate*{frametitle}{texsx}[1][]
{
\vskip1cm%
\begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle}
\begin{tikzpicture}
\useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,1.2);
\fill[orange] (0,0) rectangle(2.95,1.2);
\fill[blue!50!cyan!80] (3.05,0) rectangle(\the\paperwidth,1.2);
% In the next part I replaced \insertframetitle by \insertsection
% In the same way I replaced \insertframesubtitle by \insertsubsection
\ifx\insertframesubtitle\@empty%
{\node[anchor=west, white,font=\large] at (3.2,0.61){\insertsection};}
\else%
{\node[anchor= west, white,font=\large] at (3.2,0.81){\insertsection};%
\node[anchor= west, white,font=\small] at
(3.2,0.41){\insertsubsection};}%
\fi
\end{tikzpicture}
\end{beamercolorbox}
}
\mode<all>
我的文档的来源如下:
\documentclass[aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\title{My first attempt}
\date[today]{\today}
\author[Miguel]{Miguel Alvarez}
% use custom theme
\usetheme{texsx}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\section{The first lesson}
\subsection{Before the first break}
\begin{frame}
Blank frame
\end{frame}
\begin{frame}{auto}
Frame with title
\end{frame}
\begin{frame}{auto}{auto}
Frame with title and sub-title
\end{frame}
\end{document}
有没有一种简单的方法可以自动获取幻灯片中的标题和副标题,而\begin{frame}
无需设置框架标题和副标题,无论如何都不会使用(如\begin{frame}{auto}{auto}
)?
换句话说,对于代码
\begin{frame}
Blank frame
\end{frame}
我有:
但我期望的是: