-
Notifications
You must be signed in to change notification settings - Fork 0
/
zafu.sty
293 lines (249 loc) · 8.64 KB
/
zafu.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
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
\ProvidesPackage{zafu}
% required packages
\RequirePackage{etoolbox}
\RequirePackage{tikz}
\RequirePackage{listings}
\RequirePackage{graphicx}
\RequirePackage{geometry}
\RequirePackage{amsfonts, amsmath, bm, oldgerm, lmodern} % math
\RequirePackage{verbatim}
\RequirePackage{animate}
\RequirePackage{xcolor}
% --- package options ---
% languages
\newcommand{\tocStr}{Table of Contents}
\newcommand{\qaStr}{\textsl{Thank you for listening! \\ Your feedback will be highly appreciated!}}
\DeclareOption{en}{
\renewcommand{\tocStr}{Table of Contents}
\renewcommand{\qaStr}{\textsl{Thank you for listening! \\ Your feedback will be highly appreciated!}}
}
\DeclareOption{zh}{
% add to the preamble: \usepackage{xeCJK}
% compile with xeLaTeX
\renewcommand{\tocStr}{目录}
\renewcommand{\qaStr}{\textbf{感谢您的聆听和反馈}}
}
\newcommand{\maincolorRGB}{0, 137, 68}
\newcommand{\greenLogoPath}{src/green-logo.png}
\newcommand{\whiteLogoPath}{src/white-logo.png}
\newcommand{\coverPath}{src/cover.png}
\ProcessOptions\relax
% --- typeset & elements settings ---
% force 16:9 aspect ratio
\geometry{paperwidth=16cm,paperheight=9cm}
% logo
\pgfdeclareimage[width=0.09\paperwidth]{greenLogo}{\greenLogoPath}
\pgfdeclareimage[width=0.09\paperwidth]{whiteLogo}{\whiteLogoPath}
\newcommand{\@makelogo}{greenLogo}
\setbeamertemplate{headline}{\hspace{0.06\textwidth}\pgfuseimage{\@makelogo}} % put the logo in each slide's top left area
% color
\definecolor{maincolor}{RGB}{\maincolorRGB}
\definecolor{airforceblue}{rgb}{0.36, 0.54, 0.66}
\definecolor{morelightgray}{rgb}{0.9, 0.9, 0.9}
\newcommand{\themecolor}[1]{
\ifstrequal{#1}{colorbg}{
\renewcommand{\@makelogo}{whiteLogo}
\setbeamercolor{normal text}{fg=white, bg=maincolor}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{block title}{fg=maincolor, bg=sintefgrey}
\setbeamercolor{block body}{fg=maincolor, bg=sintefgrey}
}{
\renewcommand{\@makelogo}{greenLogo}
\setbeamercolor{normal text}{fg=darkgray, bg=white}
\setbeamercolor{structure}{fg=maincolor}
\setbeamercolor{block title}{fg=airforceblue, bg=morelightgray}
\setbeamercolor{block body}{fg=darkgray, bg=morelightgray}
}
}
\themecolor{white} % default: white theme
% P.S. Beamer colors should be set in the preamble. It often works fine in the document itself, but NOT for normal text foreground. Thus \themecolor should only be called from the preamble
\setbeamercolor{title}{fg=maincolor}
\setbeamercolor{alerted text}{fg=maincolor}
\setbeamercolor{author}{fg=black}
\setbeamercolor{date}{fg=black}
% font
% \renewcommand{\familydefault}{\sfdefault} % sans-serif
\usefonttheme{serif}
\setbeamerfont{title}{series=\mdseries, size=\Large}
\setbeamerfont{subtitle}{series=\mdseries, size=\normalsize}
\setbeamerfont{author}{size=\normalsize}
\setbeamerfont{date}{size=\normalsize}
\setbeamerfont{frametitle}{series=\bfseries}
\setbeamerfont{framesubtitle}{series=\mdseries}
\setbeamerfont{block title}{series=\centering, size=\small}
\setbeamerfont{block body}{size=\scriptsize}
\setbeamerfont{footline}{size=\scriptsize}
% no navigation symbols
\setbeamertemplate{navigation symbols}{}
% footline
\newcommand{\@footlinepayoff}{\@SINTEFmotto}
\setbeamertemplate{footline}{
\begin{beamercolorbox}[wd=\textwidth, ht=5mm, dp=3mm, rightskip=1cm]{footline}
\usebeamerfont{footline}\hfill\@footlinepayoff
\end{beamercolorbox}
}
\newcommand{\footlinecolor}[1]{
% if #1 is empty, makes footline transparent
\ifstrempty{#1}{
\renewcommand{\@footlinepayoff}{}
\setbeamercolor{footline}{bg=}
\setbeamercolor{block title}{fg=white, bg=maincolor}
\setbeamercolor{block body}{fg=white, bg=maincolor}
}{
\renewcommand{\@footlinepayoff}{\@SINTEFmotto}
\setbeamercolor{footline}{fg=white, bg=#1}
\setbeamercolor{block title}{fg=white, bg=#1}
\setbeamercolor{block body}{fg=white, bg=#1}
}
}
\footlinecolor{} % default: no footline
% block
\setbeamertemplate{blocks}[rounded]
% bullets
\setbeamertemplate{itemize item}{\textbullet}
\setbeamertemplate{itemize subitem}{\textemdash}
\setbeamertemplate{itemize subsubitem}{\ensuremath{\circ}}
% table of cotents
\setbeamertemplate{section in toc}{$\blacktriangleright$~\inserttocsection} % section name format
\setbeamertemplate{subsection in toc}{} % don't present subsection
% code bolck setting
\definecolor{codegreen}{RGB}{101,218,120}
\definecolor{darkgreen}{RGB}{93,158,82}
\definecolor{darkyellow}{RGB}{245,194,105}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
commentstyle=\color{airforceblue},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{white},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\scriptsize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=4,
xleftmargin=10pt,
xrightmargin=10pt,
}
\lstset{style=mystyle}
% --- section & frame setting ---
% subsection
\newcommand{\strsubsec}{Section \thesection.\thesubsection}
% presents subtitle on each frame
\makeatletter
\pretocmd\beamer@checkframetitle{\framesubtitle{\thesection \, \secname}}
\makeatother
% avoid numbering of frames that are breaked into multiply slides
\setbeamertemplate{frametitle continuation}{}
% section page with the current section highlighted
\AtBeginSection[]
{
\begingroup
\setbeamertemplate{footline}{}
\themecolor{colorbg}
\begin{frame}{\tocStr}
\tableofcontents[currentsection]
\end{frame}
\endgroup
}
% subsection title page
\AtBeginSubsection[]
{
\begin{frame}{\,}{\thesection \, \secname}
\fontfamily{ptm}\selectfont
\centering\textsl{\textbf{\textcolor{maincolor}{
\large Section \thesection.\thesubsection
\vskip15pt
\LARGE \subsecname
}}}
\end{frame}
}
% --- page elements ---
% frame title & subtitle layout
\setbeamertemplate{frametitle}{
\vspace*{-3.5ex}
\begin{beamercolorbox}[leftskip=2cm]{frametitle}
\usebeamerfont{frametitle}\insertframetitle\\
\usebeamerfont{framesubtitle}\insertframesubtitle
\end{beamercolorbox}
}
% title page
\setbeamertemplate{title page}{
\hspace{-12mm} % pull back the box in an inelegant way - but it works!
\begin{beamercolorbox}[wd=0.9\textwidth, sep=10pt, leftskip=8mm]{title}
{\usebeamerfont{title}\inserttitle}\\
\vskip5pt{\usebeamerfont{subtitle}\insertsubtitle}\\
\vskip5pt{\usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor}\\
\vskip5pt{\usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate}
\end{beamercolorbox}
}
\renewcommand{\maketitle}{
\begingroup
\setbeamertemplate{footline}{}
\setbeamertemplate{background}{
\includegraphics[height=\paperheight]{\coverPath}
}
\begin{frame}
\titlepage
\end{frame}
\endgroup
}
% Q&A page
\newcommand{\QApage}{
\begingroup
\setbeamertemplate{footline}{}
\themecolor{colorbg}
\begin{frame}{}
\centering
\begin{minipage}{\textwidth}
\usebeamercolor[fg]{normal text}
\centering
\Huge $$\mathcal Q \& \mathcal A$$
\Large \qaStr
\end{minipage}
\end{frame}
\endgroup
}
% bibliography page
\newcommand{\bibliographpage}{
\section{References}
\begingroup
\themecolor{colorbg}
\begin{frame}[allowframebreaks]{References}{\,}
\tiny
\printbibliography[heading=none]
\end{frame}
\endgroup
}
% --- commands ---
% set colored hyperlinks command
\newcommand{\bhref}[2]{\textcolor{airforceblue}{\href{#1}{#2}}}
% centering paragraph statement
\newcommand{\centerstate}[1]{
\centering
\begin{columns}
\begin{column}{0.8\textwidth}
#1
\end{column}
\end{columns}
}
\newcommand{\tbf}[1]{\texttt{\textcolor{airforceblue}{[#1]}}}
% coloured textbf
\newcommand{\ctextbf}[1]{\textbf{\textcolor{maincolor}{#1}}}
\newcommand{\btextbf}[1]{\textbf{\textcolor{airforceblue}{#1}}}
% coloured textsl
\newcommand{\ctextsl}[1]{\textsl{\textcolor{maincolor}{#1}}}
\newcommand{\btextsl}[1]{\textsl{\textcolor{airforceblue}{#1}}}
% coloured emph
\newcommand{\cemph}[1]{\emph{\textcolor{maincolor}{#1}}}
\newcommand{\bemph}[1]{\emph{\textcolor{airforceblue}{#1}}}
% coloured texttt
\newcommand{\ctexttt}[1]{\texttt{\textcolor{maincolor}{#1}}}
\newcommand{\btexttt}[1]{\texttt{\textcolor{airforceblue}{#1}}}