Debian Codegraph @

texmf-dist/source/latex/beamertheme-westlake/beamertheme-westlake.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: beamertheme-westlake.dtx
4 % -----------------------------------------------------------------------
5 % Copyright (C) 2026 by Mingyu Xia <[email protected]> *
6 % -----------------------------------------------------------------------
7 % This work may be distributed and/or modified under the conditions *
8 % of the LaTeX Project Public License (LPPL), either version 1.3c of *
9 % this license or (at your option) any later version. *
10 % The latest version of this license is in *
11 % *
12 % http://www.latex-project.org/lppl.txt *
13 % *
14 % and version 1.3c or later is part of all distributions of LaTeX *
15 % version 2008 or later. *
16 % *
17 % This work has the LPPL maintenance status `maintained'. *
18 % *
19 % The Current Maintainer of this work is Mingyu Xia. *
20 % -----------------------------------------------------------------------
21 % This work consists of the files beamertheme-westlake.dtx, *
22 % beamertheme-westlake.ins, *
23 % the derived files beamerthemewestlake.sty, *
24 % the documentation files beamertheme-westlake.pdf, *
25 % and README.md. *
26 % -----------------------------------------------------------------------
27 % *
28 % Any modification of this file should ensure that the copyright and *
29 % license information is placed in the derived files. *
30 % *
31 % -----------------------------------------------------------------------
32 %
33 %<*internal>
34 \iffalse
35 %</internal>
36 %
37 %<*readme>
38 [![CTAN Version](https://img.shields.io/ctan/v/beamertheme-westlake)](https://ctan.org/pkg/beamertheme-westlake)
39 [![GitHub Release](https://img.shields.io/github/v/release/myhsia/beamertheme-westlake)](https://github.com/myhsia/beamertheme-westlake/releases/latest)
40 [![GitHub Last Commit](https://img.shields.io/github/last-commit/myhsia/beamertheme-westlake)](https://github.com/myhsia/beamertheme-westlake/commits)
41 [![Actions Status](https://github.com/myhsia/beamertheme-westlake/actions/workflows/main.yaml/badge.svg?branch=main)](https://github.com/myhsia/beamertheme-westlake/actions)
42 [![GitHub Repo stars](https://img.shields.io/github/stars/myhsia/beamertheme-westlake)](https://github.com/myhsia/beamertheme-westlake)
43
44 The `westlake` Beamer Theme
45 ===========================
46
47 The `westlake` Beamer theme is inspired by West Lake, a famous freshwater lake
48 in Hangzhou, China, and also inspired by Westlake University.
49
50 Overview
51 --------
52
53 To load this theme under the `beamer` class, write the lines
54
55 \usetheme[logobg.op = <file>, logobg = <file>, lbadge = <file>,
56 mainbg.op = <file>, mainbg = <file>, rbadge = <file>,
57 basebg.op = <file>, basebg = <file>, themeRGB = <RGB>]{westlake}
58
59 to set the theme color and graphics.
60
61 See `beamertheme-westlake.pdf` for more. Happy TeXing!
62
63 Issues
64 ------
65
66 The issue tracker for `beamertheme-westlake` is currently located
67 [on GitHub](https://github.com/myhsia/beamertheme-westlake/issues).
68
69 Build status
70 ------------
71
72 This project uses [GitHub Actions](https://github.com/features/actions)
73 as a hosted continuous integration service. For each commit, the build status
74 is tested using the current release of TeX Live.
75
76 _Current build status:_ ![build status](https://github.com/myhsia/beamertheme-westlake/actions/workflows/main.yaml/badge.svg?branch=main)
77
78 Copyright and License
79 ---------------------
80
81 Copyright (C) 2026 by Mingyu Xia \<[email protected]\>
82
83 This work may be distributed and/or modified under the conditions
84 of the LaTeX Project Public License (LPPL), either version 1.3c of
85 this license or (at your option) any later version.
86 The latest version of this license is in
87
88 http://www.latex-project.org/lppl.txt
89
90 and version 1.3c or later is part of all distributions of LaTeX
91 version 2008 or later.
92
93 This work has the LPPL maintenance status `maintained'.
94
95 The Current Maintainer of this work is **Mingyu Xia**.
96 %</readme>
97 %
98 %<*internal>
99 \fi
100 %</internal>
101 %
102 %<*driver>
103 \documentclass[11pt, letterpaper, cs-break = true]{l3doc}
104 \usepackage[osf, mono = false]{libertine}
105 \usepackage{pdfpages}
106 \newcommand \mail[1]{\href{mailto:#1}{\ttfamily #1}}
107 \begin{document}
108 \DocInput{\jobname.dtx}
109 \end{document}
110 %</driver>
111 % \fi
112 %
113 % \begin{documentation}
114 %
115 % \title{The \pkg{Westlake} Beamer Theme\thanks{\parbox[t]{.8\linewidth}{^^A
116 % \url{https://github.com/myhsia/beamertheme-westlake},\\
117 % \url{https://ctan.org/pkg/beamertheme-westlake}}}^^A
118 % }
119 %
120 % \author{Mingyu Xia\thanks{\mail{[email protected]}}}
121 % \makeatletter
122 % \date{Released 2026-03-06\quad \texttt{v0.2A}}
123 % \makeatother
124 % \maketitle
125 %
126 % \begin{abstract}
127 % The \pkg{Westlake} Beamer Theme is inspired by West Lake,
128 % a famous freshwater lake in Hangzhou, China,
129 % and also inspired by Westlake University.
130 % \end{abstract}
131 %
132 % \section{Introduction \& Usage}
133 %
134 % The introduction and usage instructions for the \pkg{Westlake} Beamer Theme
135 % are included in \file{\jobname-demo.pdf}, which is also attached in the
136 % following 3 pages.
137 %
138 % The demo loads the theme with the following lines
139 % \begin{quote}
140 % \cs{usetheme}"[logobg = "\file{westlake-logo.pdf}","\\
141 % " lbadge = "\file{westlake-badge.pdf}","\\
142 % " mainbg = "\file{westlake-paint.png}","\\
143 % " basebg = "\file{plain.png}"]{westlake}"
144 % \end{quote}
145 % The code of the theme is implemented after the demo pages.
146 %
147 % \includepdf[nup = 1x2, pages = -, frame, delta = 0 .125in]{\jobname-demo.pdf}
148 %
149 % \end{documentation}
150 % \appendix
151 % \begin{implementation}
152 % \section{The Source Code}
153 % Start the optionlist package for \pkg{l3docstrip}.
154 % \begin{macrocode}
155 %<*package>
156 % \end{macrocode}
157 % Declare the package information.
158 % \begin{macrocode}
159 \def \westlake@date {2026-03-06}
160 \def \westlake@version {v0.2A}
161 \ProvidesPackage{beamerthemewestlake}%
162 [\westlake@date\ \westlake@version Westlake beamer theme]
163 % \end{macrocode}
164 % Switch to presentation mode.
165 % \begin{macrocode}
166 \mode<presentation>
167 % \end{macrocode}
168 % Set up the options.
169 % \begin{macrocode}
170 \DeclareOptionBeamer{themeRGB} {\definecolor{westlake}{RGB}{#1}}
171 \DeclareOptionBeamer{lbadge} {\gdef \westlake@lbadge {#1}}
172 \DeclareOptionBeamer{rbadge} {\gdef \westlake@rbadge {#1}}
173 \DeclareOptionBeamer{logobg} {\gdef \westlake@logobg {#1}}
174 \DeclareOptionBeamer{logobg.op} {\gdef \westlake@logobg@op {#1}}
175 \DeclareOptionBeamer{mainbg} {\gdef \westlake@mainbg {#1}}
176 \DeclareOptionBeamer{mainbg.op} {\gdef \westlake@mainbg@op {#1}}
177 \DeclareOptionBeamer{basebg} {\gdef \westlake@basebg {#1}}
178 \DeclareOptionBeamer{basebg.op} {\gdef \westlake@basebg@op {#1}}
179 \ExecuteOptionsBeamer{themeRGB = {0, 70, 134},
180 logobg.op = .1, mainbg.op = .16, basebg.op = .8}
181 \ProcessOptionsBeamer
182 % \end{macrocode}
183 % Configure the theme color and the inner theme.
184 % \begin{macrocode}
185 \usecolortheme[named = westlake]{structure}
186 \useinnertheme{rounded}
187 % \end{macrocode}
188 % Load the \pkg{tikz} package with the \pkg{fadings} library.
189 % \begin{macrocode}
190 \RequirePackage{tikz}
191 \usetikzlibrary{fadings}
192 % \end{macrocode}
193 % \begin{variable}[int]{\ifsection}
194 % A boolean variable to indicate whether the current page is a section page.
195 % \begin{macrocode}
196 \newif \ifsection
197 % \end{macrocode}
198 % \end{variable}
199 % Configure the section page.
200 % \begin{macrocode}
201 \AtBeginSection[]{%
202 \sectiontrue
203 \begin{frame}
204 \tikz [remember picture, overlay] {%
205 \ifcsname westlake@lbadge\endcsname
206 \node [below right, shift = {(.5ex,-1em)}]
207 at (current page.north west)
208 {\includegraphics
209 [height = \dimeval{2\paperheight/15}]{\westlake@lbadge}};
210 \fi
211 \ifcsname westlake@rbadge\endcsname
212 \node [below left, shift = {(-.5ex,-1em)}]
213 at (current page.north east)
214 {\includegraphics
215 [height = \dimeval{2\paperheight/15}]{\westlake@rbadge}};
216 \fi
217 }
218 \vfill
219 \usebeamerfont{title}\bfseries \color{westlake}%
220 \insertsectionhead \par
221 \tikz{%
222 \draw [ultra thick, line cap = round, westlake!20]
223 (0,0) --++ (2\linewidth/3,0);
224 \filldraw [ultra thick, line cap = round, westlake!60, path fading = west]
225 (0,0) --++
226 (\fpeval{\insertpagenumber/\insertdocumentendpage * 2/3}\linewidth,0);
227 }
228 \vfill
229 \end{frame}
230 \sectionfalse
231 }
232 % \end{macrocode}
233 % Configure the background.
234 % \begin{macrocode}
235 \usebackgroundtemplate{%
236 \tikz [remember picture, overlay] {%
237 \ifnum \insertpagenumber=1
238 \ifcsname westlake@mainbg\endcsname
239 \node [above, inner sep = 0pt, opacity = \westlake@mainbg@op]
240 at (current page.south)
241 {\includegraphics
242 [width = \paperwidth, height = \paperwidth]{\westlake@mainbg}};
243 \fi
244 \fill [westlake!90]
245 (current page.south west) --++ ({-pi/6*\paperwidth},.4)
246 cos + ({(1/18+pi/12)*\paperwidth},+.4)
247 sin + ({(1/18+pi/12)*\paperwidth},+.4)
248 cos + ({(1/18+pi/12)*\paperwidth},-.4)
249 sin + ({(1/18+pi/12)*\paperwidth},-.4)
250 cos + ({(1/18+pi/12)*\paperwidth},+.4) --
251 (current page.south east) -- cycle;
252 \fill [westlake!90, opacity = .5]
253 (current page.south east) --++ (-.75\paperwidth, 0)
254 to[bend left = 6] ([yshift = 1.4cm]current page.south east) -- cycle;
255 \else
256 \ifsection \ifcsname westlake@mainbg\endcsname
257 \node [above, inner sep = 0pt, opacity = \westlake@mainbg@op]
258 at (current page.south)
259 {\includegraphics
260 [width = \paperwidth, height = \paperwidth]{\westlake@mainbg}};
261 \fi
262 \else \ifcsname westlake@basebg\endcsname
263 \node [above, inner sep = 0pt, opacity = \westlake@basebg@op]
264 at (current page.south)
265 {\includegraphics
266 [width = \paperwidth, height = \paperwidth]{\westlake@basebg}};
267 \fi
268 \ifcsname westlake@logobg\endcsname
269 \node [inner sep = 0pt, opacity = \westlake@logobg@op, xshift = -2em]
270 at (current page.east)
271 {\includegraphics[height = .75\paperheight]{\westlake@logobg}};
272 \fi
273 \fi
274 \fi
275 }
276 }
277 % \end{macrocode}
278 % Configure the badge at the north west corners.
279 % \begin{macrocode}
280 \titlegraphic{%
281 \tikz [remember picture, overlay] {%
282 \ifcsname westlake@lbadge\endcsname
283 \node [below right, shift = {(.5ex,-.5em)}] at (current page.north west)
284 {\includegraphics
285 [height = \dimeval{2\paperheight/15}]{\westlake@lbadge}};
286 \fi
287 \ifcsname westlake@rbadge\endcsname
288 \node [below left, shift = {(-.5ex,-.5em)}] at (current page.north east)
289 {\includegraphics
290 [height = \dimeval{2\paperheight/15}]{\westlake@rbadge}};
291 \fi
292 }
293 }
294 % \end{macrocode}
295 % Configure the title page, remove the footline and headline
296 % and set the title font.
297 % \begin{macrocode}
298 \let \@maketitle \maketitle
299 \renewcommand \maketitle {\begingroup
300 \setbeamertemplate{footline}{}
301 \setbeamertemplate{headline}{}
302 \setbeamerfont{title}{series = \bfseries \Large}
303 \@maketitle \endgroup
304 }
305 % \end{macrocode}
306 % Configure the blocks, including the colors and the opacity.
307 % \begin{macrocode}
308 \setbeamercolor{block title}
309 {use = structure, fg = structure.fg, bg = structure.fg!20!bg}
310 \setbeamercolor{block title alerted}
311 {use = alerted text, fg = alerted text.fg, bg = alerted text.fg!20!bg}
312 \setbeamercolor{block title example}
313 {use = example text,fg = example text.fg, bg = example text.fg!20!bg}
314 \setbeamercolor{block body}{%
315 use = block title, parent = normal text,
316 bg = block title.bg!50!bg
317 }
318 \setbeamercolor{block body alerted}{%
319 use = block title alerted, parent = normal text,
320 bg = block title alerted.bg!50!bg
321 }
322 \setbeamercolor{block body example}{%
323 use = block title example, parent = normal text,
324 bg = block title example.bg!50!bg
325 }
326 \addtobeamertemplate{block begin}
327 {\pgfsetfillopacity{.8}}{\pgfsetfillopacity{1}}
328 \addtobeamertemplate{block alerted begin}
329 {\pgfsetfillopacity{.8}}{\pgfsetfillopacity{1}}
330 \addtobeamertemplate{block example begin}
331 {\pgfsetfillopacity{.8}}{\pgfsetfillopacity{1}}
332 % \end{macrocode}
333 % Configure the footer, remove navigation buttons, and set the color series.
334 % \begin{macrocode}
335 \useoutertheme{infolines}
336 \setbeamertemplate{navigation symbols}{}
337 \setbeamercolor{title}{parent = author in head/foot}
338 \setbeamercolor*{palette primary}
339 {use = structure, fg = black, bg = structure.fg!30!white}
340 \setbeamercolor*{palette secondary}
341 {use = structure, fg = white, bg = structure.fg!60!white}
342 \setbeamercolor*{palette tertiary}
343 {use = structure, fg = white, bg = structure.fg!90!white}
344 % \end{macrocode}
345 % Configure the header, draw the progress bar.
346 % \begin{macrocode}
347 \addtobeamertemplate{headline}{}{%
348 \tikz [remember picture, overlay]{%
349 \ifnum \inteval{2*\insertpagenumber}>\insertdocumentendpage
350 \filldraw [westlake!60]
351 (current page.north) --++ (0,-4ex) [rounded corners = 1ex] --++
352 (\fpeval
353 {\insertpagenumber/\insertdocumentendpage/2}\paperwidth,0)
354 [rounded corners = 0pt] --++ (4ex,4ex)
355 node [left = 2ex, midway, white, font = \bfseries \small]
356 {\inteval{100*\insertpagenumber/\insertdocumentendpage}\%} -- cycle;
357 \else
358 \filldraw [westlake!60]
359 (current page.north) --++ (0,-4ex) [rounded corners = 1ex] --++
360 (\fpeval
361 {\insertpagenumber/\insertdocumentendpage/2}\paperwidth,0)
362 [rounded corners = 0pt] --++ (4ex,4ex)
363 node [right = 2ex, midway, westlake, font = \bfseries \small]
364 {\inteval{100*\insertpagenumber/\insertdocumentendpage}\%} -- cycle;
365 \fi
366 }
367 }
368 % \end{macrocode}
369 % \begin{macrocode}
370 \RequirePackage{ragged2e}
371 \justifying
372 \let\raggedright=\justifying
373 % \end{macrocode}
374 % Configure the bibliography list format.
375 % \begin{macrocode}
376 \setbeamertemplate{bibliography item}[text]
377 % \end{macrocode}
378 % Switch to all mode.
379 % \begin{macrocode}
380 \mode<all>
381 % \end{macrocode}
382 % \begin{macrocode}
383 \endinput
384 % \end{macrocode}
385 % End the optionlist package for \pkg{l3docstrip}.
386 % \begin{macrocode}
387 %</package>
388 % \end{macrocode}
389 % \end{implementation}
390 % \appendix
391 % \PrintIndex