My objective is to assign custom styles to specific frames tagged with the [fancy] key, particularly font family, font colors, and background color. I was able to associate a background color with the key, but had less success when trying the same gymnastics with fonts. My desired result is to be able to just write:
\begin{frame}[fancy]
\frametitle{fancy title with fancy font and colors}
fancy background, fonts, and colors
\end{frame}
My current workaround is to define a custom frame and custom frametitle command (fancyframe and fancyframetitle), but I'd prefer to control styles with a simple fancy tag (easier to turn on and off).
The following code is an attempt to weave together bits and pieces from the beamer code. The background color appears to work, but the fonts and colors either leak or don't get applied in the right place. The output is a sorry mess.
\documentclass[xcolor={usenames,dvipsnames}]{beamer}
\usepackage{lipsum}
\usepackage[T1]{fontenc}
\usepackage{pgfpages}
\pgfpagesuselayout{4 on 1}[border shrink=2mm]
% default options for presentation
\mode<presentation>
{
\setbeamercolor{frametitle}{bg=white,fg=Green}
\setbeamertemplate{itemize item}{$-$}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}[pagenumber,split]
}
% define some special font for fancy frames
\usepackage{fontspec,unicode-math}
\newfontfamily\myfontfamily{augie}
% set default frame style
\defbeamertemplate*{background canvas}{mydefault}
{%
\ifbeamercolorempty[bg]{background canvas}{}{\color{bg}\vrule width\paperwidth height\paperheight}% beamer default
}
% reset the default frame styles... doing this wrong?
\BeforeBeginEnvironment{frame}{%
\setbeamertemplate{background canvas}[mydefault]%
\usebeamerfont{normal text}
}
% set background color for fancy frames
\defbeamertemplate*{background canvas}{fancy}
{%
\color{lightgray!50}\vrule width\paperwidth height\paperheight% background color added
}
% define the fancy key
\makeatletter
\define@key{beamerframe}{fancy}[true]{%
\setbeamercovered{invisible}
\setbeamertemplate{background canvas}[fancy]
\setbeamerfont{normal text}{family={\myfontfamily}}% leaks
\setbeamertemplate{itemize item}{$\blacktriangleright$}% leaks
\setbeamertemplate{frametitle}{\color{Red}\textbf{\insertframetitle}}% leaks
}
\makeatother
% workaround: custom frame title | likewise could make custom frames, but don't want to...
\newcommand{\fancyframetitle}[1]{\textcolor{NavyBlue}{\myfontfamily\Large#1}\vspace{0.05\paperheight}\par}
\begin{document}
\begin{frame}
\frametitle{Normal Frame (Green Title, Normal Font)}
\lipsum[11]
\begin{itemize}
\item \lipsum[11]
\end{itemize}
\end{frame}
\begin{frame}[fancy]
\frametitle{Fancy Frame (Red Title, Fancy Font)}
\lipsum[11]
\begin{itemize}
\item \lipsum[11]
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Normal Frame (Green Title, Normal Font)}
\lipsum[11]
\begin{itemize}
\item \lipsum[11]
\end{itemize}
\end{frame}
\begin{frame}[fancy]
\fancyframetitle{Fancy Frame (Blue Title, Fancy Font)}
\lipsum[11]
\begin{itemize}
\item \lipsum[11]
\end{itemize}
\end{frame}
\end{document}
Result of the failed experiment: styles leak or don't get applied where intended.


xelatex, do you recommend I switch tolualatex? Thanks! – PatrickT Aug 26 '22 at 04:55