Merge pull request #98 from benjamin-weiss/pgfkeys-based-options

Pgfkeys based options
This commit is contained in:
Matthias Vogelgesang 2015-07-01 09:39:44 +02:00
commit 1e8b3749f0
10 changed files with 624 additions and 298 deletions

View File

@ -1,28 +1,26 @@
INS = mtheme.ins
CONTRIB_SRC = contributors.py
CONTRIB_TEX = contributors.tex
DTX = $(wildcard *.dtx)
STY = $(patsubst %.dtx,%.sty,$(wildcard beamer*.dtx pgfplotsthemetol.dtx))
TEXMFHOME = $(shell kpsewhich -var-value=TEXMFHOME)
INSTALL_DIR = $(TEXMFHOME)/tex/latex/mtheme
MANUAL_DIR = $(TEXMFHOME)/doc/latex/mtheme
DOC_DIR = $(TEXMFHOME)/doc/latex/mtheme
TEMP_DIR = .temptex
INS = mtheme.ins
DEMO_SRC = demo.tex
DEMO_PDF = demo.pdf
MANUAL_SRC = mtheme.dtx
MANUAL_PDF = mtheme.pdf
TEXC := latexmk -xelatex -output-directory=$(TEMP_DIR)
DOC_SRC = mtheme.dtx
DOC_PDF = mtheme.pdf
DTX = $(wildcard *.dtx)
STY = $(patsubst %.dtx,%.sty,$(wildcard beamer*.dtx pgfplotsthemetol.dtx))
CTAN_CONTENT = $(INS) $(DTX) $(DOC_PDF)
CTAN_CONTENT = $(INS) $(DTX) $(MANUAL_PDF)
TEXC := latexmk -xelatex -output-directory=$(TEMP_DIR)
DOCKER_IMAGE = latex-image
DOCKER_CONTAINER = latex-container
.PHONY: sty manual demo ctan clean install uninstall docker-run docker-build docker-rm
.PHONY: sty doc demo ctan clean install uninstall docker-run docker-build docker-rm
all: sty manual demo
all: sty doc demo
$(STY): $(DTX) $(INS)
@latex $(INS)
@ -31,13 +29,13 @@ $(DEMO_PDF): $(STY) $(DEMO_SRC)
$(TEXC) $(DEMO_SRC)
@cp $(TEMP_DIR)/$(DEMO_PDF) .
$(MANUAL_PDF): $(MANUAL_SRC)
@$(TEXC) $(MANUAL_SRC)
@cp $(TEMP_DIR)/$(MANUAL_PDF) .
$(DOC_PDF): $(DOC_SRC) $(DTX)
@$(TEXC) $(DOC_SRC)
@cp $(TEMP_DIR)/$(DOC_PDF) .
sty: $(STY)
manual: $(MANUAL_PDF)
doc: $(DOC_PDF)
demo: $(DEMO_PDF)
@ -50,17 +48,17 @@ ctan: $(CTAN_CONTENT)
clean:
@git clean -xfd
install: $(STY) $(MANUAL_PDF)
install: $(STY) $(DOC_PDF)
@mkdir -p $(INSTALL_DIR)
@cp $(STY) $(INSTALL_DIR)
@mkdir -p $(MANUAL_DIR)
@cp $(MANUAL_PDF) $(MANUAL_DIR)
@mkdir -p $(DOC_DIR)
@cp $(DOC_PDF) $(DOC_DIR)
uninstall:
@rm -f $(addprefix $(INSTALL_DIR)/, $(STY))
@rm -f $(MANUAL_DIR)/$(MANUAL_PDF)
@rm -f $(DOC_DIR)/$(DOC_PDF)
@rmdir $(INSTALL_DIR)
@rmdir $(MANUAL_DIR)
@rmdir $(DOC_DIR)
docker-run: docker-build
docker run --rm=true --name $(DOCKER_CONTAINER) -i -t -v `pwd`:/data $(DOCKER_IMAGE) make

View File

