summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ksp-thesis/ksp-thesis.cls
blob: dab842195723390365fd6c5f0ec7c038c454f7b3 (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
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
%%% ===========================================================================
%%% <ksp-thesis>
%%% A LaTeX class for theses published with KIT Scientific Publishing
%%% ===========================================================================
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ksp-thesis}[2015/12/09 v1.0.2 LaTeX class for theses published with KIT Scientific Publishing]

%%% ===========================================================================
%%% PRELIMINARY DECLARATIONS
%%% ===========================================================================
%%% Page layout options
%%% ---------------------------------------------------------------------------
%%% draft layout (for private print and correction prints)
\newcommand{\kspths@setlayout@draft}{%
   \KOMAoptions{paper=a4,twoside=off,DIV=12,fontsize=12pt,BCOR=0.0mm,parskip=half,headsepline}%
   \setheadsepline{0.5pt}%
   \raggedbottom%
}
%%% official layout (for faculty and thesis committee)
\newcommand{\kspths@setlayout@official}{%
   \KOMAoptions{paper=a4,twoside=on,DIV=13,fontsize=12pt,BCOR=15.0mm,parskip=half,cleardoublepage=empty,headsepline}%
   \setheadsepline{0.5pt}%
   \raggedbottom%
}
%%% KIT Scientific Report layout (for publication release, A4 paper size)
\newcommand{\kspths@setlayout@report}{\kspths@setlayout@official}
%%% KIT Scientific Publishing book layout (for publication release, 17cm x 24cm paper size)
\newcommand{\kspths@setlayout@seventeentwentyfour}{%
   \KOMAoptions{paper=17cm:24cm,twoside=on,DIV=14,fontsize=10pt,BCOR=15.0mm,parskip=half,cleardoublepage=empty,headinclude,pagesize,headsepline}%
   \setheadsepline{0.5pt}%
   \raggedbottom%
}
%%% default layout (if not set in class options)
\newcommand{\kspths@setlayout}{%
   \ClassWarning{ksp-thesis}{You have not selected a page layout, the default option 'report' will be used.}
   \kspths@setlayout@report%
}

