summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/beamer-contrib/themes/beamerthemeconcrete/cfermat/beamerthemecfermat.sty
blob: e66b1f5822c18e38149728e74f592f3a213f6cd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
% -*- coding: utf-8 -*-
% ----------------------------------------------------------------------------
% Author:  Jianrui Lyu <tolvjr@163.com>
% Website: https://github.com/lvjr/concrete
% License: The LaTeX Project Public License 1.3c
% ----------------------------------------------------------------------------

\ProvidesPackage{beamerthemecfermat}[2024-01-21 v2024B Beamer Theme cFermat]

\makeatletter

% compatible with old versions of beamer
\providecommand{\beamer@endinputifotherversion}[1]{}

\RequirePackage{tikz,etoolbox,adjustbox,varwidth,multicol}
\usetikzlibrary{decorations.pathmorphing}

\mode<presentation>

\setbeamersize{text margin left=8mm,text margin right=8mm}

%% ----------------- background canvas and background ----------------

\defbeamertemplate{background}{line}{%
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
    \draw[xstep=\paperwidth,ystep=1mm,color=tcolor] (0,0) grid (\paperwidth,\paperheight);
  \end{tikzpicture}%
}

\defbeamertemplate{background}{linear}{%
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
    \draw[pattern=horizontal lines, pattern color=tcolor]
      (0,0) rectangle (\paperwidth,\paperheight);
  \end{tikzpicture}%
}

\defbeamertemplate{background}{lattice}{%
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
    \draw[step=1mm,color=tcolor] (0,0) grid (\paperwidth,\paperheight);
  \end{tikzpicture}%
}

% need "text badly ragged" option for correct space skips
% see http://tex.stackexchange.com/a/132748/8956
\gdef\my@background@title
{%
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
  \fill[draw=dcolor,fill=fcolor]
    (0,0.25\paperheight) -- (0,0) -- (\paperwidth,0)
       -- (\paperwidth,0.25\paperheight) decorate[decoration={snake,segment length=3.15mm}] { -- cycle };
  \fill[draw=dcolor,fill=fcolor]
    (0,0.85\paperheight) -- (0,\paperheight) -- (\paperwidth,\paperheight)
       -- (\paperwidth,0.85\paperheight) decorate[decoration={snake,segment length=3.15mm}] { -- cycle };
  \node[text width=0.9\paperwidth,text badly ragged] at (0.5\paperwidth,0.925\paperheight) {%
    \begin{minipage}[c][0.15\paperheight]{0.9\paperwidth}%
      \centering
      \usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate
    \end{minipage}
  };
  \node[text width=0.9\paperwidth,text badly ragged] at (0.5\paperwidth,0.55\paperheight) {%
    \begin{minipage}[c][0.6\paperheight]{0.9\paperwidth}
      \centering
      \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle
      \ifx\insertsubtitle\@empty\else
        \\[5pt]\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}
        \insertsubtitle
      \fi
    \end{minipage}
  };
  \node[text width=0.9\paperwidth,text badly ragged] at (0.5\paperwidth,0.125\paperheight) {%
    \begin{minipage}[c][0.25\paperheight]{0.9\paperwidth}
      \centering
      \usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor\\[3pt]
      \usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute
    \end{minipage}
  };
  \end{tikzpicture}
}

\gdef\my@background@section
{%
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
  \fill[draw=dcolor,fill=fcolor]
    (0,0.12\paperheight) -- (0,0) -- (\paperwidth,0)
       -- (\paperwidth,0.12\paperheight) decorate[decoration={snake,segment length=3.15mm}] { -- cycle };
  \fill[draw=dcolor,fill=fcolor]
    (0,0.92\paperheight) -- (0,\paperheight) -- (\paperwidth,\paperheight)
       -- (\paperwidth,0.92\paperheight) decorate[decoration={snake,segment length=3.15mm}] { -- cycle };
  \node[text width=0.9\paperwidth,text badly ragged] at (0.5\paperwidth,0.52\paperheight) {%
    \begin{minipage}[c]{0.9\paperwidth}
      \usebeamertemplate{section page content}%
    \end{minipage}
  };
  \end{tikzpicture}
}