@ -27,32 +27,58 @@
% \iffalse
%<*package>
% ------------------------------------------------------------------------- \fi
% \section{Implementation: \textsc{metropolis} color theme}
% Options
%
% \subsection{\textsc{metropolis} color theme}
%
% darkcolors
%
% Load required packages.
% \begin{macrocode}
\newif\if@beamer@metropolis@darkcolors
\@beamer@metropolis@darkcolorsfalse
\DeclareOptionBeamer{darkcolors}{
\@beamer@metropolis@darkcolorstrue
}
% \end{macrocode}
%
% Unknown option error handling
%
% \begin{macrocode}
\DeclareOptionBeamer*{%
\PackageWarning{beamercolorthememetropolis}{Unknown option `\CurrentOption'}%
}
\ProcessOptionsBeamer
\RequirePackage{pgfopts}
% \end{macrocode}
%
%
%
% \subsection{Base colors}
% \subsubsection{Options}
%
% \begin{macro}{block}
% This option controls whether the blocks are filled or transparent.
% \begin{macrocode}
\pgfkeys{
/metropolis/color/block/.cd,
.is choice,
transparent/.code=\@metropolis@block@transparent,
fill/.code=\@metropolis@block@fill,
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{colors}
% Defines whether the background shall be dark and the foreground be light or
% vice versa
% \begin{macrocode}
\pgfkeys{
/metropolis/color/background/.cd,
.is choice,
dark/.code=\@metropolis@colors@dark,
light/.code=\@metropolis@colors@light,
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@metropolis@color@setdefaults}
% Set default values for color theme options.
% \begin{macrocode}
\newcommand{\@metropolis@color@setdefaults}{
\pgfkeys{/metropolis/color/.cd,
background=light,
block=transparent,
}
}
% \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Base colors}
%
% \begin{macrocode}
\definecolor{mDarkBrown}{HTML}{604c38}
@ -63,23 +89,24 @@
%
%
%
% \subsection{Base styles}
% \subsubsection{Base styles}
%
% All colors in the \textsc{metropolis} theme are derived from the definitions
% of |normal text|, |alerted text|, and |example text|.
%
% \begin{macrocode}
\if@beamer@metropolis@darkcolors
\newcommand{\@metropolis@colors@dark}{
\setbeamercolor{normal text}{%
fg=black!2,
bg=mDarkTeal
}
\else
}
\newcommand{\@metropolis@colors@light}{
\setbeamercolor{normal text}{%
fg=mDarkTeal,
bg=black!2
}
\fi
}
\setbeamercolor{alerted text}{%
fg=mLightBrown
}
@ -89,12 +116,8 @@
% \end{macrocode}
%
%
% \begin{macrocode}
% \end{macrocode}
%
%
%
% \subsection{Derived colors}
% \subsubsection{Derived colors}
%
% The titles and structural elements (e.g. |itemize| bullets) are set in the
% same color as |normal text|. This would ideally done by setting |normal text|
@ -130,9 +153,9 @@
%
% The \textsc{metropolis} inner or outer themes optionally display progress
% bars in various locations. Their color is set by |progress bar| but the two
% different kinds can be customized separately. The horizontal rule on the title
% page is also set based on the progress bar color and can be customized with
% |title separator|.
% different kinds can be customized separately. The horizontal rule on the
% title page is also set based on the progress bar color and can be customized
% with |title separator|.
%
% \begin{macrocode}
\setbeamercolor{progress bar}{%
@ -157,15 +180,16 @@
% Blocks
%
% \begin{macrocode}
\if@beamer@metropolis@blockbg
\newcommand{\@metropolis@block@transparent}{
\setbeamercolor{block title}{use=normal text, parent=normal text}
}
\newcommand{\@metropolis@block@fill}{
\setbeamercolor{block title}{%
use=normal text,
fg=normal text.fg,
bg=normal text.bg!80!fg
}
\else
\setbeamercolor{block title}{use=normal text, parent=normal text}
\fi
}
\setbeamercolor{block title alerted}{%
use={block title, alerted text},
bg=block title.bg,
@ -189,10 +213,18 @@
% \begin{macrocode}
\setbeamercolor{footnote}{fg=normal text.fg!90}
\setbeamercolor{footnote mark}{fg=.}
\mode<all>
% \end{macrocode}
%
% Process package options
%
% \begin{macrocode}
\@metropolis@color@setdefaults
\ProcessPgfPackageOptions{/metropolis/color}
% \end{macrocode}
%
% \begin{macrocode}
\mode<all>
% \end{macrocode}
%
% \iffalse
%</package>

View File

@ -27,7 +27,7 @@
% \iffalse
%<*package>
% ------------------------------------------------------------------------- \fi
% \section{Implementation: Fira font theme}
% \subsection{Fira font theme}
% Font Definitions
%
% \begin{macrocode}

View File

@ -27,7 +27,8 @@
% \iffalse
%<*package>
% ------------------------------------------------------------------------- \fi
% \section{Implementation: \textsc{metropolis} inner theme}
%
% \subsection{\textsc{metropolis} inner theme}
%
% A |beamer| inner theme dictates the style of the frame elements traditionally
% set in the ``body'' of each slide. These include:
@ -40,14 +41,124 @@
% \item footnotes and plain text.
% \end{itemize}
%
% \subsection{Title page}
% Load required packages.
% \begin{macrocode}
\RequirePackage{etoolbox}
\RequirePackage{calc}
\RequirePackage{pgfopts}
\RequirePackage{tikz}
% \end{macrocode}
%
% \begin{macro}{title page}
%
% Template for the title page.
%
% \subsubsection{Options}
%
% \begin{macro}{block}
% This option controls the block style.
% \begin{macrocode}
\pgfkeys{
/metropolis/inner/block/.cd,
.is choice,
transparent/.code=\setlength{\@metropolis@blockskip}{0ex},
fill/.code=\setlength{\@metropolis@blockskip}{1ex},
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{titleformat}
% Control the case style of the title
% \begin{macrocode}
\pgfkeys{
/metropolis/inner/titleformat/.cd,
.is choice,
regular/.code=\renewcommand{\@metropolis@titleformat}{},
lowercase/.code={%
\renewcommand{\@metropolis@titleformat}{\MakeLowercase}
},
uppercase/.code={%
\renewcommand{\@metropolis@titleformat}{\MakeUppercase}
},
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{sectiontitleformat}
% Control the case style of the section title
% \begin{macrocode}
\pgfkeys{
/metropolis/inner/sectiontitleformat/.cd,
.is choice,
regular/.code=\renewcommand{\@metropolis@sectiontitleformat}{},
lowercase/.code={%
\renewcommand{\@metropolis@sectiontitleformat}{\MakeLowercase}
},
uppercase/.code={%
\renewcommand{\@metropolis@sectiontitleformat}{\MakeUppercase}
},
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{sectionpage}
% The |sectionpage| option defines the behaviour of the sectionpage.
% \begin{macrocode}
\pgfkeys{
/metropolis/inner/sectionpage/.cd,
.is choice,
none/.code=\@metropolis@sectionpage@none,
progressbar/.code=\@metropolis@sectionpage@progressbar,
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@metropolis@inner@setdefaults}
% Set default values for inner theme options.
% \begin{macrocode}
\newcommand{\@metropolis@inner@setdefaults}{
\pgfkeys{/metropolis/inner/.cd,
sectionpage=progressbar,
block=transparent,
titleformat=lowercase,
sectiontitleformat=lowercase,
}
}
% \end{macrocode}
% \end{macro}
%
%
%
% \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@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}
\RequirePackage{tikz}
\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.
% \begin{macrocode}
\setbeamertemplate{title page}{
\begin{minipage}[b][\paperheight]{\textwidth}
% \end{macrocode}
@ -78,7 +189,7 @@
\linespread{1.0}%
\usebeamerfont{title}%
\usebeamercolor[fg]{title}%
\mthemetitleformat{\inserttitle}%
\@metropolis@titleformat{\inserttitle}%
\par%
\vspace*{0.5em}
}}
@ -177,14 +288,19 @@
%
%
%
% \subsection{Section page}
% \subsubsection{Section page}
%
% \begin{macro}{section page}
%
% Template for the section title slide at the beginning of each section.
%
% \begin{macrocode}
\setbeamertemplate{section page}{
\newcommand{\@metropolis@sectionpage@none}{
\AtBeginSection{
% intenionally empty
}
}
\defbeamertemplate{section page}{progressbar}{
\vspace{2em}
\centering
\begin{minipage}{22em}
@ -195,7 +311,8 @@
\end{minipage}
\par
}
\if@noSectionSlide\else%
\newcommand{\@metropolis@sectionpage@progressbar}{
\setbeamertemplate{section page}[progressbar]
\AtBeginSection{
\ifbeamer@inframe
\sectionpage
@ -203,7 +320,7 @@
\frame[plain,c]{\sectionpage}
\fi
}
\fi
}
% \end{macrocode}
% \end{macro}
%
@ -214,7 +331,6 @@
% |progress bar in head/foot|.
%
% \begin{macrocode}
\RequirePackage{calc}
\newlength{\metropolis@progressonsectionpage}
\setbeamertemplate{progress bar in section page}{
\setlength{\metropolis@progressonsectionpage}{%
@ -244,30 +360,27 @@
%
%
%
% \subsection{Block environments}
% \subsubsection{Block environments}
%
% Regular block environment
%
% \begin{macrocode}
\newlength{\leftrightskip}
\if@beamer@metropolis@blockbg
\setlength{\leftrightskip}{1ex}
\else
\setlength{\leftrightskip}{0ex}
\fi
\newlength{\@metropolis@blockskip}
\setbeamertemplate{block begin}{%
\vspace*{1ex}
\begin{beamercolorbox}[%
ht=2.4ex,
dp=1ex,
leftskip=\leftrightskip,
rightskip=\leftrightskip]{block title}
leftskip=\@metropolis@blockskip,
rightskip=\@metropolis@blockskip]{block title}
\usebeamerfont*{block title}\insertblocktitle%
\end{beamercolorbox}%
\vspace*{-1pt}
\usebeamerfont{block body}%
\begin{beamercolorbox}[%
dp=1ex,
leftskip=\leftrightskip,
rightskip=\leftrightskip,
leftskip=\@metropolis@blockskip,
rightskip=\@metropolis@blockskip,
vmode]{block body}%
}
\setbeamertemplate{block end}{%
@ -284,16 +397,16 @@
\begin{beamercolorbox}[%
ht=2.4ex,
dp=1ex,
leftskip=\leftrightskip,
rightskip=\leftrightskip]{block title alerted}
leftskip=\@metropolis@blockskip,
rightskip=\@metropolis@blockskip]{block title alerted}
\usebeamerfont*{block title alerted}\insertblocktitle%
\end{beamercolorbox}%
\vspace*{-1pt}
\usebeamerfont{block body alerted}%
\begin{beamercolorbox}[%
dp=1ex,
leftskip=\leftrightskip,
rightskip=\leftrightskip,
leftskip=\@metropolis@blockskip,
rightskip=\@metropolis@blockskip,
vmode]{block body}%
}
\setbeamertemplate{block alerted end}{%
@ -310,16 +423,16 @@
\begin{beamercolorbox}[%
ht=2.4ex,
dp=1ex,
leftskip=\leftrightskip,
rightskip=\leftrightskip]{block title example}
leftskip=\@metropolis@blockskip,
rightskip=\@metropolis@blockskip]{block title example}
\usebeamerfont*{block title example}\insertblocktitle%
\end{beamercolorbox}%
\vspace*{-1pt}
\usebeamerfont{block body example}%
\begin{beamercolorbox}[%
dp=1ex,
leftskip=\leftrightskip,
rightskip=\leftrightskip,
leftskip=\@metropolis@blockskip,
rightskip=\@metropolis@blockskip,
vmode]{block body}%
}
\setbeamertemplate{block example end}{%
@ -330,7 +443,7 @@
%
%
%
% \subsection{Itemize/enumerate environments}
% \subsubsection{Itemize/enumerate environments}
% \begin{macrocode}
\setlength{\leftmargini}{1em}
\setlength{\leftmarginii}{1em}
@ -340,13 +453,17 @@
\setbeamertemplate{itemize subsubitem}{\textbullet}
% \end{macrocode}
%
% \subsection{Figures and tables}
%
%
% \subsubsection{Figures and tables}
% \begin{macrocode}
\setbeamertemplate{caption label separator}{: }
\setbeamertemplate{caption}[numbered]
% \end{macrocode}
%
% \subsection{Footnotes}
%
%
% \subsubsection{Footnotes}
% \begin{macrocode}
\setbeamertemplate{footnote}{%
\parindent 0em\noindent%
@ -355,14 +472,21 @@
}
% \end{macrocode}
%
% \subsection{General text}
%
%
% \subsubsection{General text settings}
% \begin{macrocode}
\mode<all>
\setlength{\parskip}{0.5em}
\linespread{1.15}
% \end{macrocode}
%
% Process package options
%
% \begin{macrocode}
\@metropolis@inner@setdefaults
\ProcessPgfPackageOptions{/metropolis/inner}
% \end{macrocode}
%
% \iffalse
%</package>

View File

@ -27,21 +27,93 @@
% \iffalse
%<*package>
% ------------------------------------------------------------------------- \fi
% \section{Implementation: \textsc{metropolis} outer theme}
%
% \subsection{\textsc{metropolis} outer theme}
%
% A |beamer| outer theme dictates the style of the frame elements traditionally
% set outside the body of each slide: the head, footline, and frame title.
%
%
%
% This customization will be removed in a future version.
%
% Load required packages.
% \begin{macrocode}
\def\mthemetitleformat{\scshape\MakeLowercase}
\RequirePackage{etoolbox}
\RequirePackage{calc}
\RequirePackage{pgfopts}
% \end{macrocode}
%
%
% \subsection{Head and footline}
%
% \subsubsection{Options}
%
% \begin{macro}{numbering}
% This option controls the page numbering.
% \begin{macrocode}
\pgfkeys{
/metropolis/outer/numbering/.cd,
.is choice,
none/.code=\setbeamertemplate{frame numbering}[none],
counter/.code=\setbeamertemplate{frame numbering}[counter],
fraction/.code=\setbeamertemplate{frame numbering}[fraction],
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{progressbar}
% This option controls the progressbar.
% \begin{macrocode}
\pgfkeys{
/metropolis/outer/progressbar/.cd,
.is choice,
none/.code=\setbeamertemplate{frametitle}[plain],
frametitle/.code=\setbeamertemplate{frametitle}[progressbar],
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{frametitleformat}
% Control the case style of the frame title
% \begin{macrocode}
\pgfkeys{
/metropolis/outer/frametitleformat/.cd,
.is choice,
regular/.code=\renewcommand{\@metropolis@frametitleformat}{},
lowercase/.code={%
\renewcommand{\@metropolis@frametitleformat}{\MakeLowercase}
},
uppercase/.code={%
\renewcommand{\@metropolis@frametitleformat}{\MakeUppercase}
},
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{frametitleoffset}
% This option controls the frame title offset.
% \begin{macrocode}
\pgfkeys{
/metropolis/outer/.cd,
frametitleoffset/.code=\setlength{\@metropolis@voffset}{#1},
noframetitleoffset/.code=\setlength{\@metropolis@voffset}{0em},
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@metropolis@outer@setdefaults}
% Set default values for outer theme options.
% \begin{macrocode}
\newcommand{\@metropolis@outer@setdefaults}{
\pgfkeys{/metropolis/outer/.cd,
numbering=counter,
progressbar=none,
frametitleformat=lowercase,
frametitleoffset=2em,
}
}
% \end{macrocode}%
% \end{macro}
%
%
%
% \subsubsection{Head and footline}
%
% All good |beamer| presentations should already remove the navigation symbols,
% but \textsc{metropolis} removes them automatically (just in case).
@ -50,8 +122,28 @@
\setbeamertemplate{navigation symbols}{}
% \end{macrocode}
%
% The only element in the footline by default is the frame number. It can
% optionally be omitted or displayed as a fraction of the total frames.
% Template for the frame number. Can be omitted, shown or displayed as a
% fraction of the total frames.
%
% \begin{macrocode}
\defbeamertemplate{frame numbering}{none}{
% intentionally empty
}
\defbeamertemplate{frame numbering}{counter}{
\insertframenumber
}
\defbeamertemplate{frame numbering}{fraction}{
\insertframenumber/\inserttotalframenumber
}
% \end{macrocode}
%
% Define additional space between frame title and content. By default 2em.
%
% \begin{macrocode}
\newlength{\@metropolis@voffset}
% \end{macrocode}
%
% The only element in the footline by default is the frame number.
%
% \begin{macrocode}
\setbeamertemplate{footline}{%
@ -62,31 +154,52 @@
leftskip=0.3cm,
rightskip=0.3cm
]{footline}%
\hfill\usebeamerfont{page number in head/foot}%
\if@noSlideNumbers%
%Purposefully left blank to display no slide number.%
\else%
\if@useTotalSlideIndicator%
\insertframenumber/\inserttotalframenumber%
\else%
\insertframenumber%
\fi%
\fi%
\hfill\usebeamerfont{page number in head/foot}%
\usebeamertemplate*{frame numbering}
\end{beamercolorbox}%
}
% \end{macrocode}
%
%
%
% \subsection{Frametitle}
% \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}
%
% Template for the frame title, which is optionally underlined with a
% progress bar.
% Templates for the frame title, which is optionally underlined with a
% progress bar.
%
% \begin{macrocode}
\setbeamertemplate{frametitle}{%
\defbeamertemplate{frametitle}{plain}{%
\nointerlineskip
\begin{beamercolorbox}[%
wd=\paperwidth,
@ -97,29 +210,42 @@
]{frametitle}
\insertframetitle%
\end{beamercolorbox}%
\if@useTitleProgressBar
\nointerlineskip
\usebeamertemplate*{progress bar in head/foot}
\fi
\vspace{\@mtheme@voffset}
\vspace{\@metropolis@voffset}
}
\defbeamertemplate{frametitle}{progressbar}{%
\nointerlineskip
\begin{beamercolorbox}[%
wd=\paperwidth,
leftskip=0.3cm,
rightskip=0.3cm,
ht=2.5ex,
dp=1.5ex
]{frametitle}
\insertframetitle%
\end{beamercolorbox}%
\usebeamertemplate*{progress bar in head/foot}
\vspace{\@metropolis@voffset}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{progress bar in head/foot}
%
% Template for the progress bar optionally displayed below the frame title
% on each page. Much of this code is duplicated in the inner theme's template
% |progress bar in section page|.
% Template for the progress bar optionally displayed below the frame title
% on each page. Much of this code is duplicated in the inner theme's template
% |progress bar in section page|.
%
% \begin{macrocode}
\RequirePackage{calc}
\newlength{\metropolis@progressinheadfoot}
\setbeamertemplate{progress bar in head/foot}{
\nointerlineskip
\setlength{\metropolis@progressinheadfoot}{%
\paperwidth * \ratio{\insertframenumber pt}{\inserttotalframenumber pt}%
}%
\begin{beamercolorbox}[wd=\paperwidth,ht=0.4pt,dp=0pt]{progress bar in head/foot}
\begin{beamercolorbox}[
wd=\paperwidth,
ht=0.4pt,
dp=0pt]{progress bar in head/foot}
\begin{tikzpicture}
\draw[bg, fill=bg] (0,0) rectangle (\paperwidth, 0.4pt);
\draw[fg, fill=fg] (0,0) rectangle (\metropolis@progressinheadfoot, 0.4pt);
@ -129,7 +255,12 @@
% \end{macrocode}
% \end{macro}
%
% Process package options
%
% \begin{macrocode}
\@metropolis@outer@setdefaults
\ProcessPgfPackageOptions{/metropolis/outer}
% \end{macrocode}
%
% \iffalse
%</package>

View File

@ -27,91 +27,109 @@
% \iffalse
%<*package>
% ------------------------------------------------------------------------- \fi
% \section{Implementation: \textsc{metropolis} main theme}
%
% \subsection{\textsc{metropolis} main theme}
%
% The primary job of this package is to load the component sub-packages of the
% \textsc{metropolis} theme and route the theme options accordingly. It also
% provides some custom commands and environments for the user.
%
% Load the required packages.
% \begin{macrocode}
\RequirePackage{etoolbox}
\RequirePackage{pgfopts}
\RequirePackage{ifxetex}
\RequirePackage{ifluatex}
% \end{macrocode}
%
% Options
% \subsubsection{Options}
%
% \begin{macro}{\metroset}
% First of all we define a macro for the user to set options.
% \begin{macrocode}
\newcommand{\metroset}[1]{\pgfkeys{/metropolis/.cd,#1}}
% \end{macrocode}
% \end{macro}
%
% Then we need to pass the unknown options to the sub-packages.
%
% \begin{macrocode}
\newif\if@useTitleProgressBar
\@useTitleProgressBarfalse
\DeclareOptionBeamer{usetitleprogressbar}{
\@useTitleProgressBartrue
\pgfkeys{/metropolis/.cd,
.search also={
/metropolis/inner,
/metropolis/outer,
/metropolis/color,
},
% \end{macrocode}
%
% We have to forwarded keys that affect multiple sub-packages manually.
%
% \begin{macrocode}
block/.code=\pgfkeysalso{
inner/block=#1,
color/block=#1,
},
}
% \end{macrocode}
%
% usetotalslideindicator
% \begin{macro}{plaintitleformat}
% Control the case style of the plain title
% \begin{macrocode}
\pgfkeys{
/metropolis/plaintitleformat/.cd,
.is choice,
regular/.code=\renewcommand{\@metropolis@plaintitleformat}{#1},
lowercase/.code={%
\renewcommand{\@metropolis@plaintitleformat}{\MakeLowercase{#1}}
},
uppercase/.code={%
\renewcommand{\@metropolis@plaintitleformat}{\MakeUppercase{#1}}
},
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{everytitleformat}
% Control the case style of the every title
% \begin{macrocode}
\pgfkeys{
/metropolis/everytitleformat/.code=\pgfkeysalso{
inner/titleformat=#1,
inner/sectiontitleformat=#1,
outer/frametitleformat=#1,
plaintitleformat=#1,
}
}
% \end{macrocode}
% \end{macro}
%
% For backwards compatibility with earlier betas of the theme, we implement
% deprecated option names as aliases to the corresponding |key=value| options.
%
% \begin{macrocode}
\newif\if@useTotalSlideIndicator
\@useTotalSlideIndicatorfalse
\DeclareOptionBeamer{usetotalslideindicator}{
\@useTotalSlideIndicatortrue
\pgfkeys{/metropolis/.cd,
usetitleprogressbar/.code=\pgfkeysalso{outer/progressbar=frametitle},
noslidenumbers/.code=\pgfkeysalso{outer/numbering=none},
usetotalslideindicator/.code=\pgfkeysalso{outer/numbering=fraction},
nosectionslide/.code=\pgfkeysalso{inner/sectionpage=none},
darkcolors/.code=\pgfkeysalso{color/background=dark},
blockbg/.code=\pgfkeysalso{color/block=fill, inner/block=fill},
}
% \end{macrocode}
%
% noslidenumbers
% Set default values for options.
%
% \begin{macrocode}
\newif\if@noSlideNumbers
\@noSlideNumbersfalse
\DeclareOptionBeamer{noslidenumbers}{
\@noSlideNumberstrue
\newcommand{\@metropolis@setdefaults}{
\pgfkeys{/metropolis/.cd,
plaintitleformat=lowercase,
}
}
% \end{macrocode}
%
% nosectionslide
%
% \begin{macrocode}
\newif\if@noSectionSlide
\@noSectionSlidefalse
\DeclareOptionBeamer{nosectionslide}{
\@noSectionSlidetrue
}
% \end{macrocode}
%
% nooffset
%
% \begin{macrocode}
\newlength{\@mtheme@voffset}
\setlength{\@mtheme@voffset}{2em}
\DeclareOptionBeamer{nooffset}{
\setlength{\@mtheme@voffset}{0em}
}
% \end{macrocode}
%
% blockbg
%
% \begin{macrocode}
\newif\if@beamer@metropolis@blockbg
\@beamer@metropolis@blockbgfalse
\DeclareOptionBeamer{blockbg}{
\@beamer@metropolis@blockbgtrue
}
% \end{macrocode}
%
% darkcolors
%
% \begin{macrocode}
\DeclareOptionBeamer{darkcolors}{
\PassOptionsToPackage{darkcolors}{beamercolorthememetropolis}%
}
% \end{macrocode}
%
% Unknown option error handling
%
% \begin{macrocode}
\DeclareOptionBeamer*{
\PackageWarning{beamerthemem}{Unknown option `\CurrentOption'}%
}
\ProcessOptionsBeamer
% \end{macrocode}
%
% \subsection{Component sub-packages}
% \subsubsection{Component sub-packages}
%
% Having processed the options, we can now load the component sub-packages of
% the theme.
@ -125,8 +143,6 @@
% document is being processed by Xe\LaTeX{} or Lua\LaTeX{}.
%
% \begin{macrocode}
\RequirePackage{etoolbox}
\RequirePackage{ifxetex,ifluatex}
\ifboolexpr{bool {xetex} or bool {luatex}}{
\usefonttheme{metropolis}
}{
@ -146,56 +162,18 @@
}
% \end{macrocode}
%
% \subsection{Custom commands}
%
%
% \subsubsection{Custom commands}
%
% We define custom commands in this package as their proper usage may depend
% on multiple sub-packages.
%
% \begin{macro}{\mthemetitleformat}
% \begin{macro}{\mthemesectiontitleformat}
% \begin{macro}{\mthemeframetitleformat}
% \begin{macro}{\mthemeplaintitleformat}
% Creates hooks to change the case format of the four different titles.
% \begin{macro}{\@metropolis@plaintitleformat}
% Define a hook to change the case format of the plain title.
% \begin{macrocode}
\def\mthemetitleformat#1{\MakeLowercase{#1}}
\def\mthemesectiontitleformat#1{\mthemetitleformat{#1}}
\def\mthemeframetitleformat#1{\mthemetitleformat{#1}}
\def\mthemeplaintitleformat#1{\mthemetitleformat{#1}}
\def\@metropolis@plaintitleformat#1{#1}
% \end{macrocode}
%
% To give users the option to |\MakeUppercase| or |\MakeLowercase| the
% section title and frame title we need to patch the commands
% |\sectionentry|, |\beamer@section| and |\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{\sectionentry}
{\def\insertsectionhead{#2}}
{\def\insertsectionhead{\mthemesectiontitleformat{#2}}}
{}{}
\patchcmd{\beamer@section}
{\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}}
{\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{\mthemesectiontitleformat{#1}}}}
{}{}
\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{{\mthemeframetitleformat{#2}\ifnum\beamer@autobreakcount>0\relax{}\space\usebeamertemplate*{frametitle continuation}\fi}}%
\gdef\beamer@frametitle{#2}%
\gdef\beamer@shortframetitle{#1}%
}}
{}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\plain}
@ -204,14 +182,17 @@
% \begin{macrocode}
\newcommand{\plain}[2][]{%
\begingroup
\setbeamercolor{background canvas}{use=palette primary,parent=palette primary}
\setbeamercolor{background canvas}{
use=palette primary,
parent=palette primary
}
\begin{frame}{#1}
\centering
\vfill
\vspace{1em}
\usebeamercolor[fg]{palette primary}
\usebeamerfont{section title}
\mthemeplaintitleformat{#2}
\@metropolis@plaintitleformat{#2}
\vfill
\end{frame}
\endgroup
@ -225,6 +206,13 @@
% \end{macrocode}
% \end{macro}
%
% Process package options
%
% \begin{macrocode}
\@metropolis@setdefaults
\ProcessPgfOptions{/metropolis}
% \end{macrocode}
%
% \iffalse
%</package>
% \fi

BIN
demo.pdf

Binary file not shown.

View File

@ -13,7 +13,7 @@
\documentclass{ltxdoc}
%\OnlyDescription
\usepackage[parfill]{parskip}
\usepackage{parskip}
\usepackage{setspace}
\onehalfspacing
@ -62,7 +62,7 @@
xrightmargin=0em,
aboveskip=1em,
belowskip=1em,
morekeywords={usetheme,institute,maketitle,mthemetitleformat,plain,setbeamercolor},
morekeywords={usetheme,institute,maketitle,@metropolis@titleformat,plain,setbeamercolor,metropolisset},
}
\lstMakeShortInline|
@ -72,6 +72,16 @@
pagecolor=mLightBrown,
urlcolor=mLightBrown]{hyperref}
\newcommand{\DescribeOption}[4]{
\DescribeMacro{#1}
\begin{minipage}[t]{\textwidth}
\textit{\textbf{\textcolor{mLightGreen}{#2}}}\dotfill\,#3\par
\begingroup
\leftskip2em #4\par
\endgroup
\end{minipage}
}
\GetFileInfo{beamerthemem.dtx}
\title{Modern Beamer Presentations\\with the\\\textsc{mtheme} package}
\author{Matthias Vogelgesang \\ \url{matthias.vogelgesang@gmail.com}}
@ -82,21 +92,21 @@
\maketitle
\section{Introduction}
Beamer is an awesome way to make presentations with LaTeX. But the stock themes
do not necessarily look particularly nice and the custom themes often scream
“Beamer” at first sight. The goal of \textsc{mtheme} is to provide a modern
Beamer theme with minimal visual noise. It provides section slides with a neat
progress bar and It is intended to be used with
\href{https://www.mozilla.org/en-US/styleguide/products/firefox-os/typeface/}{Fira
Sans}, a gorgeous typeface commissioned by Mozilla and designed by
Beamer is an awesome way to make presentations with LaTeX. But the stock
themes do not necessarily look particularly nice and the custom themes often
scream “Beamer” at first sight. The goal of \textsc{mtheme} is to provide a
modern Beamer theme with minimal visual noise. It provides section slides with
a neat progress bar and it is intended to be used with
\href{https://www.mozilla.org/en-US/styleguide/products/firefox-os/typeface/}
{Fira Sans}, a gorgeous typeface commissioned by Mozilla and designed by
\href{http://www.carrois.com/fira-3-1/}{Carrois}. Hence to get the best results
you should have installed the Fira typeface and use XeTeX to typeset your
slides. Nevertheless this is no hard dependency. The theme also works fine with
pdfTeX and the Computer Modern typeface.
The codebase is maintained on \href{https://github.com/matze/mtheme}{GitHub}. So
if you have issues, find mistakes in the manual or want to contribute to make
the theme even better get in touch there.
The codebase is maintained on \href{https://github.com/matze/mtheme}{GitHub}.
So if you have issues, find mistakes in the manual or want to contribute to
make the theme even better get in touch there.
\section{Getting Started}
@ -120,11 +130,13 @@ computer. The complete list of make rules is as follows:
\item[uninstall] \hfill \\
Remove the theme from your local texmf folder.
\item[sty] \hfill \\
Build the manual.
\item[manual] \hfill \\
Build the manual.
Creat the package files.
\item[doc] \hfill \\
Build the documentation.
\item[demo] \hfill \\
Build the demo presentation.
\item[demo-min] \hfill \\
Build the minimal demo presentation.
\item[ctan] \hfill \\
Create a package for CTAN distribution.
\end{description}
@ -182,45 +194,98 @@ minimal example of a Beamer presentation using the \textsc{mtheme}.
\section{Customization}
\subsection{Package options}
The theme provides a number of options. To use any of the options below, call
them when invoking \textsc{mtheme} in the preamble of the slides, i.e.
\begin{lstlisting}[numbers=none]
\usetheme[<options>]{m}
The theme provides a number of options. The options use a key=value interface.
So every option is controlled by a key its value. To use an option you can
either provide a comma separated list of options when invoking
\textsc{mtheme} in the preamble of the presentation.
\begin{lstlisting}
\usetheme[<key=value list>]{m}
\end{lstlisting}
Or you can set them at any time with the |\metropolisset| macro.
\begin{lstlisting}
\metropolisset[<key=value list>]
\end{lstlisting}
To set an option on a specific sub-package only you have to add the
corresponding prefix (inner, outer, color), e.g.
\begin{lstlisting}
\metropolisset[inner/block=fill]
\end{lstlisting}
The list of options is structured as shown in the following example.
\noindent\DescribeMacro{usetitleprogressbar}
Adds a thin progress bar similar to the section progress bar underneath each
frame title.\\
\DescribeOption{key}{list of possible values}{default value}{
A short description of the option.
}
\noindent\DescribeMacro{blockbg}
Adds background color to the blocks similar to other beamer themes.\\
Although the options are grouped into the corresponding packages every option
can and in most cases should be set on the main theme directly. If an option
is listed in multiple sub-packages, setting it on the main theme will set the
option on every sub-package accordingly.
\noindent\DescribeMacro{nooffset}
By default, the \textsc{mtheme} adds |\vspace{2em}| after the frametitle to
center content vertically on the frame. This option removes this additional
space in order to get more content per slide.\\
\subsubsection{Main theme}
\DescribeOption{everytitleformat}{regular, lowercase, uppercase}{lowercase}{
Shortcut option to change the case style of all titles together.
}
\noindent\DescribeMacro{nosectionslide}
By default when using the |\section| command, a slide is created with just the
title and the progress bar on it. This option prevents the creation of these
additional slides.\\
\DescribeOption{plainformat}{regular, lowercase, uppercase}{lowercase}{
Control the case style of the plain title.
}
\noindent\DescribeMacro{usetotalslideindicator}
By default, only the current page number is printed in the lower right corner.
This option changes the slide numbering format to |#current/#total|.\\
\subsubsection{Inner theme}
\DescribeOption{block}{transparent, fill}{transparent}{
This option controls the block background. It can either be filled with a
light grey or be transparent.
}
\noindent\DescribeMacro{noslidenumbers}
Omits slide numbers entirely.\\
\DescribeOption{sectionpage}{none, progressbar}{progressbar}{
Adds a thin progress bar similar to the section progress bar underneath each frame title.
}
\noindent\DescribeMacro{darkcolors}
Makes the background dark and the foreground light.\\
\DescribeOption{titleformat}{regular, lowercase, uppercase}{lowercase}{
Control the case style of the title.
}
\DescribeOption{sectiontitleformat}{regular, lowercase, uppercase}{lowercase}{
Control the case style of the section title.
}
\subsubsection{Outer theme}
\DescribeOption{numbering}{none, counter, fraction}{counter}{
In the bottom right corner of each frame the current frame number is
displayed. This can be disabled or the total framenumber can be added
additionally.
}
\DescribeOption{progressbar}{none, frametitle}{none}{
Setting this option to frametitle adds a progress bar underneath each frame
title similar to the section progress bar.
}
\DescribeOption{frametitleformat}{regular, lowercase, uppercase}{lowercase}{
Control the case style of the frame title.
}
\DescribeOption{frametitleoffset\\noframetitleoffset}{<dimension>}{2em}{
The frametitle offset is an additional vertical space after the frame title
to center the content vertically on the frame. To remove this space entirely
the short option |noframetitleoffset| is defined.
}
\subsubsection{Color theme}
\DescribeOption{block}{transparent, fill}{transparent}{
This option controls the block background. It can either be filled with a
light grey or be transparent.
}
\DescribeOption{background}{dark, light}{light}{
This option defines whether the background shall be dark and the foreground
be light or vice versa.
}
\subsection{Color Customization}
The included metropolis color theme is used by default, but its colors can be
easily changed to suit your tastes. All of the theme's styles are defined in
terms of three beamer colors:
The included \textsc{metropolis} color theme is used by default, but its
colors can be easily changed to suit your tastes. All of the theme's styles
are defined in terms of three beamer colors:
\begin{itemize}
\item |normal text| (dark fg, light bg)
\item |alerted text| (colored fg, should be visible against dark or light)
@ -228,38 +293,26 @@ terms of three beamer colors:
\end{itemize}
An easy way to customize the theme is to redefine these colors using
\begin{lstlisting}[numbers=none]
\begin{lstlisting}
\setbeamercolor{ ... }{ fg= ... , bg= ... }
\end{lstlisting}
in your preamble. For greater customization, you can redefine any of the other
colors in |beamercolorthememetropolis|, including progress bar.
\subsection{Title Case Formatting}
The main title, section titles, frame titles and plain frame titles are all
formatted according to the custom command |\mthemetitleformat|. By default,
this is equivalent to |\MakeLowercase{#1}|, hence seting the titles in small
capitals. You can change this behaviour in your preamble. For example:
stock beamer colors. In addition to the stock colors the theme defines a number
of \textsc{metropolis} specific colors, which can also be redefined to your
liking.
\begin{lstlisting}
% camel case
\renewcommand{\mthemetitleformat}{}
% lowercase
\renewcommand{\mthemetitleformat}\MakeLowercase}
% uppercase
\renewcommand{\mthemetitleformat}{\MakeUppercase}
\setbeamercolor{progress bar}{ ... }
\setbeamercolor{title separator}{ ... }
\setbeamercolor{progress bar in head/foot}{ ... }
\setbeamercolor{progress bar in section page}{ ... }
\end{lstlisting}
Be aware that these formatting macros will be replaced with theme options in
the future.
\subsection{Commands}
The |\plain{title=[]}{<body>}| command sets a slide in plain dark colors which
can be useful to focus attention on a single sentence or image.
\subsection{Paul Tol's colors: a \texttt{pgfplots} theme}
A good presentation uses colors that are

Binary file not shown.

View File

@ -30,7 +30,7 @@
%<*package>
% ------------------------------------------------------------------------- \fi
%
% \section{Implementation: Tol \texttt{pgfplots} theme}
% \subsection{Tol \texttt{pgfplots} theme}
%
% Paul Tol's 12-color palette\footnote{Tol actually describes several
% palettes; these colours are taken from the bottom row of Figure 3 in his