%%% ===========================================================================
%%% OPTION DECLARATION AND PROCESSING
%%% ===========================================================================
\RequirePackage{xkeyval}
%%% BEGIN PATCH
%%% to avoid endless loop when using bad presetkey settings
%%% http://tex.stackexchange.com/a/94006
\def\XKV@badsetkeys{%
  \@latex@error{You can't nest \noexpand\setkeys in preset keys.
    \MessageBreak That could cause an endless loop}\@ehd
}
\let\XKV@savsetkeys\setkeys
\def\XKV@usepresetkeys#1#2{%
  \XKV@presettrue
  \let\setkeys\XKV@badsetkeys
  \XKV@for@eo\XKV@fams\XKV@tfam{%
    \XKV@makehd\XKV@tfam
    \XKV@ifundefined{XKV@\XKV@header#2}{}{%
      \XKV@toks\expandafter\expandafter\expandafter
        {\csname XKV@\XKV@header#2\endcsname}%
      \@expandtwoargs\XKV@s@tkeys{\the\XKV@toks}%
        {\XKV@naa\ifx\XKV@naa\@empty\else,\fi#1}%
    }%
  }%
  \let\setkeys\XKV@savsetkeys
  \XKV@presetfalse
}
%%% END PATCH

%%% main page layout options
%%% ---------------------------------------------------------------------------
\define@choicekey*+{ksp-thesis.cls}{layout}[\val\nr]{draft,official,report,17x24}{%
   \ifcase\nr\relax
      \renewcommand{\kspths@setlayout}{\kspths@setlayout@draft}
   \or
      \renewcommand{\kspths@setlayout}{\kspths@setlayout@official}
   \or
      \renewcommand{\kspths@setlayout}{\kspths@setlayout@report}
   \or
      \renewcommand{\kspths@setlayout}{\kspths@setlayout@seventeentwentyfour}
   \fi
}{%
   \ClassWarning{ksp-thesis}{Value '#1' is unknown for key 'layout' and will %
      be ignored.}%
}
%%% TOC style options
%%% ---------------------------------------------------------------------------
%%% dotted TOC
\define@boolkey+{ksp-thesis.cls}[kspths@]{dottedtoc}[true]{%
   \ifkspths@dottedtoc
   \else
      \@ifpackagewith{classicthesis}{dottedtoc}{%
         \ClassWarning{ksp-thesis}{'dottedtoc=#1': The option 'dottedtoc' of %
            the <classicthesis> package has been previously set and cannot be %
            overridden anymore. %
            Please remove the earlier setting}
      }{%
         \ClassWarning{ksp-thesis}{The default setting for 'dottedtoc' has %
            been changed to '#1'.}
      }
   \fi
}{%
   \ClassError{ksp-thesis}{Invalid value '#1' for 'dottedtoc' key, assuming 'true'}%
      {Please use 'true' or 'false'}%
   \setkeys{ksp-thesis.cls}{dottedtoc=true}
}
%%% dotted part entries in TOC
\define@boolkey+{ksp-thesis.cls}[kspths@]{dottedtocparts}[true]{%
   \ifkspths@dottedtoc
   \else
      \ifkspths@dottedtocparts
         \ClassWarning{ksp-thesis}{You are using 'dottedtocparts=true' %
            in combination with 'dottedtoc=false'. This results in an %
            inconsistent TOC layout and is not recommended}%
      \fi
   \fi
}{%
   \else
   \ClassError{ksp-thesis}{Invalid value '#1' for 'dottedtocparts' key, %
      assuming 'true'}%
      {Please use 'true' or 'false'}%
   \setkeys{ksp-thesis.cls}{dottedtocparts=true}
}
%%% dotted chapter entries in TOC
\define@boolkey+{ksp-thesis.cls}[kspths@]{dottedtocchapters}[true]{%
   \ifkspths@dottedtoc
   \else
      \ifkspths@dottedtocchapters
         \ClassWarning{ksp-thesis}{You are using 'dottedtocchapters=true' %
            in combination with 'dottedtoc=false'. This results in an %
            inconsistent TOC layout and is not recommended}%
      \fi
   \fi
}{%
   \ClassError{ksp-thesis}{Invalid value '#1' for 'dottedtocchapters' key, %
      assuming 'true'}%
      {Please use 'true' or 'false'}%
   \setkeys{ksp-thesis.cls}{dottedtocchapters=true}
}
%%% bold TOC part entries
\define@boolkey+{ksp-thesis.cls}[kspths@]{tocpartentriesbold}[true]{%
   \ifkspths@tocpartentriesbold
   \else
      \ClassWarning{ksp-thesis}{The default setting for 'tocpartentriesbold' has been %
         changed to '#1'.}
   \fi
}{%
   \ClassError{ksp-thesis}{Invalid value '#1' for 'tocpartentriesbold' key, assuming 'true'}%
      {Please use 'true' or 'false'}%
   \setkeys{ksp-thesis.cls}{tocpartentriesbold=true}
}
%%% bold TOC chapter entries
\define@boolkey+{ksp-thesis.cls}[kspths@]{tocchapterentriesbold}[true]{%
   \ifkspths@tocchapterentriesbold
   \else
      \ClassWarning{ksp-thesis}{The default setting for 'tocchapterentriesbold' has been %
         changed to '#1'.}
   \fi
}{%
   \ClassError{ksp-thesis}{Invalid value '#1' for 'tocchapterentriesbold' key, assuming 'true'}%
      {Please use 'true' or 'false'}%
   \setkeys{ksp-thesis.cls}{tocchapterentriesbold=true}
}
%%% bold TOC entries
\define@boolkey+{ksp-thesis.cls}[kspths@]{tocentriesbold}[true]{%
   \setkeys{ksp-thesis.cls}{tocpartentriesbold=#1,tocchapterentriesbold=#1}
   \ifkspths@tocentriesbold
   \else
      \ClassWarning{ksp-thesis}{The default setting for 'tocentriesbold' has been %
         changed to '#1'.}
   \fi
}{%
   \ClassError{ksp-thesis}{Invalid value '#1' for 'tocentriesbold' key, assuming 'true'}%
      {Please use 'true' or 'false'}%
   \setkeys{ksp-thesis.cls}{tocentriesbold=true}
}
%%% ragged lists
\define@boolkey+{ksp-thesis.cls}[kspths@]{raggedlists}[true]{%
}{%
   \ClassError{ksp-thesis}{Invalid value '#1' for 'raggedlists' key, %
      assuming 'true'}%
      {Please use 'true' or 'false'}%
   \setkeys{ksp-thesis.cls}{raggedlists=true}
}

%%% pass unknown options on to the base class
%%% ---------------------------------------------------------------------------
\DeclareOptionX*{%
   \PassOptionsToClass{\CurrentOption}{scrbook}%
}
%%% default settings
%%% ---------------------------------------------------------------------------
\presetkeys{ksp-thesis.cls}{%
   dottedtoc,
   raggedlists,
   %tocentriesbold, % cannot be set within \presetkeys
   %layout=report, % default behavoir is set above with \newcommand{\kspths@setlayout}
}{}
\setkeys{ksp-thesis.cls}{tocentriesbold} % cannot be set within \presetkeys
%%% process options
%%% ---------------------------------------------------------------------------
\ProcessOptionsX

%%% ===========================================================================
%%% LOAD BASE CLASS <scrbook>
%%% =========================================================================== 
\LoadClass{scrbook}
\RequirePackage{scrlayer-scrpage}  % change header and footer

%%% ===========================================================================
%%% MAIN DECLARATIONS
%%% ===========================================================================
%%% set package options
%%% ---------------------------------------------------------------------------
\ifkspths@dottedtoc
   \PassOptionsToPackage{dottedtoc}{classicthesis} % sets pagenumbers flushed right in the table of contents
\fi
%%% <classicthesis> and <arsclassica> for layout, font and typography settings
%%% ---------------------------------------------------------------------------
\RequirePackage{classicthesis}
\RequirePackage{arsclassica}
%%% reset page and typearea settings according to KSP requirements
%%% ---------------------------------------------------------------------------
\kspths@setlayout
\recalctypearea
%%% modify <arsclassica> definitions for headings
%%% ---------------------------------------------------------------------------
%%% color definitions
\definecolor{parttitlecolor}{named}{Maroon}
%%% use font definitions that are compatible with KOMA script
\setkomafont{part}{\normalfont\centering\large}
\newkomafont{parttitle}{\color{parttitlecolor}\spacedallcaps}
\setkomafont{chapter}{\normalfont\Large\sffamily}
\newkomafont{chaptertitle}{\raggedright\spacedallcaps}
\setkomafont{section}{\normalfont\Large\sffamily\raggedright}
\newkomafont{sectiontitle}{\spacedlowsmallcaps}
\setkomafont{subsection}{\normalfont\large\sffamily\raggedright}
\newkomafont{subsectiontitle}{\relax}
\setkomafont{subsubsection}{\normalfont\sffamily\itshape\raggedright}
\newkomafont{subsubsectiontitle}{\normalsize\itshape}
\setkomafont{paragraph}{\normalfont\normalsize\sffamily}
\newkomafont{paragraphtitle}{\spacedlowsmallcaps}
\setkomafont{descriptionlabel}{\bfseries\spacedlowsmallcaps}
%%% command to make a box with the width of the current chapter number
%%% (this allows to use equal width for chapter, ..., subsubsection numbers)
\newlength{\secnumwidth}%
\newcommand{\kspths@secnumbox}[1]{%
\settowidth{\secnumwidth}{\usekomafont{chapter}{\chapterNumber\thechapter\hspace{10pt}\vline}  }%
\makebox[\secnumwidth][l]{#1}%
}
%%% reformat parts
\ifthenelse{\boolean{@parts}}%
{%
   \titleformat{\part}[display]
      {\usekomafont{part}}%
      {\thispagestyle{empty}\partname~\MakeTextUppercase{\thepart}}{1em}%
      {\usekomafont{parttitle}}
}{\relax}
%%% reformat chapters
\ifthenelse{\boolean{@linedheaders}}{%
   \ClassWarning{ksp-thesis}{%
      The 'linedheaders' option of the <classicthesis> package is incompatible and %
      will be ignored.}%
}{}
\renewcommand\formatchapter[1]{% 
   \vbox to \ht\strutbox{ 
   \setbox0=\hbox{\chapterNumber\thechapter\hspace{10pt}\vline\ } 
   \advance\hsize-\wd0 \advance\hsize-10pt
   \usekomafont{chaptertitle}{#1}\vss}} 
\titleformat{\chapter}[block] 
   {\usekomafont{chapter}} 
   {\textcolor{halfgray}{\chapterNumber\thechapter} 
   \hspace{10pt}\vline\ }{10pt} 
   {\formatchapter}
%%% reformat sections
\titleformat{\section} 
   {\usekomafont{section}}{\kspths@secnumbox{\textsc%
   {\MakeTextLowercase{\thesection}}}}%
   {10pt}{\usekomafont{sectiontitle}}
%%% reformat subsections
\titleformat{\subsection}
   {\usekomafont{subsection}}{\kspths@secnumbox{\textsc{\MakeTextLowercase%
   {\thesubsection}}}}{10pt}{\usekomafont{subsectiontitle}}
%%% reformat subsubsections
\titleformat{\subsubsection}
   {\usekomafont{subsubsection}}{\kspths@secnumbox{\textsc%
   {\MakeTextLowercase{\thesubsubsection}}}}%
   {10pt}{\usekomafont{subsubsectiontitle}}        
%%% reformat paragraphs
\titleformat{\paragraph}[runin]
   {\usekomafont{paragraph}}{\textsc%
   {\MakeTextLowercase{\theparagraph}}}%
   {0pt}{\usekomafont{paragraphtitle}}    
%%% reformat descriptionlabels
\renewcommand{\descriptionlabel}[1]{\hspace*{\labelsep}%
\usekomafont{descriptionlabel}{#1}}
%%% modify <classicthesis> definitions for TOC style
%%% ---------------------------------------------------------------------------
%%% change colors
\ifthenelse{\boolean{@parts}}{%
   \renewcommand{\cftpartfont}{\color{parttitlecolor}\normalfont}%
   \renewcommand{\cftpartpagefont}{\color{parttitlecolor}\normalfont}%
}{\relax}
%%% use correct format of parts in TOC
%%% http://tex.stackexchange.com/a/140053
\def\ttl@tocpart{\def\ttl@a{\protect\numberline{\thepart}\@gobble{}}}
%%% use equal width for part numbers and chapter numbers
\setlength{\cftpartnumwidth}{\cftchapnumwidth}
%%% use bold parts instead of smallcaps if specified in the options
\ifkspths@tocpartentriesbold
   \renewcommand{\thepart}{\Roman{part}}%
   \renewcommand{\cftpartpresnum}{\normalfont\bfseries}%  \scshape
   \let\cftpartfontoriginal\cftpartfont
   \renewcommand{\cftpartfont}{%
\let\spacedlowsmallcapstemp\spacedlowsmallcaps%
\let\spacedlowsmallcaps\relax%
\cftpartfontoriginal\bfseries}%
   \let\cftpartpagefontoriginal\cftpartpagefont
   \renewcommand{\cftpartafterpnum}{\let\spacedlowsmallcaps\spacedlowsmallcapstemp\ifkspths@dottedtoc\else\cftparfillskip\fi}
   \renewcommand{\cftpartpagefont}{\cftpartpagefontoriginal\bfseries}%
\fi
%%% use bold chapters instead of smallcaps if specified in the options
\ifkspths@tocchapterentriesbold
   \renewcommand{\cftchappresnum}{\normalfont\bfseries}%
   \renewcommand{\cftchapfont}{%
\let\spacedlowsmallcapstemp\spacedlowsmallcaps%
\let\spacedlowsmallcaps\relax%
\normalfont\bfseries}%
   \renewcommand{\cftchapafterpnum}{\let\spacedlowsmallcaps\spacedlowsmallcapstemp\ifkspths@dottedtoc\else\cftparfillskip\fi}
   \renewcommand{\cftchappagefont}{\normalfont\bfseries}%
\fi
%%% use dotted leaders for parts/chapters if specified in the options
\ifkspths@dottedtocparts
   \renewcommand{\cftpartleader}{\cftdotfill{\cftdotsep}}%
\fi
\ifkspths@dottedtocchapters
   \renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}%
\fi
%%% additional layout settings
%%% ---------------------------------------------------------------------------
%%% left-aligned footnotes
\deffootnote{1.5em}{1em}{\makebox[1.5em][l]{\thefootnotemark}}
%%% ragged lists
%%% http://tex.stackexchange.com/a/104093
\RequirePackage{ragged2e}   % improved ragged text
\RequirePackage{etoolbox}   %  programming tools for LaTeX class and package authors
\newkomafont{itemize}{}
\newkomafont{enumerate}{}
\newkomafont{description}{}
\ifkspths@raggedlists
   \setkomafont{itemize}{\RaggedRight}
   \setkomafont{enumerate}{\RaggedRight}
   \setkomafont{description}{\RaggedRight}
\fi
\AtBeginEnvironment{itemize}{\preto\item{\usekomafont{itemize}}}
\AtBeginEnvironment{enumerate}{\preto\item{\usekomafont{enumerate}}}
\AtBeginEnvironment{description}{\preto\item{\usekomafont{description}}}
%%% line break controls
%%% http://www.tex.ac.uk/FAQ-widows.html
\clubpenalty = 10000 % disable first line of a paragraph at the end of a page (orphans / Schusterjungen)
\widowpenalty = 10000 % disable last line of a paragraph at the start of a page (widows / Hurenkinder)
\finalhyphendemerits=50000000 % avoid hyphenation before last line of paragraph
%%% commands for manual word spacing controls
%%% http://tex.stackexchange.com/a/23924
\newdimen\origiwspc
\newdimen\origiwstr
\newcommand{\resetwspc}{\fontdimen2\font=\origiwspc}
\newcommand{\resetwstr}{\fontdimen3\font=\origiwstr}
\newcommand{\reducewspc}[1][0.95]{\fontdimen2\font=#1\origiwspc}
\newcommand{\reducewstr}[1][0.95]{\fontdimen3\font=#1\origiwstr}
\AtBeginDocument{%
\origiwspc=\fontdimen2\font% original inter word space
\origiwstr=\fontdimen3\font% original inter word stretch
}
%%% do not highlight links (remove colors set by <arsclassica>)
\RequirePackage{hyperref}
\hypersetup{
   hidelinks,     % remove link color and border
}