Merge pull request #145 from benjamin-weiss/font-theme

Fixes #85 – Font theme overhaul
This commit is contained in:
Matthias Vogelgesang 2015-11-13 08:18:06 +01:00
commit 4cd0943d42
6 changed files with 248 additions and 70 deletions

Binary file not shown.

View File

@ -64,6 +64,22 @@ or show \textbf{bold} results.\end{verbatim}
The theme provides sensible defaults to \emph{emphasize} text, The theme provides sensible defaults to \emph{emphasize} text,
\alert{accent} parts or show \textbf{bold} results. \alert{accent} parts or show \textbf{bold} results.
\end{frame} \end{frame}
\begin{frame}{Font feature test}
\begin{itemize}
\item Regular
\item \textit{Italic}
\item \textsc{SmallCaps}
\item \textbf{Bold}
\item \textbf{\textit{Bold Italic}}
\item \textbf{\textsc{Bold SmallCaps}}
\item \texttt{Monospace}
\item \texttt{\textit{Monospace Italic}}
\item \texttt{\textbf{Monospace Bold}}
\item \texttt{\textbf{\textit{Monospace Bold Italic}}}
\end{itemize}
\end{frame}
\begin{frame}{Lists} \begin{frame}{Lists}
\begin{columns}[T,onlytextwidth] \begin{columns}[T,onlytextwidth]
\column{0.33\textwidth} \column{0.33\textwidth}

View File