\gdef\my@background@subsection
{%
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
  \fill[draw=dcolor,fill=fcolor]
    (0,0.12\paperheight) -- (0,0) -- (\paperwidth,0)
       -- (\paperwidth,0.12\paperheight) decorate[decoration={snake,segment length=3.15mm}] { -- cycle };
  \fill[draw=dcolor,fill=fcolor]
    (0,0.92\paperheight) -- (0,\paperheight) -- (\paperwidth,\paperheight)
       -- (\paperwidth,0.92\paperheight) decorate[decoration={snake,segment length=3.15mm}] { -- cycle };
  \node[text width=0.9\paperwidth,text badly ragged] at (0.5\paperwidth,0.52\paperheight) {%
    \begin{minipage}[c]{0.9\paperwidth}
      \usebeamertemplate{subsection page content}%
    \end{minipage}
  };
  \end{tikzpicture}
}

%% -------------------------- title page -----------------------------

\defbeamertemplate{title page}{snake}
{%
  \nointerlineskip
  \begin{adjustbox}{width=\paperwidth,center}%
    \my@background@title
  \end{adjustbox}%
}

%% ----------------------- section and subsection --------------------

\patchcmd{\@vwid@sift}{\PackageWarning{varwidth}{Failed to reprocess entire contents}}{}{}{}

