From a87cb88cd3f8c534a8ff133833c6349022ca4356 Mon Sep 17 00:00:00 2001 From: Ross Churchley Date: Sat, 6 Feb 2016 20:43:18 -0800 Subject: [PATCH] Move titleformat options to font theme --- source/beamerfontthememetropolis.dtx | 216 ++++++++++++++++++++++++++ source/beamerinnerthememetropolis.dtx | 132 +--------------- source/beamerouterthememetropolis.dtx | 81 +--------- source/beamerthememetropolis.dtx | 9 +- 4 files changed, 226 insertions(+), 212 deletions(-) diff --git a/source/beamerfontthememetropolis.dtx b/source/beamerfontthememetropolis.dtx index 177ac3c..382341d 100644 --- a/source/beamerfontthememetropolis.dtx +++ b/source/beamerfontthememetropolis.dtx @@ -34,6 +34,7 @@ \RequirePackage{etoolbox} \RequirePackage{ifxetex} \RequirePackage{ifluatex} +\RequirePackage{pgfopts} % \end{macrocode} % % \subsubsection{Load Fira font} @@ -159,6 +160,221 @@ series=\normalfont} % \end{macrocode} % +% +% +% \subsubsection{Title format options} +% +% \begin{macro}{titleformat-title} +% Controls the format of the title. +% \begin{macrocode} +\pgfkeys{ + /metropolis/font/titleformat-title/.cd, + .is choice, + regular/.code={% + \let\metropolis@titleformat\@empty% + \setbeamerfont{title}{shape=\normalfont}% + }, + smallcaps/.code={% + \let\metropolis@titleformat\@empty% + \setbeamerfont{title}{shape=\scshape}% + }, + allsmallcaps/.code={% + \let\metropolis@titleformat\lowercase% + \setbeamerfont{title}{shape=\scshape}% + \PackageWarning{beamerthememetropolis}{% + Be aware that titleformat-title=allsmallcaps can lead to problems% + } + }, + allcaps/.code={% + \let\metropolis@titleformat\uppercase% + \setbeamerfont{title}{shape=\normalfont} + \PackageWarning{beamerthememetropolis}{% + Be aware that titleformat-title=allcaps can lead to problems% + } + }, +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{titleformat-subtitle} +% Control the format of the subtitle. +% \begin{macrocode} +\pgfkeys{ + /metropolis/font/titleformat-subtitle/.cd, + .is choice, + regular/.code={% + \let\metropolis@subtitleformat\@empty% + \setbeamerfont{subtitle}{shape=\normalfont}% + }, + smallcaps/.code={% + \let\metropolis@subtitleformat\@empty% + \setbeamerfont{subtitle}{shape=\scshape}% + }, + allsmallcaps/.code={% + \let\metropolis@subtitleformat\lowercase% + \setbeamerfont{subtitle}{shape=\scshape}% + \PackageWarning{beamerthememetropolis}{% + Be aware that titleformat-subtitle=allsmallcaps can lead to problems% + } + }, + allcaps/.code={% + \let\metropolis@subtitleformat\uppercase% + \setbeamerfont{subtitle}{shape=\normalfont}% + \PackageWarning{beamerthememetropolis}{% + Be aware that titleformat-subtitle=allcaps can lead to problems% + } + }, +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{titleformat-section} +% Controls the format of the section title. +% \begin{macrocode} +\pgfkeys{ + /metropolis/font/titleformat-section/.cd, + .is choice, + regular/.code={% + \let\metropolis@sectiontitleformat\@empty% + \setbeamerfont{section title}{shape=\normalfont}% + }, + smallcaps/.code={% + \let\metropolis@sectiontitleformat\@empty% + \setbeamerfont{section title}{shape=\scshape}% + }, + allsmallcaps/.code={% + \let\metropolis@sectiontitleformat\MakeLowercase% + \setbeamerfont{section title}{shape=\scshape}% + \PackageWarning{beamerthememetropolis}{% + Be aware that titleformat-section=allsmallcaps can lead to problems% + } + }, + allcaps/.code={% + \let\metropolis@sectiontitleformat\MakeUppercase% + \setbeamerfont{section title}{shape=\normalfont}% + \PackageWarning{beamerthememetropolis}{% + Be aware that titleformat-section=allcaps can lead to problems% + } + }, +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{frametitleformat} +% Control the format of the frame title. +% \begin{macrocode} +\pgfkeys{ + /metropolis/font/titleformat-frame/.cd, + .is choice, + regular/.code={% + \let\metropolis@frametitleformat\@empty% + \setbeamerfont{frametitle}{shape=\normalfont}% + }, + smallcaps/.code={% + \let\metropolis@frametitleformat\@empty% + \setbeamerfont{frametitle}{shape=\scshape}% + }, + allsmallcaps/.code={% + \let\metropolis@frametitleformat\MakeLowercase% + \setbeamerfont{frametitle}{shape=\scshape}% + \PackageWarning{beamerthememetropolis}{% + Be aware that titleformat-frame=allsmallcaps can lead to problems% + } + }, + allcaps/.code={% + \let\metropolis@frametitleformat\MakeUppercase% + \setbeamerfont{frametitle}{shape=\normalfont} + \PackageWarning{beamerthememetropolis}{% + Be aware that titleformat-frame=allcaps can lead to problems% + } + }, +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\metropolis@font@setdefaults} +% Sets default values for font theme options. +% \begin{macrocode} +\newcommand{\metropolis@font@setdefaults}{ + \pgfkeys{/metropolis/font/.cd, + titleformat-title=regular, + titleformat-subtitle=regular, + titleformat-section=regular, + titleformat-frame=regular, + } +} +% \end{macrocode} +% \end{macro} +% +% We first define hooks to change the case format of the titles. +% +% \begin{macrocode} +\def\metropolis@titleformat#1{#1} +\def\metropolis@subtitleformat#1{#1} +\def\metropolis@sectiontitleformat#1{#1} +\def\metropolis@frametitleformat#1{#1} +% \end{macrocode} +% +% To make the uppercase and lowercase macros work in the title, subtitle, etc., +% we have to patch the appropriate |beamer| commands that set their values. +% This solution was suggested by Enrico Gregorio in an answer to +% \href{http://tex.stackexchange.com/questions/112526/}{this StackExchange +% question}. +% +% \begin{macrocode} +\patchcmd{\beamer@title}% + {\def\inserttitle{#2}}% + {\def\inserttitle{\metropolis@titleformat{#2}}}% + {}% + {\PackageError{beamerfontthememetropolis}{Patching title failed}} +\patchcmd{\beamer@subtitle}% + {\def\insertsubtitle{#2}}% + {\def\insertsubtitle{\metropolis@subtitleformat{#2}}}% + {}% + {\PackageError{beamerfontthememetropolis}{Patching subtitle failed}} +\patchcmd{\sectionentry} + {\def\insertsectionhead{#2}} + {\def\insertsectionhead{\metropolis@sectiontitleformat{#2}}} + {} + {\PackageError{beamerfontthememetropolis}{Patching section title failed}} +\patchcmd{\beamer@section} + {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}} + {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{% + \metropolis@sectiontitleformat{#1}}}} + {} + {\PackageError{beamerfontthememetropolis}{Patching section title failed}} +% \end{macrocode} +% +% Similarly, to make the |\MakeLowercase| and |\MakeUppercase| macros work in +% the frame title we have to patch |\beamer@@frametitle|. +% +% \begin{macrocode} +\patchcmd{\beamer@@frametitle} + {\beamer@ifempty{#2}{}{% + \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space% + \usebeamertemplate*{frametitle continuation}\fi}}% + \gdef\beamer@frametitle{#2}% + \gdef\beamer@shortframetitle{#1}% + }} + {\beamer@ifempty{#2}{}{% + \gdef\insertframetitle{{\metropolis@frametitleformat{#2}\ifnum% + \beamer@autobreakcount>0\relax{}\space% + \usebeamertemplate*{frametitle continuation}\fi}}% + \gdef\beamer@frametitle{#2}% + \gdef\beamer@shortframetitle{#1}% + }} + {} + {\PackageError{beamerfontthememetropolis}{Patching frame title failed}} +% \end{macrocode} +% +% +% +% \subsubsection{Process package options} +% +% \begin{macrocode} +\metropolis@font@setdefaults +\ProcessPgfPackageOptions{/metropolis/font} +% \end{macrocode} % \iffalse % % \fi diff --git a/source/beamerinnerthememetropolis.dtx b/source/beamerinnerthememetropolis.dtx index 70f2538..175cf0a 100644 --- a/source/beamerinnerthememetropolis.dtx +++ b/source/beamerinnerthememetropolis.dtx @@ -64,102 +64,6 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{titleformat-title} -% Control the titleformat of the title -% \begin{macrocode} -\pgfkeys{ - /metropolis/inner/titleformat-title/.cd, - .is choice, - regular/.code={% - \let\metropolis@titleformat\@empty% - \setbeamerfont{title}{shape=\normalfont}% - }, - smallcaps/.code={% - \let\metropolis@titleformat\@empty% - \setbeamerfont{title}{shape=\scshape}% - }, - allsmallcaps/.code={% - \let\metropolis@titleformat\MakeLowercase% - \setbeamerfont{title}{shape=\scshape}% - \PackageWarning{beamerthememetropolis}{% - Be aware that titleformat-title=allsmallcaps can lead to problems% - } - }, - allcaps/.code={% - \let\metropolis@titleformat\MakeUppercase% - \setbeamerfont{title}{shape=\normalfont} - \PackageWarning{beamerthememetropolis}{% - Be aware that titleformat-title=allcaps can lead to problems% - } - }, -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{titleformat-subtitle} -% Control the titleformat of the subtitle -% \begin{macrocode} -\pgfkeys{ - /metropolis/inner/titleformat-subtitle/.cd, - .is choice, - regular/.code={% - \let\metropolis@subtitleformat\@empty% - \setbeamerfont{subtitle}{shape=\normalfont}% - }, - smallcaps/.code={% - \let\metropolis@subtitleformat\@empty% - \setbeamerfont{subtitle}{shape=\scshape}% - }, - allsmallcaps/.code={% - \let\metropolis@subtitleformat\MakeLowercase% - \setbeamerfont{subtitle}{shape=\scshape}% - \PackageWarning{beamerthememetropolis}{% - Be aware that titleformat-subtitle=allsmallcaps can lead to problems% - } - }, - allcaps/.code={% - \let\metropolis@subtitleformat\MakeUppercase% - \setbeamerfont{subtitle}{shape=\normalfont}% - \PackageWarning{beamerthememetropolis}{% - Be aware that titleformat-subtitle=allcaps can lead to problems% - } - }, -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{titleformat-section} -% Control the titleformat of the section title -% \begin{macrocode} -\pgfkeys{ - /metropolis/inner/titleformat-section/.cd, - .is choice, - regular/.code={% - \let\metropolis@sectiontitleformat\@empty% - \setbeamerfont{section title}{shape=\normalfont}% - }, - smallcaps/.code={% - \let\metropolis@sectiontitleformat\@empty% - \setbeamerfont{section title}{shape=\scshape}% - }, - allsmallcaps/.code={% - \let\metropolis@sectiontitleformat\MakeLowercase% - \setbeamerfont{section title}{shape=\scshape}% - \PackageWarning{beamerthememetropolis}{% - Be aware that titleformat-section=allsmallcaps can lead to problems% - } - }, - allcaps/.code={% - \let\metropolis@sectiontitleformat\MakeUppercase% - \setbeamerfont{section title}{shape=\normalfont}% - \PackageWarning{beamerthememetropolis}{% - Be aware that titleformat-section=allcaps can lead to problems% - } - }, -} -% \end{macrocode} -% \end{macro} -% % \begin{macro}{sectionpage} % The |sectionpage| option defines the behaviour of the sectionpage. % \begin{macrocode} @@ -180,9 +84,6 @@ \pgfkeys{/metropolis/inner/.cd, sectionpage=progressbar, block=transparent, - titleformat-title=regular, - titleformat-subtitle=regular, - titleformat-section=regular, } } % \end{macrocode} @@ -192,35 +93,6 @@ % % \subsubsection{Title page} % -% \begin{macro}{\metropolis@titleformat} -% Define hooks to change the case format of the titles. -% \begin{macrocode} -\def\metropolis@titleformat#1{#1} -\def\metropolis@subtitleformat#1{#1} -\def\metropolis@sectiontitleformat#1{#1} -% \end{macrocode} -% \end{macro} -% -% To make the |\MakeLowercase| and |\MakeUppercase| macros work in the -% sectiontitle we have to patch |\sectionentry| and |\beamer@section|. This -% solution was suggested by Enrico Gregorio in an answer to -% \href{http://tex.stackexchange.com/questions/112526/}{this StackExchange -% question}. -% -% \begin{macrocode} -\patchcmd{\sectionentry} - {\def\insertsectionhead{#2}} - {\def\insertsectionhead{\metropolis@sectiontitleformat{#2}}} - {} - {\PackageError{beamerinnerthememetropolis}{Patching section title failed}} -\patchcmd{\beamer@section} - {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}} - {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{% - \metropolis@sectiontitleformat{#1}}}} - {} - {\PackageError{beamerinnerthememetropolis}{Patching section title failed}} -% \end{macrocode} -% % \begin{macro}{title page} % Template for the title page. Each element is only typset if it is defined % by the user. If |\subtitle| is empty, for example, it won't leave a blank @@ -298,7 +170,7 @@ \setbeamertemplate{title}{ \raggedright% \linespread{1.0}% - \metropolis@titleformat{\inserttitle}% + \inserttitle% \par% \vspace*{0.5em} } @@ -309,7 +181,7 @@ % Set the subtitle on the title page. % \begin{macrocode} \setbeamertemplate{subtitle}{ - \metropolis@subtitleformat{\insertsubtitle}% + \insertsubtitle% \par% \vspace*{0.5em} } diff --git a/source/beamerouterthememetropolis.dtx b/source/beamerouterthememetropolis.dtx index 14a3656..c85a82e 100644 --- a/source/beamerouterthememetropolis.dtx +++ b/source/beamerouterthememetropolis.dtx @@ -86,50 +86,6 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{frametitleformat} -% Control the titleformat of the frame title -% \begin{macrocode} -\pgfkeys{ - /metropolis/outer/titleformat-frame/.cd, - .is choice, - regular/.code={% - \let\metropolis@frametitleformat\@empty% - \setbeamerfont{frametitle}{shape=\normalfont}% - \renewcommand{\metropolis@frametitlestrut}{% - \vphantom{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}% - } - }, - smallcaps/.code={% - \let\metropolis@frametitleformat\@empty% - \setbeamerfont{frametitle}{shape=\scshape}% - \renewcommand{\metropolis@frametitlestrut}{% - \vphantom{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}% - } - }, - allsmallcaps/.code={% - \let\metropolis@frametitleformat\MakeLowercase% - \setbeamerfont{frametitle}{shape=\scshape}% - \renewcommand{\metropolis@frametitlestrut}{% - \vphantom{abcdefghijklmnopqrstuvwxyz}% - } - \PackageWarning{beamerthememetropolis}{% - Be aware that titleformat-frame=allsmallcaps can lead to problems% - } - }, - allcaps/.code={% - \let\metropolis@frametitleformat\MakeUppercase% - \setbeamerfont{frametitle}{shape=\normalfont} - \renewcommand{\metropolis@frametitlestrut}{% - \vphantom{ABCDEFGHIJKLMNOPQRSTUVWXYZ}% - } - \PackageWarning{beamerthememetropolis}{% - Be aware that titleformat-frame=allcaps can lead to problems% - } - }, -} -% \end{macrocode} -% \end{macro} -% % \begin{macro}{\metropolis@outer@setdefaults} % Set default values for outer theme options. % \begin{macrocode} @@ -137,7 +93,6 @@ \pgfkeys{/metropolis/outer/.cd, numbering=counter, progressbar=none, - titleformat-frame=regular, } } % \end{macrocode}% @@ -180,45 +135,15 @@ % % \subsubsection{Frametitle} % -% \begin{macro}{\metropolis@frametitleformat} -% Define a hook to change the case format of the frame title. -% \begin{macrocode} -\def\metropolis@frametitleformat#1{#1} -% \end{macrocode} -% \end{macro} -% -% To make the |\MakeLowercase| and |\MakeUppercase| macros work in the -% frame title we have to patch |\beamer@@frametitle|. This solution was -% suggested by Enrico Gregorio in an answer to -% \href{http://tex.stackexchange.com/questions/112526/}{this StackExchange -% question}. -% -% \begin{macrocode} -\patchcmd{\beamer@@frametitle} - {\beamer@ifempty{#2}{}{% - \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space% - \usebeamertemplate*{frametitle continuation}\fi}}% - \gdef\beamer@frametitle{#2}% - \gdef\beamer@shortframetitle{#1}% - }} - {\beamer@ifempty{#2}{}{% - \gdef\insertframetitle{{\metropolis@frametitleformat{#2}\ifnum% - \beamer@autobreakcount>0\relax{}\space% - \usebeamertemplate*{frametitle continuation}\fi}}% - \gdef\beamer@frametitle{#2}% - \gdef\beamer@shortframetitle{#1}% - }} - {} - {\PackageError{beamerouterthememetropolis}{Patching frame title failed}} -% \end{macrocode} -% % \begin{macro}{frametitle} % % Templates for the frame title, which is optionally underlined with a % progress bar. % % \begin{macrocode} -\newlength{\metropolis@frametitlestrut} +\newcommand{\metropolis@frametitlestrut}{ + \vphantom{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz()}% +} \defbeamertemplate{frametitle}{plain}{% \nointerlineskip% \begin{beamercolorbox}[% diff --git a/source/beamerthememetropolis.dtx b/source/beamerthememetropolis.dtx index 608e450..4bfad45 100644 --- a/source/beamerthememetropolis.dtx +++ b/source/beamerthememetropolis.dtx @@ -56,6 +56,7 @@ /metropolis/inner, /metropolis/outer, /metropolis/color, + /metropolis/font, }, % \end{macrocode} % @@ -106,10 +107,10 @@ % \begin{macrocode} \pgfkeys{ /metropolis/titleformat/.code=\pgfkeysalso{ - inner/titleformat-title=#1, - inner/titleformat-subtitle=#1, - inner/titleformat-section=#1, - outer/titleformat-frame=#1, + font/titleformat-title=#1, + font/titleformat-subtitle=#1, + font/titleformat-section=#1, + font/titleformat-frame=#1, titleformat-plain=#1, } }