summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tuda-ci/tudabeamer.cls
blob: 6dc094b9f2ce98d4fe994de5f57369fb99288dfc (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
%% This is file `tudabeamer.cls' version 3.20 (2021/10/12),
%% it is part of
%% TUDa-CI -- Corporate Design for TU Darmstadt
%% ----------------------------------------------------------------------------
%%
%%  Copyright (C) 2018--2021 by Marei Peischl <marei@peitex.de>
%%
%% ============================================================================
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainers of this work are
%%   Marei Peischl <tuda-ci@peitex.de>
%%   Markus Lazanowski <latex@ce.tu-darmstadt.de>
%%
%% The development respository can be found at
%% https://github.com/tudace/tuda_latex_templates
%% Please use the issue tracker for feedback!
%%
%% ============================================================================
%%
\def\fileversion{3.20}
\def\filedate{2021/10/12}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tudabeamer}
 [\filedate\space\fileversion\space]

\RequirePackage{l3keys2e}
\RequirePackage{URspecialopts}

\Define@specialopt@Module[ptxcd/beamer]
\PassOptionsToClass{10pt}{beamer}

\Module@DefineSpecialPassKey[ptxcd/beamer]{color}<tudacolors>

\ExplSyntaxOn
\str_new:N \g_ptxcd_department_str
\keys_define:nn {ptxcd/beamer} {
	accentcolor .code:n = \PassOptionsToPackage{accentcolor=#1}{tudacolors},
	colorframetitle .code:n = \exp_args:Nx \PassOptionsToPackage{\l_keys_key_tl=#1}{beamercolorthemeTUDa}
	\exp_args:Nx \PassOptionsToPackage{\l_keys_key_tl=#1}{beamerouterthemeTUDa},
	colorframetitle .default:n = true,
	logo .code:n = \PassOptionsToPackage{logo=#1}{beamerouterthemeTUDa},
	pdfa .bool_gset:N = \g_ptxcd_pdfa_bool,
	pdfa .initial:n = false,
	logofile .code:n = \PassOptionsToPackage{logofile=#1}{beamerouterthemeTUDa},
	serif .code:n = \PassOptionsToPackage{serif=#1}{beamerfontthemeTUDa},
	serif .default:n = true,
	sans-serif .code:n = \PassOptionsToPackage{sans-serif=#1}{beamerfontthemeTUDa},
	sans-serif .default:n = true,
	department .choice:,
	department / default .code:n = \str_gset:Nn \g_ptxcd_department_str {default},
	department / mecheng .code:n = {
		\keys_set:nn {ptxcd/beamer} {
			colorframetitle=false,
			centerframetitle,
			headsepline=false
		}
		\str_gset:Nn \g_ptxcd_department_str {mecheng}
	},
	department .initial:n = default,
	mecheng .meta:n = {department=mecheng},
	departmentlogofile .tl_gset:N = \g_ptxcd_departmentlogo_tl,
	departmentlogofile .initial:n =,
}


\clist_map_inline:nn {colortitle, colorbacktitle, colorback} {
	\Module@DeclarePassOption[ptxcd/beamer]{#1}{beamercolorthemeTUDa}
}

\clist_map_inline:nn {centerframetitle, logo, headsepline} {
		\Module@DeclarePassOption[ptxcd/beamer]{#1}{beamerouterthemeTUDa}
}
\Module@DeclarePassOption[ptxcd/beamer]{authorontitle}{beamerinnerthemeTUDa}

\ExplSyntaxOff



\PassOptionsToPackage{pdfpagelabels=false,plainpages=false}{hyperref}
\PassOptionsToClass{t}{beamer}

\Module@Process@SpecialOptions[ptxcd/beamer]

\DeclareOption*{%
	\PassOptionsToClass{\CurrentOption}{beamer}
}

\ProcessKeysOptions{ptxcd/beamer}
\ProcessOptions*

\ExplSyntaxOn
\bool_if:NT  \g_ptxcd_pdfa_bool {\PassOptionsToPackage{RGB}{xcolor}}

\bool_if:NT  \g_ptxcd_pdfa_bool {
\RequirePackage{scrlfile}
\PreventPackageFromLoading{hyperref}
\def\hypersetup#1{}
}
\ExplSyntaxOff

% Load the latex-beamer class
\LoadClass{beamer}

\ExplSyntaxOn
\bool_if:NT \g_ptxcd_pdfa_bool {
	\UnPreventPackageFromLoading{hyperref}
	%only apply the hack if pdfx is older than the working version
	\@ifpackagelater{pdfx}{2021/07/06}{
		\PassOptionsToPackage{a-2b}{pdfx}
		\RequirePackage{pdfx}
	} {
		\msg_new:nnnn{tudapub} {dirty-hack-pdfa} {
			I~have~to~use~a~dirty~hack~to~workaround~some~incompatibilites~between~your~LaTeX~version~and~the~pdfa-mode.\\
			Please~use~pdfa=true~only~if~you~really~need~it.\\
			We~will~remove~this~hack~as~soon~as~all~incompatibilities~have~been~patched.
		} {
			See~the~corresponding~GitHub~Issue~for~more~information:~https://github.com/tudace/tuda_latex_templates/issues/321
		}
		\msg_warning:nn {tudapub} {dirty-hack-pdfa}
		%check if \par is expanable and add a dirty hack
		%Thanks to Ross Moore for the support
		\expandafter\ifx\csname tex_par:D\endcsname \relax
		\let\pdfx@par\par
		\else
		\expandafter\let\expandafter\pdfx@par\csname tex_par:D\endcsname
		\fi
		\let\orig@par\par
		\let\par\pdfx@par
		\PassOptionsToPackage{a-2b}{pdfx}
		\RequirePackage{pdfx}
		%restore\par
		\let\par\orig@par
	}
}
\hypersetup{hidelinks, unicode}


%\department command
\def\department{\@dblarg\ptxcd_beamer_department}

\long\def\ptxcd_beamer_department[#1]#2{%
	\def\beamer@temp{#2}%
	\ifx\beamer@temp\@empty
	\def\insertdepartment{}
	\else
	\def\insertdepartment{\def\inst{\beamer@instinst}\def\and{\qquad}#2}%
	\fi
	\def\beamer@shortdepartment{#1}}
\department{}

\newcommand\insertshortdepartment[1][]{%
	{%
		\let\thanks=\@gobble%
		\beamer@setupshort{#1}%
		\beamer@insertshort{\beamer@shortdepartment}%
}}
%end of \department command
\if_bool:N \g_ptxcd_pdfa_bool
\iow_new:N \ptxcd_xmpdata_stream
\iow_open:Nn \ptxcd_xmpdata_stream {\jobname.xmpdata}
\tl_new:N \g_ptxcd_xmp_title
\tl_new:N \g_ptxcd_xmp_author

\cs_new:Nn \ptxcd_pass_TitleData: {
	\begingroup
	\def\newline{}
	\def\\{}
	\let\thanks\use_none:n
	\cs_set:Npn \and {\exp_not:n {\exp_not:N \sep}}
	\bool_if:NTF \g_ptxcd_pass_TitleData_bool {
		\tl_gset:Nx \g_ptxcd_xmp_title {\insertshorttitle}
		\tl_gset:Nx \g_ptxcd_xmp_author {\insertshortauthor}
		\iow_now:Nx \ptxcd_xmpdata_stream
		{
			\exp_not:N \Title{\tl_to_str:V \g_ptxcd_xmp_title}
			^^J
			\exp_not:N \Author{\tl_to_str:V \g_ptxcd_xmp_author}
			^^J
			\exp_not:N \Creator{LaTeX~ using~ the~ TUDa-CI~ Bundle}
		}
	}{
		\begingroup
		\use:c {pdfx@localcommands}
		\prop_if_in:NnF \g_ptxcd_MetaData_prop {Creator} {\prop_gput:Nnn \g_ptxcd_MetaData_prop {Creator} {LaTeX~ using~ the~ TUDa-CI~ Bundle}}
		\prop_map_function:NN \g_ptxcd_MetaData_prop  \ptxcd_write_xmp_line:nn
		\endgroup
	}
	\endgroup
}
\cs_new:Nn \ptxcd_write_xmp_line:nn {
	%Fallback test for older kernels
	\cs_if_exist:NTF \str_uppercase:f {
	\tl_set:Nx \l_tmpa_tl {
		\str_uppercase:f {\tl_head:n {#1}}
		\str_lowercase:f { \tl_tail:n {#1}}
	}
	} {
	%may be removed in some time
	\tl_set:Nx \l_tmpa_tl {\tl_mixed_case:n {#1}}
	}
	\cs_if_exist:cTF {\l_tmpa_tl}{
		\iow_now:Nx \ptxcd_xmpdata_stream {
			\c_backslash_str \l_tmpa_tl {\exp_not:n {#2}}
		}
	}{
		\msg_error:nnn{tudapub} {unknown-metadata} {#1}
	}
}

\bool_new:N \g_ptxcd_pass_TitleData_bool
\bool_gset_true:N  \g_ptxcd_pass_TitleData_bool
\prop_new:N \g_ptxcd_MetaData_prop

\newcommand*{\Metadata}[1]{
	\bool_gset_false:N \g_ptxcd_pass_TitleData_bool
	\prop_gset_from_keyval:Nn \g_ptxcd_MetaData_prop {#1}
}

\msg_new:nnnn{tudapub} {unknown-metadata} {
	You~ used~ the~ #1~ metadata~ entry.\\
	I~ don't~ know~ how~ to~ handle~ that.\\
	It~ will~ be~ ignored.
} {See~ TUDa-CI~ or~ pdfx~ documentation~ for~ details.}
\else:
\msg_new:nnn{tudapub} {no-pdfa}{The~ tudapub~ class~ won't~ create~ PDF/A-mode.}
\msg_info:nn{tudapub} {no-pdfa}
\fi:

\str_if_empty:NF \g_ptxcd_department_str {}

% Load the TUDa theme
\usetheme{TUDa}%
\@input{\jobname.len}%
\@starttoc{len}%
\let\accentfont\normalfont%
\file_if_exist:nT {beamerthemeTUDa-\g_ptxcd_department_str.sty} {\usetheme{TUDa-\g_ptxcd_department_str}}

\ExplSyntaxOff

\endinput