@ -18,12 +18,69 @@
\usepackage{xspace} \usepackage{xspace}
\onehalfspacing \onehalfspacing
\usepackage{fontspec} \usepackage{etoolbox}
\setmainfont[BoldItalicFont={Fira Sans Italic},% \usepackage{ifxetex}
ItalicFont={Fira Sans Light Italic},% \usepackage{ifluatex}
BoldFont={Fira Sans}]{Fira Sans Light}
\setmonofont{Fira Mono} \ifboolexpr{bool {xetex} or bool {luatex}}{
\defaultfontfeatures{Ligatures=TeX} \usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\newcounter{fontsnotfound}
\newcommand{\checkfont}[1]{%
\suppressfontnotfounderror=1%
\font\x = "#1" at 10pt
\ifx\x\nullfont%
\stepcounter{fontsnotfound}%
\fi%
\suppressfontnotfounderror=0%
}
\newcommand{\iffontsexist}[3]{%
\setcounter{fontsnotfound}{0}%
\expandafter\forcsvlist\expandafter%
\checkfont\expandafter{#1}%
\ifnum\value{fontsnotfound}=0%
#2%
\else%
#3%
\fi%
}
\iffontsexist{Fira Sans Light,%
Fira Sans Light Italic,%
Fira Sans,%
Fira Sans Italic}{%
\setmainfont[BoldFont={Fira Sans}]{Fira Sans Light}%
}{%
\iffontsexist{Fira Sans Light OT,%
Fira Sans Light Italic OT,%
Fira Sans OT,%
Fira Sans Italic OT}{%
\setmainfont[BoldFont={Fira Sans OT}]{Fira Sans Light OT}%
}{%
\typeout{%
Could not find Fira Sans fonts. Creating documentation%
with standard fonts.%
}
}
}
\iffontsexist{Fira Mono, Fira Mono Bold}{%
\setmonofont{Fira Mono}%
}{%
\iffontsexist{Fira Mono OT, Fira Mono Bold OT}{%
\setmonofont{Fira Mono OT}%
}{%
\typeout{%
Could not find Fira Sans fonts. Creating documentation%
with standard monospaced fonts.%
}
}
}
}{
\typeout{%
You need to compile with XeLaTeX or LuaLaTeX to use the Fira fonts.%
}
}
\usepackage{enumitem} \usepackage{enumitem}
\setlist[itemize]{noitemsep} \setlist[itemize]{noitemsep}
@ -63,7 +120,8 @@
xrightmargin=0em, xrightmargin=0em,
aboveskip=1em, aboveskip=1em,
belowskip=1em, belowskip=1em,
morekeywords={usetheme,institute,maketitle,@metropolis@titleformat,plain,setbeamercolor,metroset}, morekeywords={usetheme,institute,maketitle,@metropolis@titleformat,%
plain,setbeamercolor,metroset,setsansfont,setmonofont},
} }
\lstMakeShortInline| \lstMakeShortInline|
@ -83,7 +141,7 @@
\end{minipage} \end{minipage}
} }
\newcommand{\themename}{\textsc{metropolis}\xspace} \newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}
\GetFileInfo{beamerthemem.dtx} \GetFileInfo{beamerthemem.dtx}
\title{Modern Beamer Presentations with the \themename{} package} \title{Modern Beamer Presentations with the \themename{} package}
@ -113,7 +171,7 @@ By default, \themename{} uses
{Fira Sans}, a gorgeous typeface commissioned by Mozilla and designed by {Fira Sans}, a gorgeous typeface commissioned by Mozilla and designed by
\href{http://www.carrois.com/fira-3-1/}{Carrois}. For best results, you will \href{http://www.carrois.com/fira-3-1/}{Carrois}. For best results, you will
need the Fira typeface installed and use Xe\LaTeX{} to typeset your slides. need the Fira typeface installed and use Xe\LaTeX{} to typeset your slides.
However, \themename{} can also be used other typefaces and \LaTeX{} build However, \themename{} can also be used with other typefaces and \LaTeX{} build
systems. systems.
\themename's codebase is maintained on \href{https://github.com/matze/mtheme} \themename's codebase is maintained on \href{https://github.com/matze/mtheme}
@ -125,6 +183,23 @@ the theme even better, please get in touch there. The
\section{Getting Started} \section{Getting Started}
% \subsection{Installing from CTAN}
% For the regular user it is recommended to install \themename{} from
% \href{https://www.ctan.org}{CTAN}. In case you keep your \TeX\ distribution up-to-date,
% chances are good that \themename{} is already installed. If it is not, you need to update
% your packages. For \TeX\ Live (or Mac\TeX\ on OS X) the following command updates all
% packages.
% \begin{lstlisting}
% sudo tlmgr update --all
% \end{lstlisting}
% For any other distribution please refer to its documentation on how to update your
% packages.
% To get the most out of the theme you should also install the |Fira| fonts. Yet this
% is not mandatory. \themename{} also works with the standard fonts.
\subsection{Installing from GitHub} \subsection{Installing from GitHub}
Installing \themename{}, like any Beamer theme, involves four easy steps: Installing \themename{}, like any Beamer theme, involves four easy steps:
@ -161,6 +236,10 @@ options for advanced users:
\item[|make ctan|] creates a package for CTAN distribution. \item[|make ctan|] creates a package for CTAN distribution.
\end{description} \end{description}
\subsection{Installing the Debian Package}
As an alternative users of Debian or Ubuntu can also install this
\href{https://launchpad.net/\%7Eedd/+archive/ubuntu/misc/+files/latex-mtheme_0.1.0vidid1_all.deb}{.deb package}
containing the theme files as well as the Fira Sans font files.
\subsection{A Minimal Example} \subsection{A Minimal Example}
@ -191,13 +270,10 @@ The following code shows a minimal example of a Beamer presentation using \theme
\item TikZ \item TikZ
\end{itemize} \end{itemize}
Depending on the Linux distribution, the packaged name of |Fira Sans| might be The |Fira Sans| font is not a hard dependency. \themename will try to load the
|Fira Sans OT| instead of |Fira Sans|. In that case, you may have to edit font and use it if it is installed, but if not it will just use the standard
|beamerfontthememetropolis.dtx|. You may also need to install Fira Sans; see font. Depending on the Linux distribution, the packaged name of |Fira Sans| might be
the |contrib/| directory for more. Users of Debian or Ubuntu can also install |Fira Sans OT| instead of |Fira Sans|. \themename will check for this name too.
this \href{https://launchpad.net/\%7Eedd/+archive/ubuntu/misc/+files/latex-mtheme_0.1.0vidid1_all.deb}{.deb package} containing the theme files as well
as the Fira Sans font files.
\subsection{Pandoc} \subsection{Pandoc}
@ -321,9 +397,21 @@ of \themename specific colors, which can also be redefined to your liking.
\setbeamercolor{progress bar in section page}{ ... } \setbeamercolor{progress bar in section page}{ ... }
\end{lstlisting} \end{lstlisting}
\subsection{Font Customization}
The default font for \themename{} is |Fira|. Yet this can be easily changed using
the standard font selection commands of the |fontspec| package. So if you for
example prefer the \href{http://font.ubuntu.com}{|Ubuntu|} font family just add
the following two commands after loading the \themename{} theme.
\begin{lstlisting}
\setsansfont{Ubuntu}
\setmonofont{Ubuntu Mono}
\end{lstlisting}
\subsection{Commands} \subsection{Commands}
The |\plain{title=[]}{<body>}| command sets a slide in plain dark colors which The \lstinline|\plain{title=[]}{<body>}| command sets a slide in plain dark colors which
can be useful to focus attention on a single sentence or image. can be useful to focus attention on a single sentence or image.
\subsection{Paul Tol's colors: a \texttt{pgfplots} theme} \subsection{Paul Tol's colors: a \texttt{pgfplots} theme}
@ -347,7 +435,7 @@ or horizontal |mbarplot| to plot bar charts.
\section{Known Issues} \section{Known Issues}
The |\plain| command does not work if you override the \textsc{metropolis} The \lstinline|\plain| command does not work if you override the \textsc{metropolis}
color theme with the default beamer color theme |fly|. color theme with the default beamer color theme |fly|.
\section{License} \section{License}

Binary file not shown.

View File

@ -13,7 +13,7 @@
%<driver> \ProvidesFile{beamerfontthememetropolis.dtx} %<driver> \ProvidesFile{beamerfontthememetropolis.dtx}
%<*package> %<*package>
\NeedsTeXFormat{LaTeX2e} \NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerfontthememetropolis}[2015/06/12 Metropolis font theme] \ProvidesPackage{beamerfontthememetropolis}[2015/10/24 Metropolis font theme]
%</package> %</package>
%<driver> \documentclass{ltxdoc} %<driver> \documentclass{ltxdoc}
%<driver> \usepackage{beamerfontthememetropolis} %<driver> \usepackage{beamerfontthememetropolis}
@ -26,53 +26,141 @@
% \iffalse % \iffalse
%<*package> %<*package>
% ------------------------------------------------------------------------- \fi % ------------------------------------------------------------------------- \fi
% \subsection{Fira font theme} % \subsection{\textsc{metropolis} font theme}
% Font Definitions %
%
% Load required packages.
% \begin{macrocode}
\RequirePackage{etoolbox}
\RequirePackage{ifxetex}
\RequirePackage{ifluatex}
% \end{macrocode}
%
% \subsubsection{Load Fira font}
% If the presentation is compiled with XeLaTeX or LuaLaTeX the fontspec package
% will be loaded.
% \begin{macrocode}
\ifboolexpr{bool {xetex} or bool {luatex}}{
\RequirePackage[no-math]{fontspec}
\defaultfontfeatures{Mapping=tex-text}
% \end{macrocode}
%
% To simplify the check whether the |Fira| fonts are installed, a set macros is
% defined.
%
% \begin{macro}{\checkfont}
% Checks if a font is installed and increases |fontsnotfound| counter if not.
% \begin{macrocode}
\newcounter{fontsnotfound}
\newcommand{\checkfont}[1]{%
\suppressfontnotfounderror=1%
\font\x = "#1" at 10pt
\ifx\x\nullfont%
\stepcounter{fontsnotfound}%
\fi%
\suppressfontnotfounderror=0%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\iffontexists}
% Resets the |fontsnotfound| counter and calls |\checkfont| for each font in the comma
% separated list in the first argument.
% \begin{macrocode}
\newcommand{\iffontsexist}[3]{%
\setcounter{fontsnotfound}{0}%
\expandafter\forcsvlist\expandafter%
\checkfont\expandafter{#1}%
\ifnum\value{fontsnotfound}=0%
#2%
\else%
#3%
\fi%
}
% \end{macrocode}
% \end{macro}
%
% Using the previously defined macros it is tried to load the |Fira| fonts. First the default
% |Fira| name will be tried. Second the |Fira| fonts with the suffix OT -- used by some Linux
% distributions -- will be tried. If this also fails a warning will be displayed and the
% standard fonts will be used.
% %
% \begin{macrocode} % \begin{macrocode}
\RequirePackage[no-math]{fontspec} \iffontsexist{Fira Sans Light,%
\defaultfontfeatures{Mapping=tex-text} Fira Sans Light Italic,%
\setsansfont[BoldItalicFont={Fira Sans Italic},% Fira Sans,%
ItalicFont={Fira Sans Light Italic},% Fira Sans Italic}{%
BoldFont={Fira Sans}]{Fira Sans Light} \setsansfont[BoldFont={Fira Sans}]{Fira Sans Light}%
\setmonofont{Fira Mono} }{%
\newfontfamily\ExtraLight{Fira Sans ExtraLight} \iffontsexist{Fira Sans Light OT,%
\newfontfamily\Light{Fira Sans Light} Fira Sans Light Italic OT,%
\newfontfamily\Book{Fira Sans} Fira Sans OT,%
\newfontfamily\Medium{Fira Sans Medium} Fira Sans Italic OT}{%
\AtBeginEnvironment{tabular}{% \setsansfont[BoldFont={Fira Sans OT}]{Fira Sans Light OT}%
\setsansfont[BoldFont={Fira Sans},% }{%
Numbers={Monospaced}]{Fira Sans Light}% \PackageWarning{beamerthemem}{%
Could not find Fira Sans fonts.%
}
} }
}
\iffontsexist{Fira Mono, Fira Mono Bold}{%
\setmonofont{Fira Mono}%
}{%
\iffontsexist{Fira Mono OT, Fira Mono Bold OT}{%
\setmonofont{Fira Mono OT}%
}{%
\PackageWarning{beamerthemem}{%
Could not find Fira Mono fonts.%
}
}
}
\AtBeginEnvironment{tabular}{%
\addfontfeature{Numbers={Monospaced}}%
}
}{%
\PackageWarning{beamerthemem}{%
You need to compile with XeLaTeX or LuaLaTeX to use the Fira fonts.%
}
}
% \end{macrocode} % \end{macrocode}
% %
% Font Assignment %
%
% \subsubsection{General font definitions}
% %
% \begin{macrocode} % \begin{macrocode}
\setbeamerfont{title}{family=\Book, size=\Large, shape=\scshape} \setbeamerfont{title}{size=\Large,%
\setbeamerfont{author}{family=\ExtraLight, size=\small} series=\bfseries,%
\setbeamerfont{date}{family=\ExtraLight, size=\small} shape=\scshape}
\setbeamerfont{section title}{family=\Book, size=\Large, shape=\scshape} \setbeamerfont{author}{size=\small}
\setbeamerfont{block title}{family=\Book, size=\normalsize} \setbeamerfont{date}{size=\small}
\setbeamerfont{block title alerted}{family=\Book,size=\normalsize} \setbeamerfont{section title}{size=\Large,%
\setbeamerfont{subtitle}{family=\Light, size=\fontsize{12}{14}} series=\bfseries,%
\setbeamerfont{frametitle}{family=\Book, size=\large, shape=\scshape} shape=\scshape}
\setbeamerfont{block title}{size=\normalsize,%
series=\bfseries}
\setbeamerfont{block title alerted}{size=\normalsize,%
series=\bfseries}
\setbeamerfont*{subtitle}{size=\large,%
shape=\scshape}
\setbeamerfont{frametitle}{size=\large,%
series=\bfseries,%
shape=\scshape}
\setbeamerfont{caption}{size=\small} \setbeamerfont{caption}{size=\small}
\setbeamerfont{caption name}{family=\Book} \setbeamerfont{caption name}{series=\bfseries}
\setbeamerfont{description item}{family=\Book} \setbeamerfont{description item}{series=\bfseries}
\setbeamerfont{page number in head/foot}{size=\scriptsize} \setbeamerfont{page number in head/foot}{size=\scriptsize}
% \end{macrocode} \setbeamerfont{bibliography entry author}{size=\normalsize,%
% series=\normalfont}
% Bibliograpy \setbeamerfont{bibliography entry title}{size=\normalsize,%
% series=\bfseries}
% \begin{macrocode} \setbeamerfont{bibliography entry location}{size=\normalsize,%
\setbeamerfont{bibliography entry author}{family=\Light, size=\normalsize} series=\normalfont}
\setbeamerfont{bibliography entry title}{family=\Book, size=\normalsize} \setbeamerfont{bibliography entry note}{size=\small,%
\setbeamerfont{bibliography entry location}{family=\Light, size=\normalsize} series=\normalfont}
\setbeamerfont{bibliography entry note}{family=\Light, size=\small}
\linespread{1.15} \linespread{1.15}
% \end{macrocode} % \end{macrocode}
% %
% \iffalse % \iffalse
%</package> %</package>

View File

@ -37,8 +37,6 @@
% \begin{macrocode} % \begin{macrocode}
\RequirePackage{etoolbox} \RequirePackage{etoolbox}
\RequirePackage{pgfopts} \RequirePackage{pgfopts}
\RequirePackage{ifxetex}
\RequirePackage{ifluatex}
% \end{macrocode} % \end{macrocode}
% %
% \subsubsection{Options} % \subsubsection{Options}
@ -136,19 +134,7 @@
\useinnertheme{metropolis} \useinnertheme{metropolis}
\useoutertheme{metropolis} \useoutertheme{metropolis}
\usecolortheme{metropolis} \usecolortheme{metropolis}
% \end{macrocode} \usefonttheme{metropolis}
%
% The |fira| font theme, which depends on |fontspec|, is only loaded if the
% document is being processed by Xe\LaTeX{} or Lua\LaTeX{}.
%
% \begin{macrocode}
\ifboolexpr{bool {xetex} or bool {luatex}}{
\usefonttheme{metropolis}
}{
\PackageWarning{beamerthemem}{%
You need to compile with XeLaTeX or LuaLaTeX to use the Fira fonts.
}
}
% \end{macrocode} % \end{macrocode}
% %
% The |tol| theme for |pgfplots| is only loaded if |pgfplots| is used. % The |tol| theme for |pgfplots| is only loaded if |pgfplots| is used.