-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeamerinnerthemebonbon.sty
245 lines (200 loc) · 10.4 KB
/
beamerinnerthemebonbon.sty
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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerinnerthemebonbon}[2017/07/30 Bonbon inner theme]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Required packages and configuration. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{calc}
\RequirePackage{tikz}
\RequirePackage{xkeyval}
% Configure libraries to be imported by TikZ.
\usetikzlibrary{
calc,
arrows
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Variables used to calculate slide dimensions and progress bar width. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Creates a new length and initializes it with the specified dimension.
\newcommand{\declength}[2]{
\newlength{#1}
\setlength{#1}{#2}
}
% The separation lengths that determine by how much the slide content is shifted
% to the right.
\declength{\smlsep}{0.4cm}
\declength{\bigsep}{0.8cm}
% The thickness with which the lines are drawn.
\declength{\linethick}{0.4pt}
% The template uses two page dimensions, the smaller one for title pages, and
% the larger one for slide content.
\declength{\smlpagewidth}{\paperwidth - (\bigsep * 2)}
\declength{\smlpageheight}{\paperheight - (\bigsep * 2)}
\declength{\bigpagewidth}{\paperwidth - (\smlsep * 2)}
\declength{\bigpageheight}{\paperheight - (\smlsep * 2)}
% The template features a progress bar which shows indicates the current
% presentation progress. It comes in two flavours, one that fits \smlpagewidth
% and the other that fits \bigpagewidth.
% The two macros below calculate the length of the progress bar in both cases.
\newlength{\smlproglen}
\newlength{\bigproglen}
%\declength{\smlprogtotal}{\smlpagewidth - \linethick}
%\declength{\bigprogtotal}{\bigpagewidth - \linethick}
%\newcommand{\updatesmlprog}{
% \ifnum\inserttotalframenumber=1\relax
% \setlength{\smlproglen}{0pt}
% \else
% \setlength{\smlproglen}{(\smlprogtotal * (\insertframenumber - 1)) / (\inserttotalframenumber - 1)}\relax
% \fi
%}
%\newcommand{\updatebigprog}{
% \ifnum\inserttotalframenumber=1\relax
% \setlength{\bigproglen}{0pt}
% \else
% \setlength{\bigproglen}{(\bigprogtotal * (\insertframenumber - 1)) / (\inserttotalframenumber - 1)}\relax
% \fi
%}
% TODO: Fix this big and nasty hack! But I was pressed with time :(
\declength{\smlprogtotal}{((\smlpagewidth - \linethick) / 100) * 100}
\declength{\bigprogtotal}{((\bigpagewidth - \linethick) / 100) * 100}
\newcommand{\updatesmlprog}{
\ifnum\inserttotalframenumber=1\relax
\setlength{\smlproglen}{0pt}
\else
\setlength{\smlproglen}{(((\smlprogtotal / 100) * (\insertframenumber - 1)) / (\inserttotalframenumber - 1)) * 100}\relax
\fi
}
\newcommand{\updatebigprog}{
\ifnum\inserttotalframenumber=1\relax
\setlength{\bigproglen}{0pt}
\else
\setlength{\bigproglen}{(((\bigprogtotal / 100) * (\insertframenumber - 1)) / (\inserttotalframenumber - 1)) * 100}\relax
\fi
}
% TODO: End nasty hack!
\def\fineprint#1{\gdef\insertfineprint{#1}}
\fineprint{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inner template styles. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{itemize items}{\textbullet}
\setbeamertemplate{description item}{\insertdescriptionitem\hfill}
\setbeamertemplate{caption}{\insertcaption}
\setbeamertemplate{caption label separator}{}
\setbeamertemplate{title page}{%
% Add this to remove the white top border that appears.
\nointerlineskip
\begin{beamercolorbox}[wd=\paperwidth, ht=\paperheight, sep=\bigsep]{title page}
\begin{tikzpicture}
% Set the smaller size of slide as the canvas over which we will draw.
\useasboundingbox (0, 0) rectangle (\smlpagewidth, \smlpageheight);
% Draw title, subtitle, author and date text.
\node [anchor=west, rotate=0, text width=\smlpagewidth] at (current bounding box.west) [font={\usebeamerfont{title}\usebeamercolor[fg]{title}}] (title) {\inserttitle};
\node [anchor=west, yshift=-0.0cm] at (title.south west) [font={\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}}] (subtitle) {\insertsubtitle};
%\node [anchor=south west, inner ysep=0] at (current bounding box.south west) [font={\usebeamerfont{subsubtitle}\usebeamercolor[fg]{subsubtitle}}] (author) {\insertauthor~$\cdot$~\insertdate};
\node [anchor=south west, inner ysep=0] at (current bounding box.south west) [font={\usebeamerfont{subsubtitle}\usebeamercolor[fg]{subsubtitle}}] (fineprint) {\tiny\insertfineprint};
\node [anchor=south west, inner ysep=4pt] at (fineprint.north west) [font={\usebeamerfont{subsubtitle}\usebeamercolor[fg]{subsubtitle}}] (institute) {\usebeamerfont{institute}\insertinstitute};
\node [anchor=south west, inner ysep=0] at (institute.north west) [font={\usebeamerfont{subsubtitle}\usebeamercolor[fg]{subsubtitle}}] (author) {\insertdate~$\cdot$~\insertauthor};
\end{tikzpicture}
\end{beamercolorbox}
}
\setbeamertemplate{frametitle}{%
% Update the length of widest (big) progress bar to be drawn. One should be
% reminded that this macro needs to be invoked in each template, as length
% variables in LaTeX are locally-scoped.
\updatebigprog
% Apply the beamer color, and use it to create a new FG color for it. This
% is used to draw the progress bar in the same same color as the frame title
% text.
% The color was not hardcoded in order to make it possible to change this
% indirectly by setting the frametitle color.
\usebeamercolor{frametitle}
\colorlet{progfg}{fg}
% Add this to remove the white top border that appears.
\nointerlineskip
\begin{beamercolorbox}[wd=\paperwidth, ht=1.4cm, sep=\smlsep]{frametitle}
\begin{tikzpicture}
\node[anchor=west, text depth=-0.2em, font={\usebeamercolor[bg]{frametitle}}] at (0, 0) [] (frametitle) {\insertframetitle};
% Draw the unfilled full progress bar, and superimpose it with the
% progress bar reflecting the current progress.
\draw[-*, color=darkash] (frametitle.south west) -- ++(\bigprogtotal, 0);
\ifnum\bigproglen=\bigprogtotal\relax
\draw[-*, color=progfg] (frametitle.south west) -- ++(\bigproglen, 0);
\else
\draw[color=progfg] (frametitle.south west) -- ++(\bigproglen, 0);
\fi
% Superimpose the frame title on the progress bar.
\node[anchor=west, text depth=-0.2em] at (0, 0) [] {\insertframetitle};
%\node[overlay, inner sep=0, anchor=east] at ($(current bounding box.east)+(0,-0.5em)$){\includegraphics[scale=0.06]{/Users/duncan/Downloads/Halloween-PNG-Images.png}};
\end{tikzpicture}
\end{beamercolorbox}
}
\AtBeginSection{\frame{\sectionpage}}
\setbeamertemplate{section page}{%
% Update the length of narrowest (sml) progress bar to be drawn. One should be
% reminded that this macro needs to be invoked in each template, as length
% variables in LaTeX are locally-scoped.
\updatesmlprog
% Apply the beamer color, and use it to create a new FG color for it. This
% is used to draw the progress bar in the same same color as the section title
% text.
% The color was not hardcoded in order to make it possible to change this
% indirectly by setting the section title color.
\usebeamercolor{section page}
\colorlet{progfg}{fg}
% Add this to remove the white top border that appears.
\nointerlineskip
\begin{beamercolorbox}[wd=\paperwidth, ht=\paperheight, sep=\bigsep]{section page}
\begin{tikzpicture}
% Set the smaller size of slide as the canvas over which we will draw.
\useasboundingbox (0, 0) rectangle (\smlpagewidth, \smlpageheight);
\node [anchor=west, text depth=-0.06em] at (current bounding box.west) [font={\usebeamerfont{section title}\usebeamercolor[bg]{section title}}] (title) {\insertsection};
% Draw the unfilled full progress bar, and superimpose it with the
% progress bar reflecting the current progress.
\draw[-*, color=darkash] (title.south west) -- ++(\smlprogtotal, 0);
\ifnum\smlproglen=\smlprogtotal\relax
\draw[-*, color=progfg] (title.south west) -- ++(\smlproglen, 0);
\else
\draw[color=progfg] (title.south west) -- ++(\smlproglen, 0);
\fi
% Superimpose the section title on the progress bar.
\node [anchor=west, text depth=-0.06em] at (current bounding box.west) [font={\usebeamerfont{section title}\usebeamercolor[fg]{section title}}] (title) {\insertsection};
\end{tikzpicture}
\end{beamercolorbox}
}
\AtBeginSubsection{\frame{\subsectionpage}}
\setbeamertemplate{subsection page} {
% Add this to remove the white top border that appears.
\nointerlineskip
\begin{beamercolorbox}[wd=\paperwidth, ht=\paperheight, sep=0pt]{subsection page}
\begin{tikzpicture}
% Set the entire slide as the canvas over which we will draw.
\useasboundingbox (0, 0) rectangle (\paperwidth, \paperheight);
\node [draw, text depth=-0.06em, rounded corners=0.6cm, line width=0.05cm, minimum height=1.2cm, minimum width=3cm, inner xsep=0.8cm, inner ysep=0] at (current bounding box.center) [font={\usebeamerfont{subsection title}\usebeamercolor[fg]{subsection title}}] (title) {\insertsubsection};
\end{tikzpicture}
\end{beamercolorbox}
}
% We do not need to use \makeatletter here (even though we are using @ in names)
% because the cat code for @ is set automatically to 11 (i.e. the catcode for
% letters) in .sty and .cls files. Note that this would however need to be set
% to 11 manually (using \makeatletter) and back to 12 (using \makeatother) in
%.tex files.
\define@key{beamerframe}{subsection}[true]{%
% TODO: Providing the color directly is not the best solution, because for
% the BW theme, then royalblue must be set to black. And I don't like it.
\setbeamercolor{frametitle}{fg=royalblue}
% TODO: Add a boolean here so that I set it at this point to on, and
% reset it once the slide title is drawn in the frametitle template.
% For now I need the user would need to employ \begingroup and \endgroup
% to manage the style himself.
\setbeamertemplate{enumerate item}{
\tikz[baseline={([yshift=-.65ex]current bounding box.center)}]{
\node[draw, semithick, inner sep=0.1em, font=\sffamily\scriptsize, align=center, rotate=0, minimum width=1em, minimum height=0.9em, rounded corners=0.45em] {\insertenumlabel};
}
}
}
\setbeamertemplate{note page}{%
\vspace{2em}
\textbf{\insertframetitle}
\vspace{0.5em}
\insertnote
}