beamerfontthememetropolis.sty 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. %%
  2. %% This is file `beamerfontthememetropolis.sty',
  3. %% generated with the docstrip utility.
  4. %%
  5. %% The original source files were:
  6. %%
  7. %% beamerfontthememetropolis.dtx (with options: `package')
  8. %% ---------------------------------------------------------------------------
  9. %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of
  10. %% contributors can be found at
  11. %%
  12. %% https://github.com/matze/mtheme/graphs/contributors
  13. %%
  14. %% and the original template was based on the HSRM theme by Benjamin Weiss.
  15. %%
  16. %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0
  17. %% International License (https://creativecommons.org/licenses/by-sa/4.0/).
  18. %% ---------------------------------------------------------------------------
  19. \NeedsTeXFormat{LaTeX2e}
  20. \ProvidesPackage{beamerfontthememetropolis}[2017/01/23 Metropolis font theme]
  21. \RequirePackage{etoolbox}
  22. \RequirePackage{ifxetex}
  23. \RequirePackage{ifluatex}
  24. \RequirePackage{pgfopts}
  25. \ifboolexpr{bool {xetex} or bool {luatex}}{
  26. \@ifpackageloaded{fontspec}{
  27. \PassOptionsToPackage{no-math}{fontspec}
  28. }{
  29. \RequirePackage[no-math]{fontspec}
  30. }
  31. \newcounter{fontsnotfound}
  32. \newcommand{\checkfont}[1]{%
  33. \suppressfontnotfounderror=1%
  34. \font\x = "#1" at 10pt
  35. \selectfont
  36. \ifx\x\nullfont%
  37. \stepcounter{fontsnotfound}%
  38. \fi%
  39. \suppressfontnotfounderror=0%
  40. }
  41. \newcommand{\iffontsavailable}[3]{%
  42. \setcounter{fontsnotfound}{0}%
  43. \expandafter\forcsvlist\expandafter%
  44. \checkfont\expandafter{#1}%
  45. \ifnum\value{fontsnotfound}=0%
  46. #2%
  47. \else%
  48. #3%
  49. \fi%
  50. }
  51. \iffontsavailable{Fira Sans Light,%
  52. Fira Sans Light Italic,%
  53. Fira Sans,%
  54. Fira Sans Italic}%
  55. {%
  56. \setsansfont[ItalicFont={Fira Sans Light Italic},%
  57. BoldFont={Fira Sans},%
  58. BoldItalicFont={Fira Sans Italic}]%
  59. {Fira Sans Light}%
  60. }{%
  61. \iffontsavailable{Fira Sans Light OT,%
  62. Fira Sans Light Italic OT,%
  63. Fira Sans OT,%
  64. Fira Sans Italic OT}%
  65. {%
  66. \setsansfont[ItalicFont={Fira Sans Light Italic OT},%
  67. BoldFont={Fira Sans OT},%
  68. BoldItalicFont={Fira Sans Italic OT}]%
  69. {Fira Sans Light OT}%
  70. }{%
  71. \PackageWarning{beamerthememetropolis}{%
  72. Could not find Fira Sans fonts%
  73. }
  74. }
  75. }
  76. \iffontsavailable{Fira Mono, Fira Mono Bold}{%
  77. \setmonofont[BoldFont={Fira Mono Medium}]{Fira Mono}%
  78. }{%
  79. \iffontsavailable{Fira Mono OT, Fira Mono Bold OT}{%
  80. \setmonofont[BoldFont={Fira Mono Medium OT}]{Fira Mono OT}%
  81. }{%
  82. \PackageWarning{beamerthememetropolis}{%
  83. Could not find Fira Mono fonts%
  84. }
  85. }
  86. }
  87. \AtBeginEnvironment{tabular}{%
  88. \addfontfeature{Numbers={Monospaced}}%
  89. }
  90. }{%
  91. \PackageWarning{beamerthememetropolis}{%
  92. You need to compile with XeLaTeX or LuaLaTeX to use the Fira fonts%
  93. }
  94. }
  95. \setbeamerfont{title}{size=\Large,%
  96. series=\bfseries}
  97. \setbeamerfont{author}{size=\small}
  98. \setbeamerfont{date}{size=\small}
  99. \setbeamerfont{section title}{size=\Large,%
  100. series=\bfseries}
  101. \setbeamerfont{block title}{size=\normalsize,%
  102. series=\bfseries}
  103. \setbeamerfont{block title alerted}{size=\normalsize,%
  104. series=\bfseries}
  105. \setbeamerfont*{subtitle}{size=\large}
  106. \setbeamerfont{frametitle}{size=\large,%
  107. series=\bfseries}
  108. \setbeamerfont{caption}{size=\small}
  109. \setbeamerfont{caption name}{series=\bfseries}
  110. \setbeamerfont{description item}{series=\bfseries}
  111. \setbeamerfont{page number in head/foot}{size=\scriptsize}
  112. \setbeamerfont{bibliography entry author}{size=\normalsize,%
  113. series=\normalfont}
  114. \setbeamerfont{bibliography entry title}{size=\normalsize,%
  115. series=\bfseries}
  116. \setbeamerfont{bibliography entry location}{size=\normalsize,%
  117. series=\normalfont}
  118. \setbeamerfont{bibliography entry note}{size=\small,%
  119. series=\normalfont}
  120. \setbeamerfont{standout}{size=\Large,%
  121. series=\bfseries}
  122. \pgfkeys{
  123. /metropolis/font/titleformat title/.cd,
  124. .is choice,
  125. regular/.code={%
  126. \let\metropolis@titleformat\@empty%
  127. \setbeamerfont{title}{shape=\normalfont}%
  128. },
  129. smallcaps/.code={%
  130. \let\metropolis@titleformat\@empty%
  131. \setbeamerfont{title}{shape=\scshape}%
  132. },
  133. allsmallcaps/.code={%
  134. \let\metropolis@titleformat\lowercase%
  135. \setbeamerfont{title}{shape=\scshape}%
  136. \PackageWarning{beamerthememetropolis}{%
  137. Be aware that titleformat title=allsmallcaps can lead to problems%
  138. }
  139. },
  140. allcaps/.code={%
  141. \let\metropolis@titleformat\uppercase%
  142. \setbeamerfont{title}{shape=\normalfont}
  143. \PackageWarning{beamerthememetropolis}{%
  144. Be aware that titleformat title=allcaps can lead to problems%
  145. }
  146. },
  147. }
  148. \pgfkeys{
  149. /metropolis/font/titleformat subtitle/.cd,
  150. .is choice,
  151. regular/.code={%
  152. \let\metropolis@subtitleformat\@empty%
  153. \setbeamerfont{subtitle}{shape=\normalfont}%
  154. },
  155. smallcaps/.code={%
  156. \let\metropolis@subtitleformat\@empty%
  157. \setbeamerfont{subtitle}{shape=\scshape}%
  158. },
  159. allsmallcaps/.code={%
  160. \let\metropolis@subtitleformat\lowercase%
  161. \setbeamerfont{subtitle}{shape=\scshape}%
  162. \PackageWarning{beamerthememetropolis}{%
  163. Be aware that titleformat subtitle=allsmallcaps can lead to problems%
  164. }
  165. },
  166. allcaps/.code={%
  167. \let\metropolis@subtitleformat\uppercase%
  168. \setbeamerfont{subtitle}{shape=\normalfont}%
  169. \PackageWarning{beamerthememetropolis}{%
  170. Be aware that titleformat subtitle=allcaps can lead to problems%
  171. }
  172. },
  173. }
  174. \pgfkeys{
  175. /metropolis/font/titleformat section/.cd,
  176. .is choice,
  177. regular/.code={%
  178. \let\metropolis@sectiontitleformat\@empty%
  179. \setbeamerfont{section title}{shape=\normalfont}%
  180. },
  181. smallcaps/.code={%
  182. \let\metropolis@sectiontitleformat\@empty%
  183. \setbeamerfont{section title}{shape=\scshape}%
  184. },
  185. allsmallcaps/.code={%
  186. \let\metropolis@sectiontitleformat\MakeLowercase%
  187. \setbeamerfont{section title}{shape=\scshape}%
  188. \PackageWarning{beamerthememetropolis}{%
  189. Be aware that titleformat section=allsmallcaps can lead to problems%
  190. }
  191. },
  192. allcaps/.code={%
  193. \let\metropolis@sectiontitleformat\MakeUppercase%
  194. \setbeamerfont{section title}{shape=\normalfont}%
  195. \PackageWarning{beamerthememetropolis}{%
  196. Be aware that titleformat section=allcaps can lead to problems%
  197. }
  198. },
  199. }
  200. \pgfkeys{
  201. /metropolis/font/titleformat frame/.cd,
  202. .is choice,
  203. regular/.code={%
  204. \let\metropolis@frametitleformat\@empty%
  205. \setbeamerfont{frametitle}{shape=\normalfont}%
  206. },
  207. smallcaps/.code={%
  208. \let\metropolis@frametitleformat\@empty%
  209. \setbeamerfont{frametitle}{shape=\scshape}%
  210. },
  211. allsmallcaps/.code={%
  212. \let\metropolis@frametitleformat\MakeLowercase%
  213. \setbeamerfont{frametitle}{shape=\scshape}%
  214. \PackageWarning{beamerthememetropolis}{%
  215. Be aware that titleformat frame=allsmallcaps can lead to problems%
  216. }
  217. },
  218. allcaps/.code={%
  219. \let\metropolis@frametitleformat\MakeUppercase%
  220. \setbeamerfont{frametitle}{shape=\normalfont}
  221. \PackageWarning{beamerthememetropolis}{%
  222. Be aware that titleformat frame=allcaps can lead to problems%
  223. }
  224. },
  225. }
  226. \pgfkeys{
  227. /metropolis/font/.cd,
  228. titleformattitle/.code=\pgfkeysalso{titleformat title=#1},
  229. titleformatsubtitle/.code=\pgfkeysalso{titleformat subtitle=#1},
  230. titleformatsection/.code=\pgfkeysalso{titleformat section=#1},
  231. titleformatframe/.code=\pgfkeysalso{titleformat frame=#1},
  232. }
  233. \newcommand{\metropolis@font@setdefaults}{
  234. \pgfkeys{/metropolis/font/.cd,
  235. titleformat title=regular,
  236. titleformat subtitle=regular,
  237. titleformat section=regular,
  238. titleformat frame=regular,
  239. }
  240. }
  241. \def\metropolis@titleformat#1{#1}
  242. \def\metropolis@subtitleformat#1{#1}
  243. \def\metropolis@sectiontitleformat#1{#1}
  244. \def\metropolis@frametitleformat#1{#1}
  245. \patchcmd{\beamer@title}%
  246. {\def\inserttitle{#2}}%
  247. {\def\inserttitle{\metropolis@titleformat{#2}}}%
  248. {}%
  249. {\PackageError{beamerfontthememetropolis}{Patching title failed}\@ehc}
  250. \patchcmd{\beamer@subtitle}%
  251. {\def\insertsubtitle{#2}}%
  252. {\def\insertsubtitle{\metropolis@subtitleformat{#2}}}%
  253. {}%
  254. {\PackageError{beamerfontthememetropolis}{Patching subtitle failed}\@ehc}
  255. \patchcmd{\sectionentry}
  256. {\def\insertsectionhead{#2}}
  257. {\def\insertsectionhead{\metropolis@sectiontitleformat{#2}}}
  258. {}
  259. {\PackageError{beamerfontthememetropolis}{Patching section title failed}\@ehc}
  260. \@tempswafalse
  261. \patchcmd{\beamer@section}
  262. {\edef\insertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{\unexpanded{#1}}}}
  263. {\edef\insertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{%
  264. \noexpand\metropolis@sectiontitleformat{\unexpanded{#1}}}}}
  265. {\@tempswatrue}
  266. {}
  267. \patchcmd{\beamer@section}
  268. {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}}
  269. {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{%
  270. \metropolis@sectiontitleformat{#1}}}}
  271. {\@tempswatrue}
  272. {}
  273. \patchcmd{\beamer@section}
  274. {\protected@edef\insertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{#1}}}
  275. {\protected@edef\insertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{%
  276. \noexpand\metropolis@sectiontitleformat{#1}}}}
  277. {\@tempswatrue}
  278. {}
  279. \if@tempswa\else
  280. \PackageError{beamerfontthememetropolis}{Patching section title failed}\@ehc
  281. \fi
  282. \@tempswafalse
  283. \patchcmd{\beamer@subsection}
  284. {\edef\insertsubsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{\unexpanded{#1}}}}
  285. {\edef\insertsubsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{%
  286. \noexpand\metropolis@sectiontitleformat{\unexpanded{#1}}}}}
  287. {\@tempswatrue}
  288. {}
  289. \patchcmd{\beamer@subsection}
  290. {\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{#1}}}
  291. {\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{%
  292. \metropolis@sectiontitleformat{#1}}}}
  293. {\@tempswatrue}
  294. {}
  295. \patchcmd{\beamer@subsection}
  296. {\protected@edef\insertsubsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{#1}}}
  297. {\protected@edef\insertsubsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{%
  298. \noexpand\metropolis@sectiontitleformat{#1}}}}
  299. {\@tempswatrue}
  300. {}
  301. \if@tempswa\else
  302. \PackageError{beamerfontthememetropolis}{Patching section title failed}\@ehc
  303. \fi
  304. \patchcmd{\beamer@@frametitle}
  305. {{%
  306. \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space%
  307. \usebeamertemplate*{frametitle continuation}\fi}}%
  308. \gdef\beamer@frametitle{#2}%
  309. \gdef\beamer@shortframetitle{#1}%
  310. }}
  311. {{%
  312. \gdef\insertframetitle{{\metropolis@frametitleformat{#2}\ifnum%
  313. \beamer@autobreakcount>0\relax{}\space%
  314. \usebeamertemplate*{frametitle continuation}\fi}}%
  315. \gdef\beamer@frametitle{#2}%
  316. \gdef\beamer@shortframetitle{#1}%
  317. }}
  318. {}
  319. {\PackageError{beamerfontthememetropolis}{Patching frame title failed}\@ehc}
  320. \metropolis@font@setdefaults
  321. \ProcessPgfPackageOptions{/metropolis/font}
  322. \endinput
  323. %%
  324. %% End of file `beamerfontthememetropolis.sty'.