-
Notifications
You must be signed in to change notification settings - Fork 5
/
baarticle.cls
516 lines (479 loc) · 18.5 KB
/
baarticle.cls
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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
% Document class implementing the BA Dresden Styleguide
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{baarticle}[2021/09/24 v1.0.0]
% Process package options
\RequirePackage{xkeyval} % for key value processing
\RequirePackage{etoolbox} % for csdef, csundef, ifdefempty, toggles, etc ...
\newtoggle{baclssimple} % toggles are false per default
\newtoggle{baclslinkcoloring} % toggles are false per default
\newtoggle{baclsheader} % toggles are false per default
\toggletrue{baclsheader} % default setting should show the header
% first name of the author
\DeclareOptionX[BA]{first}{\def\@baclsfirst{#1}}
% last name of the author
\DeclareOptionX[BA]{last}{\def\@baclslast{#1}}
% company the author works at
\DeclareOptionX[BA]{company}{\def\@baclscompany{#1}}
% location of the university
\DeclareOptionX[BA]{location}{\def\@baclslocation{#1}}
% if specified the class will load additional packages and provide the basimple environment, which simplifies the setup
\DeclareOptionX[BA]{simple}{\toggletrue{baclssimple}}
% if specified links will be colored
\DeclareOptionX[BA]{linkcoloring}{\toggletrue{baclslinkcoloring}}
% if specified title will not be shown in the header
\DeclareOptionX[BA]{noheader}{\togglefalse{baclsheader}}
% if specified header title is changed to tis provided title
% it's recommended to use a maximum lentgth of 80 characters to prevent an overflow
\DeclareOptionX[BA]{headertitle}{\def\@baclsheadertitle{#1}}
\DeclareOptionX*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptionsX[BA]\relax
% Class is based on the deault article class
\LoadClass[12pt]{article}
% Load required packages
\RequirePackage{iftex} % to check the TeX engine in use
\ifpdftex
\RequirePackage[T1]{fontenc} % change the fontencoding so people can copy accented characters properly from the compiled document
\RequirePackage{lmodern} % swap the font so that the fontencoding change does not screw up letter kerning
\fi
\iftoggle{baclsheader}{ % adjust the page top spacing depending on whether header is shown or not
\RequirePackage[a4paper,left=3cm,right=2cm,top=3cm,bottom=2cm]{geometry} % for paper size and page spacing
}{
\RequirePackage[a4paper,left=3cm,right=2cm,top=2cm,bottom=2cm]{geometry} % for paper size and page spacing
}
\RequirePackage{setspace} % for line spacing
\RequirePackage{float} % for H placement directive in \begin{figure}
\RequirePackage{tocloft} % to adjust the ToC, LoF and LoT
\RequirePackage{fancyhdr} % to adjust headers and footers
\RequirePackage{graphicx} % to use includegraphics
\RequirePackage[font={footnotesize},justification=centering]{caption} % to make captions smaller and keep long captions centered
\RequirePackage{wrapfig} % to place text wrapping floats
\RequirePackage{tocbibind} % adds ToC entries for ToC, LoF, LoT, etc ...
\RequirePackage[bottom,hang]{footmisc} % to keep footnotes always on the bottom and to fix multiline indentation
\RequirePackage[all]{nowidow} % to eliminate widows and orphans
\RequirePackage{titlesec} % to reduce section spacing
\RequirePackage{lipsum}% just to generate text for the example
% Load additional packages if in simple mode
\iftoggle{baclssimple}{
\RequirePackage{pdfpages}
\RequirePackage[english,main=ngerman]{babel}
\RequirePackage[autostyle=true,german=quotes]{csquotes}
\RequirePackage[style=baarticle]{biblatex}
\RequirePackage{hyperref}
\RequirePackage[style=alttree,nogroupskip,nonumberlist,nopostdot,nolong,nosuper,nolist]{glossaries}
\iftoggle{baclslinkcoloring}{
% hyperref config
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
}
} {
% no coloring required, do nothing
}
} {
% not in simple, do nothing
}
% set spacing for sections
\titlespacing*{\section}
{0pt}{0pt}{0pt}
\titlespacing*{\subsection}
{0pt}{0pt}{0pt}
% {0pt}{1ex minus .2ex}{1ex plus .2ex}
% Set paragraph indentation
\setlength{\parindent}{0pt}
% Set spacing after paragraphs
\setlength{\parskip}{\baselineskip}
% Set line spread
\onehalfspacing
% Table of contents Style
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} % Linie for chapters
\renewcommand{\cftsecdotsep}{\cftdot}
% List of figures Style
\renewcommand{\cftfigpresnum}{Abbildung }
\renewcommand{\cftfigaftersnum}{:}
\newlength{\fignumspacing} % a "scratch" length
\settowidth{\fignumspacing}{\bfseries\cftfigpresnum\cftfigaftersnum} % extra space
\addtolength{\cftfignumwidth}{\fignumspacing} % add the extra space
\setlength{\cftfigindent}{0pt}
% List of Tables Style
\renewcommand{\cfttabpresnum}{Tabelle }
\renewcommand{\cfttabaftersnum}{:}
\newlength{\tabnumspacing} % a "scratch" length
\settowidth{\tabnumspacing}{\bfseries\cfttabpresnum\cfttabaftersnum} % extra space
\addtolength{\cfttabnumwidth}{\tabnumspacing} % add the extra space
\setlength{\cfttabindent}{0pt}
% List of Appendix (LoA)
% The related commands will refer to 'appx' as the appendix command is already defined by LaTeX
\newcommand{\listappxname}{Anhangverzeichnis}
\newlistof{appx}{loa}{\listappxname}
\newcommand{\addtoappx}[1]{%
\refstepcounter{appx}
\addcontentsline{loa}{appx}{\protect\numberline{\theappx}#1}\par
}
\renewcommand{\cftloatitlefont}{\Large\bfseries}
\renewcommand{\cftappxpresnum}{Anhang }
\renewcommand{\cftappxaftersnum}{:}
\newlength{\appxnumspacing} % a "scratch" length
\settowidth{\appxnumspacing}{\bfseries\cftappxpresnum\cftappxaftersnum} % extra space
\addtolength{\cftappxnumwidth}{\appxnumspacing} % add the extra space
% Change pagestyle of "normal" pages to fancy
\pagestyle{fancy}
% Change pagestyle of ToC pages to fancy
\tocloftpagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
% Start with roman page numbering
\pagenumbering{Roman}
% Define keys for the title page
% path to an image, placed in the top right corner
\define@key[BA]{title}{img}{\def\@batitleimg{#1}}
% course attended at the university
\define@key[BA]{title}{course}{\def\@batitlecourse{#1}}
% title of the paper
\define@key[BA]{title}{title}{\def\@batitletitle{#1}}
% number of the author
\define@key[BA]{title}{number}{\def\@batitlenumber{#1}}
% correctors
\define@key[BA]{title}{corrector}{\edef\@batitlecorrector{#1}}
% date when the theme of the paper was announced
\define@key[BA]{title}{themedate}{\def\@batitlethemedate{#1}}
% date when the paper has been handed in
\define@key[BA]{title}{returndate}{\def\@batitlereturndate{#1}}
% type of paper (thesis etc...)
\define@key[BA]{title}{type}{\def\@batitletype{#1}}
\presetkeys[BA]{title}{type=undefined}{}
% Clear the header and footer
\fancyhead{}
\fancyfoot{}
\iftoggle{baclsheader}{
\ifdefvoid{\@baclsheadertitle}{
\fancyhead[L]{\@batitletitle}
}{
\fancyhead[L]{\@baclsheadertitle}
}
% Default \headrulewidth is 0.4pt
\renewcommand{\headrulewidth}{0.4pt}
}
% Show the page number on the right side
\fancyfoot[R]{\thepage}
% Default \footrulewidth is 0pt
% \renewcommand{\footrulewidth}{0.4pt}
% helper macro to print the list of correctors comma seperated
\newcommand{\printcorrectors}[1]{
\@for\next:=#1\do
{Gutachter: \next\\}%
}
% helper macro to convert @baclstype to an actual text
\newcommand{\@bapapertype}{%
% need to expand @bapapertype as ifdefstring does not do that
\edef\@bapapertest{\@batitletype}%
\ifdefstring{\@bapapertest}{thesis}{%
Bachelorarbeit\\
zur Erlangung des Abschlusses Bachelor of Science\\
im Studiengang \@batitlecourse\\[\baselineskip]%
}{} % \ifdefstring
\ifdefstring{\@bapapertest}{study}{%
Studienarbeit\\[\baselineskip]%
}{}%
\ifdefstring{\@bapapertest}{report}{%
Belegarbeit\\[\baselineskip]%
}{}%
}
% Title Page
\newcommand{\mktitle}[1]{
\setkeys[BA]{title}{#1}
\begin{titlepage}
\begin{wrapfigure}[3]{r}{0.5\textwidth}
\begin{center}
\vspace{-18pt}
\includegraphics[width=0.5\textwidth]{\@batitleimg}
\end{center}
\end{wrapfigure}
\noindent
\normalsize
Berufsakademie Sachsen \\
Staatliche Studienakademie \@baclslocation{} \\
Studiengang \@batitlecourse{} \\
\par
%% \vspace{4cm}
\vspace*{\fill}
\begin{center}
\Huge
\textbf{\@batitletitle}
\par
\vspace{\fill}
\normalsize
\@bapapertype{}
\@baclslast{}, \@baclsfirst \\
\@baclscompany{}\\
Matrikelnummer: \@batitlenumber{}
\vspace{\fill}
\end{center}
\vfill
\printcorrectors{\@batitlecorrector}\\
Tag der Themenübergabe: \@batitlethemedate \\
Tag der Einreichung: \@batitlereturndate
\vfill
\end{titlepage}
\addtocounter{page}{1}
}
% Define keys for the blocking notice
% signature of the author
\define@key[BA]{block}{signature}{\def\@bablocksignature{#1}}
% date when the paper is handed in
\define@key[BA]{block}{date}{\def\@bablockdate{#1}}
% where the company is located at
\define@key[BA]{block}{location}{\def\@bablocklocation{#1}}
% Blocking notice
\newcommand{\mkblocknotice}[1]{
\setkeys[BA]{block}{#1}
% do not print page number on blocking notice
\thispagestyle{empty}
\subsubsection*{Sperrvermerk}
Die vorliegende Arbeit enthält vertrauliche Daten des Unternehmens \@baclscompany{}.
Auf Wunsch des Unternehmens \@baclscompany{} ist die vorliegende Arbeit für die öffentliche Nutzung zu sperren.
Veröffentlichung, Vervielfältigung und Einsichtnahme sind ohne ausdrückliche Genehmigung des Unternehmens \@baclscompany{}, in \@bablocklocation{} und des Verfassers \@baclsfirst{} \@baclslast{} nicht gestattet.
Die Arbeit ist nur den Gutachtern und den Mitgliedern des Prüfungsausschusses zugänglich zu machen.
\bigskip\par
\begin{wrapfigure}[1]{r}{0.3\textwidth}
\begin{center}
\vspace{-32pt}
\includegraphics[width=0.28\textwidth]{\@bablocksignature}
\end{center}
\end{wrapfigure}
\bigskip
\par\noindent
\@baclslocation{}, \@bablockdate{}
\par\noindent
Ort, Datum\hfill Unterschrift des Verfassers
\clearpage
}
% Define keys for the affirmation
% signature of the author
\define@key[BA]{affirmation}{signature}{\def\@baaffirsignature{#1}}
% date when the paper is handed in
\define@key[BA]{affirmation}{date}{\def\@baaffirdate{#1}}
% Affirmation
\newcommand{\mkaffirmation}[1]{
\setkeys[BA]{affirmation}{#1}
% do not print page number on affirmation
\thispagestyle{empty}
\subsubsection*{Eidesstattliche Erklärung}
Ich erkläre an Eides statt, dass ich die vorliegende Arbeit selbständig und ohne unerlaubte fremde Hilfe angefertigt, andere als die angegebenen Quellen und Hilfsmittel nicht benutzt habe.
Die aus fremden Quellen direkt oder indirekt übernommenen Stellen sind als solche kenntlich gemacht.
Die Zustimmung des Partnerunternehmens in der Praxis zur Verwendung betrieblicher Unterlagen habe ich eingeholt.
Die Arbeit wurde bisher in gleicher oder ähnlicher Form keiner anderen Prüfungsbehörde vorgelegt und auch nicht veröffentlicht.
\bigskip\par
\begin{wrapfigure}[1]{r}{0.3\textwidth}
\begin{center}
\vspace{-32pt}
\includegraphics[width=0.28\textwidth]{\@baaffirsignature}
\end{center}
\end{wrapfigure}
\bigskip
\par\noindent
\@baclslocation{}, \@baaffirdate{}
\par\noindent
Ort, Datum\hfill Unterschrift des Verfassers
}
% Frontmatter
% prints ToC, LoF and LoT and swaps to arabic pagenumbering afterwards
% the argument defines how to print the list of abbreviations, as there
% exist multiple packages to handle abbreviations
\newcommand{\mkfrontmatter}[1]{
\tableofcontents
\clearpage
\listoffigures
\clearpage
#1
\clearpage
\listoftables
\clearpage
\pagenumbering{arabic}
}
% Define basimple environment if in simple mode
\iftoggle{baclssimple}{
% Specify environment keys
% path to an image, placed in the top right corner
\define@key[BA]{simple}{img}{\def\@basimpleimg{#1}}
% course attended at the university
\define@key[BA]{simple}{course}{\def\@basimplecourse{#1}}
% title of the paper
\define@key[BA]{simple}{title}{\def\@basimpletitle{#1}}
% number of the author
\define@key[BA]{simple}{number}{\def\@basimplenumber{#1}}
% correctors
\define@key[BA]{simple}{corrector}{\def\@basimplecorrector{#1}}
% date when the theme of the paper was announced
\define@key[BA]{simple}{themedate}{\def\@basimplethemedate{#1}}
% date when the paper has been handed in
\define@key[BA]{simple}{returndate}{\def\@basimplereturndate{#1}}
% signature of the author
\define@key[BA]{simple}{signature}{\def\@basimplesignature{#1}}
% where the company is located at
\define@key[BA]{simple}{location}{\def\@basimplelocation{#1}}
% type of the paper (thesis etc...)
\define@key[BA]{simple}{type}{\def\@basimpletype{#1}}
% path to thesis assignment (must be a pdf file)
\define@key[BA]{simple}{assignment}{\def\@basimpleassignment{#1}}
% whether to include the blocknotice or not
\define@boolkey[BA]{simple}{blocknotice}[true]{}
\presetkeys[BA]{simple}{type=undefined,blocknotice=true}{}
% adjust glossary styling
\renewcommand{\glossarypreamble}{\glsfindwidesttoplevelname[\currentglossary]}
\setacronymstyle{long-short}
\renewcommand{\glossarysection}[2][]{}
\makenoidxglossaries
\newenvironment{basimple}[1][]{
\setkeys[BA]{simple}{#1}
\mktitle{
title=\@basimpletitle,
img=\@basimpleimg,
course=\@basimplecourse,
number=\@basimplenumber,
corrector=\@basimplecorrector,
themedate=\@basimplethemedate,
returndate=\@basimplereturndate,
type=\@basimpletype,
}
\ifdefvoid{\@basimpleassignment}{
% no assignment file set, do nothing
}{
\includepdf[pages={1}]{\@basimpleassignment}
}
\ifBA@simple@blocknotice
\mkblocknotice{
signature=\@basimplesignature,
date=\@basimplereturndate,
location=\@basimplelocation
}
\fi
\ifdefvoid{\basimpleabstract}{}{
\section*{Abstract}
\basimpleabstract
\clearpage
}
\mkfrontmatter{
\singlespacing
\section*{Abkürzungsverzeichnis}
\addcontentsline{toc}{section}{Abkürzungsverzeichnis}
\vspace{-1cm}
\printnoidxglossaries
\onehalfspacing
}
}{
\printbibliography[heading=bibintoc]
\clearpage
\mkaffirmation{
signature=\@basimplesignature,
date=\@basimplereturndate
}
}
}{
% not in simple mode, do nothing
}
% Appendix environment
% Toggle defining if the baappx environment is active
\newtoggle{baclsappx}
\newenvironment{baappx}{
\toggletrue{baclsappx}
\phantomsection
\addcontentsline{toc}{section}{Anhangverzeichnis}
\listofappx
\clearpage
\section*{Anhang}
\addcontentsline{toc}{section}{Anhang}
}{
\clearpage
\togglefalse{baclsappx}
}
% Specify environment keys
% Reference to the source
\define@key[BA]{env}{source}[]{\def\@baenvsource{#1}}
% Label to use with \ref
\define@key[BA]{env}{label}[]{\def\@baenvlabel{#1}}
% Placement directive, defaults to H of package float
\define@key[BA]{env}{placement}{\def\@baenvplacement{#1}}
\presetkeys[BA]{env}{placement=H,source,label}{}
% Environment caption
% Somehow is use of global variables is required here, because otherwiese
% the \edef tests cause a stack overflow
\newcommand{\@bacaption}{%
\ifdefempty{\@baenvsource}{%
\@baenvtitle\space(Quelle: eigene Darstellung)%
}{%
\@baenvtitle\space(Quelle: \@baenvsource)%
}%
}
% \begin{bafigure}[source=SOURCE,placement=htb,label=LABEL]{title}
% bafigure puts a frame around its content and adds a source reference below the figure
% also adds a label which equals the given title
\newsavebox{\@bafigurebox}
\newenvironment{bafigure}[2][]{
\setkeys[BA]{env}{#1}
\csdef{@basource}{\@baenvsource}
\csdef{@baenvtitle}{#2}
% the stuff below for begin figure is required because it is
% required to expand the placement modifier instantly
\def\efigure{\begin{figure}}%
\expandafter\efigure\expandafter[\@baenvplacement]
\begin{lrbox}{\@bafigurebox}
\begin{minipage}{0.98\textwidth}
\begin{center}
}{
\end{center}
\end{minipage}
\end{lrbox}
\fbox{\usebox{\@bafigurebox}}
\iftoggle{baclsappx}{
\addtoappx{\@baenvtitle}
\begin{center}
\vspace{-10pt}
\small
Anhang \theappx{}: \@bacaption
\end{center}
} {
\caption[\@baenvtitle]{\@bacaption}
}
\ifdefempty{\@baenvlabel}{
\label{\@baenvtitle}
}{
\label{\@baenvlabel}
}
\end{figure}
\csundef{@basource}
\csundef{@baenvtitle}
}
% \begin{batable}[source=SOURCE,placement=htb,label=LABEL]{title}
% batable centers the content and adds a source reference below the table
% also adds a label which equals the given title
\newenvironment{batable}[2][]{
\setkeys[BA]{env}{#1}
\csdef{@basource}{\@baenvsource}
\csdef{@baenvtitle}{#2}
% the stuff below for begin table is required because it is
% required to expand the placment modifier instantly
\def\etable{\begin{table}}%
\expandafter\etable\expandafter[\@baenvplacement]
\begin{center}
}{
\end{center}
\iftoggle{baclsappx}{
\addtoappx{\@baenvtitle}
\begin{center}
\vspace{-10pt}
\small
Anhang \theappx{}: \@bacaption
\end{center}
} {
\caption[\@baenvtitle]{\@bacaption}
}
\ifdefempty{\@baenvlabel}{
\label{\@baenvtitle}
}{
\label{\@baenvlabel}
}
\end{table}
\csundef{@basource}
\csundef{@baenvtitle}
}