\def\sectionintocskip{0.5em}
\patchcmd{\beamer@sectionintoc}{\vskip1.5em}{\vskip\sectionintocskip}{}{}
% patch for centering toc with varwidth package
\patchcmd{\beamer@sectionintoc}{%
  \hbox{\vbox{%
    \def\beamer@breakhere{\\}%
    \beamer@tocact{\ifnum\c@section=#1\beamer@toc@cs\else\beamer@toc@os\fi}{section in toc}}}%
}{%
  \hbox{%
    \def\beamer@breakhere{}%
    \beamer@tocact{\ifnum\c@section=#1\beamer@toc@cs\else\beamer@toc@os\fi}{section in toc}}%
}{}{}
% patch for centering toc in pdflatex with varwidth package
\let\my@beamer@subsectionintoc=\beamer@subsectionintoc
\patchcmd{\my@beamer@subsectionintoc}{%
  \def\beamer@breakhere{\\}%
  \beamer@tocact{\ifnum\c@section=#1\ifnum\c@subsection=#2\beamer@toc@css\else\beamer@toc@oss\fi\else\beamer@toc@ooss\fi}
  {subsection in toc}%
}{%
  \def\beamer@breakhere{}%
  \ifnum\c@section=#1\ifnum\c@subsection=#2%
    \vskip.5em\hbox{\beamer@tocact\beamer@toc@css{subsection in toc}}%
  \else
    \vskip.5em\hbox{\beamer@tocact\beamer@toc@oss{subsection in toc}}%
  \fi\fi
}{}{}

% create new template for section
\defbeamertemplate{section}{simple}{%
  \insertsectionnumber.\hspace*{1ex}\insertsection%
}

\defbeamertemplate{at begin section}{normal}{%
  \frame{\sectionpage}
}
\defbeamertemplate{at begin section}{plain}{%
  \frame[plain]{\sectionpage}
}
\AtBeginSection[]{\usebeamertemplate{at begin section}}

\defbeamertemplate{section page}{snake}{%
  \nointerlineskip
  \begin{adjustbox}{width=\paperwidth,center}%
    \my@background@section
  \end{adjustbox}%
}

\defbeamertemplate{section page content}{simple}{
  \begin{beamercolorbox}[wd=\textwidth,center]{section title}%
    \usebeamerfont{section title}
    \usebeamertemplate{section}%
  \end{beamercolorbox}
}
\defbeamertemplate{section page content}{level}{
  \begin{center}
  \begin{varwidth}{\textwidth}
    \tableofcontents[sectionstyle=show/shaded,subsectionstyle=hide]
  \end{varwidth}
  \end{center}
}
\defbeamertemplate{section page content}{split}{
  \begin{multicols}{2}
    \tableofcontents[sectionstyle=show/shaded,subsectionstyle=shaded]
  \end{multicols}
}

% create new template for subsection
\defbeamertemplate{subsection}{simple}{%
  \insertsectionnumber.\insertsubsectionnumber\hspace*{2ex}\insertsubsection%
}

\defbeamertemplate{at begin subsection}{normal}{%
  \frame{\subsectionpage}
}
\defbeamertemplate{at begin subsection}{plain}{%
  \frame[plain]{\subsectionpage}
}
\AtBeginSubsection[]{\usebeamertemplate{at begin subsection}}

\defbeamertemplate{subsection page}{snake}{%
  \nointerlineskip
  \begin{adjustbox}{width=\paperwidth,center}%
    \my@background@subsection
  \end{adjustbox}%
}

\defbeamertemplate{subsection page content}{simple}{
  \begin{beamercolorbox}[wd=\textwidth,center]{subsection title}%
  \usebeamerfont{subsection title}%
  \usebeamertemplate{subsection}%
  \end{beamercolorbox}%
}
\defbeamertemplate{subsection page content}{level}{
  \begin{center}
  \let\beamer@subsectionintoc=\my@beamer@subsectionintoc
  \begin{varwidth}{\textwidth}
    \tableofcontents[sectionstyle=hide,subsectionstyle=show/shaded/hide]
  \end{varwidth}
  \end{center}
}
\defbeamertemplate{subsection page content}{split}{
  \begin{multicols}{2}
    \tableofcontents[sectionstyle=show/shaded,subsectionstyle=show/shaded]
  \end{multicols}
}

\defbeamertemplate{subsection in toc}{triangle}{%
  \leavevmode\leftskip=2.5em\scriptsize\raise1.25pt%
  \rlap{\hskip-1.5em\donotcoloroutermaths$\blacktriangleright$}%
  \normalsize\inserttocsubsection\par
}

%% ---------------------- headline and footline ----------------------

\newif\ifmy@subsection \my@subsectionfalse

\newcommand{\my@sectionentry}[5]{%
  \hfill
  \ifnum\c@section=#1%
    \usebeamercolor{footline highlight}%
  \else%
    \usebeamercolor{footline}%
  \fi%
  \hyperlink{Navigation#3}{%
    \colorbox{bg}{%
      \hspace{0.2em}\rule[-1ex]{0pt}{3.25ex}\color{fg}#2\hspace{0.2em}%
    }%
  }%
  \let\slideentry=\my@slideentry
}

\newcommand{\my@subsectionentry}[5]{\my@subsectiontrue}

\newcommand{\my@slideentry}[6]{%
  \ifmy@subsection
    \usebeamercolor{footline}%
    \def\my@box{$\circ$}%
    \ifnum\c@section=#1%
      \usebeamercolor{footline highlight}%
      \ifnum\c@subsection=#2%
        \def\my@box{$\bullet$}%
      \fi
    \fi
    \beamer@link(#4){%
      \colorbox{bg}{%
        \rule[-1ex]{0pt}{3.25ex}\hspace{0.1em}\color{fg}\my@box\hspace{0.1em}%
      }%
    }%
    \my@subsectionfalse
  \fi
}

\defbeamertemplate{footline}{progress}{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=0.6pt,sep=0pt]{separator line}
  \end{beamercolorbox}
  \nointerlineskip
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex]{footline}%
    \usebeamerfont{footline}%
    \kern\beamer@leftmargin
    \setlength{\fboxsep}{0pt}%
    \let\sectionentry=\my@sectionentry
    \let\beamer@subsectionentry=\my@subsectionentry
    \hskip 0pt plus -1fill\dohead
    \hskip 0pt plus 9fill\relax
    \Acrobatmenu{GoToPage}{\insertframenumber{}/\inserttotalframenumber}%
    \kern\beamer@rightmargin
  \end{beamercolorbox}%
}

%% ------------------------- frame title -----------------------------

\defbeamertemplate{frametitle}{simple}{%
  \nointerlineskip
  \begin{beamercolorbox}[wd=\paperwidth,sep=0pt,leftskip=\beamer@leftmargin,%
                         rightskip=\beamer@rightmargin]{frametitle}
    \usebeamerfont{frametitle}%
    \rule[-3.6mm]{0pt}{12mm}\insertframetitle\rule[-3.6mm]{0pt}{12mm}\par
  \end{beamercolorbox}
  \nointerlineskip
  \begin{beamercolorbox}[wd=\paperwidth,ht=0.6pt,sep=0pt]{separator line}
  \end{beamercolorbox}
}

%% --------------------------- font theme ----------------------------

\setbeamerfont{title}{size=\LARGE}
\setbeamerfont{subtitle}{size=\large}
\setbeamerfont{author}{size=\large}
\setbeamerfont{institute}{size=\normalsize}
\setbeamerfont{date}{size=\large}
\setbeamerfont{section in toc}{size=\large}
\setbeamerfont{subsection in toc}{size=\large}
\setbeamerfont{frametitle}{size=\large}
\setbeamerfont{block title}{size=\normalsize}

\usefonttheme{professionalfonts}
%\usepackage{arev}

%\setlength{\parskip}{5pt plus 1pt minus 1pt}

%% ---------------------------- color theme --------------------------

% always use rgb colors in pdf files
\substitutecolormodel{hsb}{rgb}

\definecolor{red99}{Hsb}{0,0.9,0.9}
\definecolor{brown49}{Hsb}{30,0.4,0.9}
\definecolor{yellow29}{Hsb}{60,0.2,0.9}
\definecolor{yellow86}{Hsb}{60,0.8,0.6}
\definecolor{cyan95}{Hsb}{180,0.9,0.5}
\definecolor{blue77}{Hsb}{240,0.7,0.7}
\definecolor{blue99}{Hsb}{240,0.9,0.9}
\definecolor{magenta88}{Hsb}{300,0.8,0.8}

\colorlet{text1}{black}
\colorlet{back1}{white}
\colorlet{accent1}{blue99}
\colorlet{accent2}{cyan95}
\colorlet{accent3}{red99}
\colorlet{accent4}{yellow86}
\colorlet{accent5}{magenta88}
\colorlet{filler1}{accent1!40!back1}
\colorlet{filler2}{accent2!40!back1}
\colorlet{filler3}{accent3!40!back1}
\colorlet{filler4}{accent4!40!back1}
\colorlet{filler5}{accent5!40!back1}
\colorlet{tcolor}{text1!10!back1}
\colorlet{dcolor}{cyan95}
\colorlet{fcolor}{brown49}

\setbeamercolor{normal text}{bg=yellow29,fg=black}
\setbeamercolor{structure}{fg=blue99}
\setbeamercolor{local structure}{fg=cyan95}
\setbeamercolor{footline}{bg=brown49,fg=black}
\setbeamercolor{footline highlight}{parent=footline,bg=filler2}
\setbeamercolor{separator line}{bg=accent2}
\setbeamercolor{title}{use=structure,fg=structure.fg}
\setbeamercolor{subtitle}{use={structure,normal text},fg=structure.fg!90!normal text.bg}
\setbeamercolor{section in toc}{parent=title}
\setbeamercolor{subsection in toc}{parent=subtitle}
\setbeamercolor{section in toc shaded}{parent=normal text}
\setbeamercolor{subsection in toc shaded}{parent=normal text}
\setbeamercolor{frametitle}{fg=text1,bg=brown49}
\setbeamercolor{theoremname}{parent=subtitle}
\setbeamercolor{proofname}{parent=subtitle}
\setbeamercolor{block title}{fg=accent1,bg=gray}
\setbeamercolor{block body}{bg=lightgray}
\setbeamercolor{block title example}{fg=accent2,bg=gray}
\setbeamercolor{block body example}{bg=lightgray}
\setbeamercolor{block title alerted}{fg=accent3,bg=gray}
\setbeamercolor{block body alerted}{bg=lightgray}

%% ------------------------ select templates -------------------------

\setbeamertemplate{background canvas}[default]
\setbeamertemplate{background}[line]
\setbeamertemplate{footline}[progress]
\setbeamertemplate{title page}[snake]
\setbeamertemplate{at begin section}[plain]
\setbeamertemplate{at begin subsection}[plain]
\setbeamertemplate{section page}[snake]
\setbeamertemplate{section page content}[level]
\setbeamertemplate{subsection page}[snake]
\setbeamertemplate{subsection page content}[level]
\setbeamertemplate{frametitle}[simple]
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{section}[simple]
\setbeamertemplate{subsection}[simple]
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\setbeamertemplate{section in toc shaded}[default][100]
\setbeamertemplate{subsection in toc shaded}[default][100]
\setbeamertemplate{itemize items}[default]
\setbeamertemplate{enumerate items}[default]

%% ----------------------- handout mode ------------------------------

\mode<handout>{
  \setbeamertemplate{background canvas}{}
  \setbeamertemplate{background}{}
  \colorlet{dcolor}{darkgray}
  \colorlet{fcolor}{white}
  \setbeamercolor{normal text}{fg=black, bg=white}
  \setbeamercolor{footline highlight}{bg=,fg=blue99}
  \setbeamercolor{title}{fg=blue}
  \setbeamercolor{subtitle}{fg=blue!70!gray}
  \setbeamercolor{section in toc}{fg=blue!90!gray}
  \setbeamercolor{subsection in toc}{fg=blue!80!gray}
  \setbeamercolor{section in toc shaded}{fg=lightgray}
  \setbeamercolor{subsection in toc shaded}{fg=lightgray}
  \setbeamercolor{frametitle}{fg=blue!70!gray,bg=}
  \setbeamercolor{theoremname}{fg=blue!60!gray}
  \setbeamercolor{proofname}{fg=blue!60!gray}
  \setbeamercolor{footline}{bg=white,fg=black}
}

\mode
<all>

\makeatother