| 1 |
% \iffalse meta-comment ------------------------------------------------------- |
| 2 |
% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of |
| 3 |
% contributors can be found at |
| 4 |
% |
| 5 |
% https://github.com/matze/mtheme/graphs/contributors |
| 6 |
% |
| 7 |
% and the original template was based on the HSRM theme by Benjamin Weiss. |
| 8 |
% |
| 9 |
% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 |
| 10 |
% International License (https://creativecommons.org/licenses/by-sa/4.0/). |
| 11 |
% ------------------------------------------------------------------------- \fi |
| 12 |
% \iffalse |
| 13 |
%<*package> |
| 14 |
\NeedsTeXFormat{LaTeX2e} |
| 15 |
\ProvidesPackage{beamerfontthememetropolis}[2017/01/23 Metropolis font theme] |
| 16 |
%</package> |
| 17 |
% \fi |
| 18 |
% \CheckSum{0} |
| 19 |
% \StopEventually{} |
| 20 |
% \iffalse |
| 21 |
%<*package> |
| 22 |
% ------------------------------------------------------------------------- \fi |
| 23 |
% |
| 24 |
% \subsection{\themename font theme} |
| 25 |
% |
| 26 |
% A |beamer| font theme sets the style of the font used in the document. |
| 27 |
% |
| 28 |
% |
| 29 |
% |
| 30 |
% \subsubsection{Package dependencies} |
| 31 |
% |
| 32 |
% \begin{macrocode} |
| 33 |
\RequirePackage{etoolbox} |
| 34 |
\RequirePackage{ifxetex} |
| 35 |
\RequirePackage{ifluatex} |
| 36 |
\RequirePackage{pgfopts} |
| 37 |
% \end{macrocode} |
| 38 |
% |
| 39 |
% |
| 40 |
% |
| 41 |
% \subsubsection{Load Fira fonts} |
| 42 |
% |
| 43 |
% If the presentation is compiled with Xe\LaTeX{} or Lua\LaTeX{}, the fontspec |
| 44 |
% package is loaded and we search for the |Fira| fonts. |
| 45 |
% |
| 46 |
% \begin{macrocode} |
| 47 |
\ifboolexpr{bool {xetex} or bool {luatex}}{ |
| 48 |
\@ifpackageloaded{fontspec}{ |
| 49 |
\PassOptionsToPackage{no-math}{fontspec} |
| 50 |
}{ |
| 51 |
\RequirePackage[no-math]{fontspec} |
| 52 |
} |
| 53 |
% \end{macrocode} |
| 54 |
% |
| 55 |
% \begin{macro}{\checkfont} |
| 56 |
% Checks if a font is installed; if not, |fontsnotfound| is increased. |
| 57 |
% \begin{macrocode} |
| 58 |
\newcounter{fontsnotfound} |
| 59 |
\newcommand{\checkfont}[1]{% |
| 60 |
\suppressfontnotfounderror=1% |
| 61 |
\font\x = "#1" at 10pt |
| 62 |
\selectfont |
| 63 |
\ifx\x\nullfont% |
| 64 |
\stepcounter{fontsnotfound}% |
| 65 |
\fi% |
| 66 |
\suppressfontnotfounderror=0% |
| 67 |
} |
| 68 |
|
| 69 |
% \end{macrocode} |
| 70 |
% \end{macro} |
| 71 |
% |
| 72 |
% \begin{macro}{\iffontsavailable} |
| 73 |
% Resets the |fontsnotfound| counter and calls |\checkfont| for each font in |
| 74 |
% the comma separated list in the first argument. |
| 75 |
% \begin{macrocode} |
| 76 |
\newcommand{\iffontsavailable}[3]{% |
| 77 |
\setcounter{fontsnotfound}{0}% |
| 78 |
\expandafter\forcsvlist\expandafter% |
| 79 |
\checkfont\expandafter{#1}% |
| 80 |
\ifnum\value{fontsnotfound}=0% |
| 81 |
#2% |
| 82 |
\else% |
| 83 |
#3% |
| 84 |
\fi% |
| 85 |
} |
| 86 |
% \end{macrocode} |
| 87 |
% \end{macro} |
| 88 |
% |
| 89 |
% We search for regular, italic, light, light italic, mono, and mono bold |
| 90 |
% fonts under the default |Fira Sans| and |Fira Mono| names. If this fails, |
| 91 |
% the suffix OT --- used by some Linux distributions --- will be tried. If this |
| 92 |
% also fails, a warning will be displayed and the standard fonts will be used. |
| 93 |
% |
| 94 |
% \begin{macrocode} |
| 95 |
\iffontsavailable{Fira Sans Light,% |
| 96 |
Fira Sans Light Italic,% |
| 97 |
Fira Sans,% |
| 98 |
Fira Sans Italic}% |
| 99 |
{% |
| 100 |
\setsansfont[ItalicFont={Fira Sans Light Italic},% |
| 101 |
BoldFont={Fira Sans},% |
| 102 |
BoldItalicFont={Fira Sans Italic}]% |
| 103 |
{Fira Sans Light}% |
| 104 |
}{% |
| 105 |
\iffontsavailable{Fira Sans Light OT,% |
| 106 |
Fira Sans Light Italic OT,% |
| 107 |
Fira Sans OT,% |
| 108 |
Fira Sans Italic OT}% |
| 109 |
{% |
| 110 |
\setsansfont[ItalicFont={Fira Sans Light Italic OT},% |
| 111 |
BoldFont={Fira Sans OT},% |
| 112 |
BoldItalicFont={Fira Sans Italic OT}]% |
| 113 |
{Fira Sans Light OT}% |
| 114 |
}{% |
| 115 |
\PackageWarning{beamerthememetropolis}{% |
| 116 |
Could not find Fira Sans fonts% |
| 117 |
} |
| 118 |
} |
| 119 |
} |
| 120 |
\iffontsavailable{Fira Mono, Fira Mono Bold}{% |
| 121 |
\setmonofont[BoldFont={Fira Mono Medium}]{Fira Mono}% |
| 122 |
}{% |
| 123 |
\iffontsavailable{Fira Mono OT, Fira Mono Bold OT}{% |
| 124 |
\setmonofont[BoldFont={Fira Mono Medium OT}]{Fira Mono OT}% |
| 125 |
}{% |
| 126 |
\PackageWarning{beamerthememetropolis}{% |
| 127 |
Could not find Fira Mono fonts% |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
\AtBeginEnvironment{tabular}{% |
| 132 |
\addfontfeature{Numbers={Monospaced}}% |
| 133 |
} |
| 134 |
}{% |
| 135 |
\PackageWarning{beamerthememetropolis}{% |
| 136 |
You need to compile with XeLaTeX or LuaLaTeX to use the Fira fonts% |
| 137 |
} |
| 138 |
} |
| 139 |
% \end{macrocode} |
| 140 |
% |
| 141 |
% This concludes the portion of the code which is only run when compiled with |
| 142 |
% Xe\LaTeX{} or Lua\LaTeX{}. The remainder of this package applies regardless |
| 143 |
% of the compiling engine. |
| 144 |
% |
| 145 |
% |
| 146 |
% |
| 147 |
% \subsubsection{General font definitions} |
| 148 |
% |
| 149 |
% \begin{macrocode} |
| 150 |
\setbeamerfont{title}{size=\Large,% |
| 151 |
series=\bfseries} |
| 152 |
\setbeamerfont{author}{size=\small} |
| 153 |
\setbeamerfont{date}{size=\small} |
| 154 |
\setbeamerfont{section title}{size=\Large,% |
| 155 |
series=\bfseries} |
| 156 |
\setbeamerfont{block title}{size=\normalsize,% |
| 157 |
series=\bfseries} |
| 158 |
\setbeamerfont{block title alerted}{size=\normalsize,% |
| 159 |
series=\bfseries} |
| 160 |
\setbeamerfont*{subtitle}{size=\large} |
| 161 |
\setbeamerfont{frametitle}{size=\large,% |
| 162 |
series=\bfseries} |
| 163 |
\setbeamerfont{caption}{size=\small} |
| 164 |
\setbeamerfont{caption name}{series=\bfseries} |
| 165 |
\setbeamerfont{description item}{series=\bfseries} |
| 166 |
\setbeamerfont{page number in head/foot}{size=\scriptsize} |
| 167 |
\setbeamerfont{bibliography entry author}{size=\normalsize,% |
| 168 |
series=\normalfont} |
| 169 |
\setbeamerfont{bibliography entry title}{size=\normalsize,% |
| 170 |
series=\bfseries} |
| 171 |
\setbeamerfont{bibliography entry location}{size=\normalsize,% |
| 172 |
series=\normalfont} |
| 173 |
\setbeamerfont{bibliography entry note}{size=\small,% |
| 174 |
series=\normalfont} |
| 175 |
\setbeamerfont{standout}{size=\Large,% |
| 176 |
series=\bfseries} |
| 177 |
% \end{macrocode} |
| 178 |
% |
| 179 |
% |
| 180 |
% |
| 181 |
% \subsubsection{Title format options} |
| 182 |
% |
| 183 |
% \begin{macro}{titleformat title} |
| 184 |
% Controls the format of the title. |
| 185 |
% \begin{macrocode} |
| 186 |
\pgfkeys{ |
| 187 |
/metropolis/font/titleformat title/.cd, |
| 188 |
.is choice, |
| 189 |
regular/.code={% |
| 190 |
\let\metropolis@titleformat\@empty% |
| 191 |
\setbeamerfont{title}{shape=\normalfont}% |
| 192 |
}, |
| 193 |
smallcaps/.code={% |
| 194 |
\let\metropolis@titleformat\@empty% |
| 195 |
\setbeamerfont{title}{shape=\scshape}% |
| 196 |
}, |
| 197 |
allsmallcaps/.code={% |
| 198 |
\let\metropolis@titleformat\lowercase% |
| 199 |
\setbeamerfont{title}{shape=\scshape}% |
| 200 |
\PackageWarning{beamerthememetropolis}{% |
| 201 |
Be aware that titleformat title=allsmallcaps can lead to problems% |
| 202 |
} |
| 203 |
}, |
| 204 |
allcaps/.code={% |
| 205 |
\let\metropolis@titleformat\uppercase% |
| 206 |
\setbeamerfont{title}{shape=\normalfont} |
| 207 |
\PackageWarning{beamerthememetropolis}{% |
| 208 |
Be aware that titleformat title=allcaps can lead to problems% |
| 209 |
} |
| 210 |
}, |
| 211 |
} |
| 212 |
% \end{macrocode} |
| 213 |
% \end{macro} |
| 214 |
% |
| 215 |
% \begin{macro}{titleformat subtitle} |
| 216 |
% Control the format of the subtitle. |
| 217 |
% \begin{macrocode} |
| 218 |
\pgfkeys{ |
| 219 |
/metropolis/font/titleformat subtitle/.cd, |
| 220 |
.is choice, |
| 221 |
regular/.code={% |
| 222 |
\let\metropolis@subtitleformat\@empty% |
| 223 |
\setbeamerfont{subtitle}{shape=\normalfont}% |
| 224 |
}, |
| 225 |
smallcaps/.code={% |
| 226 |
\let\metropolis@subtitleformat\@empty% |
| 227 |
\setbeamerfont{subtitle}{shape=\scshape}% |
| 228 |
}, |
| 229 |
allsmallcaps/.code={% |
| 230 |
\let\metropolis@subtitleformat\lowercase% |
| 231 |
\setbeamerfont{subtitle}{shape=\scshape}% |
| 232 |
\PackageWarning{beamerthememetropolis}{% |
| 233 |
Be aware that titleformat subtitle=allsmallcaps can lead to problems% |
| 234 |
} |
| 235 |
}, |
| 236 |
allcaps/.code={% |
| 237 |
\let\metropolis@subtitleformat\uppercase% |
| 238 |
\setbeamerfont{subtitle}{shape=\normalfont}% |
| 239 |
\PackageWarning{beamerthememetropolis}{% |
| 240 |
Be aware that titleformat subtitle=allcaps can lead to problems% |
| 241 |
} |
| 242 |
}, |
| 243 |
} |
| 244 |
% \end{macrocode} |
| 245 |
% \end{macro} |
| 246 |
% |
| 247 |
% \begin{macro}{titleformat section} |
| 248 |
% Controls the format of the section title. |
| 249 |
% \begin{macrocode} |
| 250 |
\pgfkeys{ |
| 251 |
/metropolis/font/titleformat section/.cd, |
| 252 |
.is choice, |
| 253 |
regular/.code={% |
| 254 |
\let\metropolis@sectiontitleformat\@empty% |
| 255 |
\setbeamerfont{section title}{shape=\normalfont}% |
| 256 |
}, |
| 257 |
smallcaps/.code={% |
| 258 |
\let\metropolis@sectiontitleformat\@empty% |
| 259 |
\setbeamerfont{section title}{shape=\scshape}% |
| 260 |
}, |
| 261 |
allsmallcaps/.code={% |
| 262 |
\let\metropolis@sectiontitleformat\MakeLowercase% |
| 263 |
\setbeamerfont{section title}{shape=\scshape}% |
| 264 |
\PackageWarning{beamerthememetropolis}{% |
| 265 |
Be aware that titleformat section=allsmallcaps can lead to problems% |
| 266 |
} |
| 267 |
}, |
| 268 |
allcaps/.code={% |
| 269 |
\let\metropolis@sectiontitleformat\MakeUppercase% |
| 270 |
\setbeamerfont{section title}{shape=\normalfont}% |
| 271 |
\PackageWarning{beamerthememetropolis}{% |
| 272 |
Be aware that titleformat section=allcaps can lead to problems% |
| 273 |
} |
| 274 |
}, |
| 275 |
} |
| 276 |
% \end{macrocode} |
| 277 |
% \end{macro} |
| 278 |
% |
| 279 |
% \begin{macro}{frametitleformat} |
| 280 |
% Control the format of the frame title. |
| 281 |
% \begin{macrocode} |
| 282 |
\pgfkeys{ |
| 283 |
/metropolis/font/titleformat frame/.cd, |
| 284 |
.is choice, |
| 285 |
regular/.code={% |
| 286 |
\let\metropolis@frametitleformat\@empty% |
| 287 |
\setbeamerfont{frametitle}{shape=\normalfont}% |
| 288 |
}, |
| 289 |
smallcaps/.code={% |
| 290 |
\let\metropolis@frametitleformat\@empty% |
| 291 |
\setbeamerfont{frametitle}{shape=\scshape}% |
| 292 |
}, |
| 293 |
allsmallcaps/.code={% |
| 294 |
\let\metropolis@frametitleformat\MakeLowercase% |
| 295 |
\setbeamerfont{frametitle}{shape=\scshape}% |
| 296 |
\PackageWarning{beamerthememetropolis}{% |
| 297 |
Be aware that titleformat frame=allsmallcaps can lead to problems% |
| 298 |
} |
| 299 |
}, |
| 300 |
allcaps/.code={% |
| 301 |
\let\metropolis@frametitleformat\MakeUppercase% |
| 302 |
\setbeamerfont{frametitle}{shape=\normalfont} |
| 303 |
\PackageWarning{beamerthememetropolis}{% |
| 304 |
Be aware that titleformat frame=allcaps can lead to problems% |
| 305 |
} |
| 306 |
}, |
| 307 |
} |
| 308 |
% \end{macrocode} |
| 309 |
% \end{macro} |
| 310 |
% |
| 311 |
% \begin{macro}{titleformat aliases} |
| 312 |
% Allows |titleformat title| et al. to be used in the |\usetheme| |
| 313 |
% declaration, where \LaTeX{} automatically removes all spaces. |
| 314 |
% \begin{macrocode} |
| 315 |
\pgfkeys{ |
| 316 |
/metropolis/font/.cd, |
| 317 |
titleformattitle/.code=\pgfkeysalso{titleformat title=#1}, |
| 318 |
titleformatsubtitle/.code=\pgfkeysalso{titleformat subtitle=#1}, |
| 319 |
titleformatsection/.code=\pgfkeysalso{titleformat section=#1}, |
| 320 |
titleformatframe/.code=\pgfkeysalso{titleformat frame=#1}, |
| 321 |
} |
| 322 |
% \end{macrocode} |
| 323 |
% \end{macro} |
| 324 |
% |
| 325 |
% \begin{macro}{\metropolis@font@setdefaults} |
| 326 |
% Sets default values for font theme options. |
| 327 |
% \begin{macrocode} |
| 328 |
\newcommand{\metropolis@font@setdefaults}{ |
| 329 |
\pgfkeys{/metropolis/font/.cd, |
| 330 |
titleformat title=regular, |
| 331 |
titleformat subtitle=regular, |
| 332 |
titleformat section=regular, |
| 333 |
titleformat frame=regular, |
| 334 |
} |
| 335 |
} |
| 336 |
% \end{macrocode} |
| 337 |
% \end{macro} |
| 338 |
% |
| 339 |
% We first define hooks to change the case format of the titles. |
| 340 |
% |
| 341 |
% \begin{macrocode} |
| 342 |
\def\metropolis@titleformat#1{#1} |
| 343 |
\def\metropolis@subtitleformat#1{#1} |
| 344 |
\def\metropolis@sectiontitleformat#1{#1} |
| 345 |
\def\metropolis@frametitleformat#1{#1} |
| 346 |
% \end{macrocode} |
| 347 |
% |
| 348 |
% To make the uppercase and lowercase macros work in the title, subtitle, etc., |
| 349 |
% we have to patch the appropriate |beamer| commands that set their values. |
| 350 |
% This solution was suggested by Enrico Gregorio in an answer to |
| 351 |
% \href{http://tex.stackexchange.com/questions/112526/}{this StackExchange |
| 352 |
% question}. |
| 353 |
% |
| 354 |
% \begin{macrocode} |
| 355 |
\patchcmd{\beamer@title}% |
| 356 |
{\def\inserttitle{#2}}% |
| 357 |
{\def\inserttitle{\metropolis@titleformat{#2}}}% |
| 358 |
{}% |
| 359 |
{\PackageError{beamerfontthememetropolis}{Patching title failed}\@ehc} |
| 360 |
\patchcmd{\beamer@subtitle}% |
| 361 |
{\def\insertsubtitle{#2}}% |
| 362 |
{\def\insertsubtitle{\metropolis@subtitleformat{#2}}}% |
| 363 |
{}% |
| 364 |
{\PackageError{beamerfontthememetropolis}{Patching subtitle failed}\@ehc} |
| 365 |
\patchcmd{\sectionentry} |
| 366 |
{\def\insertsectionhead{#2}} |
| 367 |
{\def\insertsectionhead{\metropolis@sectiontitleformat{#2}}} |
| 368 |
{} |
| 369 |
{\PackageError{beamerfontthememetropolis}{Patching section title failed}\@ehc} |
| 370 |
\@tempswafalse |
| 371 |
\patchcmd{\beamer@section} |
| 372 |
{\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}} |
| 373 |
{\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{% |
| 374 |
\metropolis@sectiontitleformat{#1}}}} |
| 375 |
{\@tempswatrue} |
| 376 |
{} |
| 377 |
\patchcmd{\beamer@section} |
| 378 |
{\protected@edef\insertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{#1}}} |
| 379 |
{\protected@edef\insertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{% |
| 380 |
\noexpand\metropolis@sectiontitleformat{#1}}}} |
| 381 |
{\@tempswatrue} |
| 382 |
{} |
| 383 |
\if@tempswa\else |
| 384 |
\PackageError{beamerfontthememetropolis}{Patching section title failed}\@ehc |
| 385 |
\fi |
| 386 |
\@tempswafalse |
| 387 |
\patchcmd{\beamer@subsection} |
| 388 |
{\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{#1}}} |
| 389 |
{\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{% |
| 390 |
\metropolis@sectiontitleformat{#1}}}} |
| 391 |
{\@tempswatrue} |
| 392 |
{} |
| 393 |
\patchcmd{\beamer@subsection} |
| 394 |
{\protected@edef\insertsubsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{#1}}} |
| 395 |
{\protected@edef\insertsubsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{% |
| 396 |
\noexpand\metropolis@sectiontitleformat{#1}}}} |
| 397 |
{\@tempswatrue} |
| 398 |
{} |
| 399 |
\if@tempswa\else |
| 400 |
\PackageError{beamerfontthememetropolis}{Patching section title failed}\@ehc |
| 401 |
\fi |
| 402 |
% \end{macrocode} |
| 403 |
% |
| 404 |
% Similarly, to make the |\MakeLowercase| and |\MakeUppercase| macros work in |
| 405 |
% the frame title we have to patch |\beamer@@frametitle|. |
| 406 |
% |
| 407 |
% \begin{macrocode} |
| 408 |
\patchcmd{\beamer@@frametitle} |
| 409 |
{{% |
| 410 |
\gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space% |
| 411 |
\usebeamertemplate*{frametitle continuation}\fi}}% |
| 412 |
\gdef\beamer@frametitle{#2}% |
| 413 |
\gdef\beamer@shortframetitle{#1}% |
| 414 |
}} |
| 415 |
{{% |
| 416 |
\gdef\insertframetitle{{\metropolis@frametitleformat{#2}\ifnum% |
| 417 |
\beamer@autobreakcount>0\relax{}\space% |
| 418 |
\usebeamertemplate*{frametitle continuation}\fi}}% |
| 419 |
\gdef\beamer@frametitle{#2}% |
| 420 |
\gdef\beamer@shortframetitle{#1}% |
| 421 |
}} |
| 422 |
{} |
| 423 |
{\PackageError{beamerfontthememetropolis}{Patching frame title failed}\@ehc} |
| 424 |
% \end{macrocode} |
| 425 |
% |
| 426 |
% |
| 427 |
% |
| 428 |
% \subsubsection{Process package options} |
| 429 |
% |
| 430 |
% \begin{macrocode} |
| 431 |
\metropolis@font@setdefaults |
| 432 |
\ProcessPgfPackageOptions{/metropolis/font} |
| 433 |
% \end{macrocode} |
| 434 |
% \iffalse |
| 435 |
%</package> |
| 436 |
% \fi |
| 437 |
% \Finale |
| 438 |
\endinput |