This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhDSettings.sty
532 lines (443 loc) · 16.3 KB
/
PhDSettings.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
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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{PhDSettings}[2020/04/08 LaTeX helpers for Ph.D. thesis]
%
% Anmerkung:
% Lädt das Paket "minted" für formatierte Quelltexte.
% Für minted muss LaTeX mit der Option --shell-escape aufgerufen werden.
%
% Zudem muss das Paket "pgf-pie" vermutlich von Hand installiert werden.
%
%%% Hyphenation
% - hyphen sign, no others in this word (hy-phenation > hy-|phenation)
% "= hypen sign that allows other breaks (h"=yphenation > h-|y|phen|a|tion)
% "~ hyphen sign without line break (hy"~phenation > hy-phenation)
% \- possible hyphenation with sign (h\-yphenation > h|y|phen|a|tion)
% "" possible hyphenation without sign ((super"~)""hyphenation > (super-)*hy|pen|a|tion)
% "| break ligature and allow hyphenation
%
% the pipe indicates possible line break with hyphen sign
% asterisk indicates possible line break without sign
%%% Basispakete und Einstellungen für Schrift und Satz
\RequirePackage[T1]{fontenc}
\RequirePackage{lmodern}
% Sprachanpassung, verbesserte Trennregeln
\RequirePackage[ngerman]{babel}
\RequirePackage{microtype}
% Seiten nicht bis unten füllen
% https://tex.stackexchange.com/a/36429
% Dann ggf. auch im Paket footmisc die Option "bottom" aktivieren
\raggedbottom
% Euro-Zeichen
\RequirePackage{textcomp}
% Erforderlich für korrekte Anführungszeichen in Literatur
\RequirePackage{fvextra} % "Warning: csquotes should be loaded after fvextra [...]"
\RequirePackage[style=german]{csquotes}
% Befehl "\runinhead" für Glossar
% https://github.com/JonHoy/Latex-Practice/blob/master/Books/Springer/contributed%2Bbooks/styles/svmult.cls
\makeatletter
\newcommand\runinhead{%
\@startsection{paragraph}{4}{\z@}%
{-6\p@}%
{-6\p@}%
{\normalfont\normalsize\bfseries\boldmath
\rightskip=\z@ \@plus 8em\pretolerance=10000%
}%
}
\makeatother
% Listen bearbeiten
\RequirePackage{enumitem}
% Dann: Listenabstand links verringern, z.B. in multicols:
% \bgroup
% \setlist[itemize]{leftmargin=16pt}
% ...
% \egroup
% Sinnvoller Alias für noch kleinere Schrift
\let\smaller\footnotesize
% Neue Zeile nach \paragraph
\let\nonewlineparagraph\paragraph
\renewcommand{\paragraph}[1]{\nonewlineparagraph{#1}\mbox{}\\}
\newcommand{\raggedparagraph}[1]{\vspace{-1.5ex}\paragraph{#1}}
%%% Zugriff auf Titel, Autor und Datum
\makeatletter
\let\thetitle\@title
\let\theauthor\@author
\let\thedate\@date
\makeatother
%%% Farben, Grafiken und Symbole
\RequirePackage[table,dvipsnames]{xcolor}
% Font Awesome
\RequirePackage{fontawesome5}
% includegraphics, definecolors
\RequirePackage{graphicx}
% Labels
\RequirePackage[
font=small,
labelfont=bf,
format=hang,
justification=justified,
singlelinecheck=false
]{caption}
\captionsetup[listing]{aboveskip=-4pt}
%\captionsetup[figure]{margin=15pt}%
%\captionsetup[table]{skip=15pt} % Quelle unterhalb Tabellen weiter absetzen
%\captionsetup[box]{...}
% Quelle in Grafik/Tabellen angeben
% Variante 1: Sauber und elegant, aber ohne hängenden Einzug: https://tex.stackexchange.com/a/246285
%\newcommand{\source}[1]{\vspace{-5pt} \caption*{\textbf{Quelle:} {#1}} }
% Variante 2 mit hängendem Einzug: https://tex.stackexchange.com/a/24610
\RequirePackage{hanging, calc}
\newlength{\hangwidth} % Breite des Einzugs für den folgenden Befehl
\newcommand{\hangingindent}[1]{\settowidth{\hangwidth}{#1}\hangpara{\hangwidth}{1}#1}
\newcommand{\source}[1]{%
\vspace{2pt}% Abstand zum eigentlichen Label etwas vergrößern
\raggedright% Zwingend linksbündig
\small% Schriftgröße dem Label (siehe Paket caption oben)
\hangingindent{\textbf{Quelle: }}% Hängenden Einzug anlegen
#1% Text der Quelle hinzufügen
}
% Mehrere Spalten
\RequirePackage{multicol}
% cmark (crossmark), xmark (x-mark)-Shortcuts, Mathematik-Symbole
\RequirePackage{amssymb}
\RequirePackage{pifont}
\newcommand{\cmark}{\ding{51}}
\newcommand{\xmark}{\ding{55}}
%%% Abstände
% Absatzabstand
\parskip = \medskipamount
% Zeilenabstand 1,5
\RequirePackage[onehalfspacing]{setspace}
% Zeilenabstand 1,5 in Tabellen
\renewcommand{\arraystretch}{1.5}
% Abstand zwischen Floats im Text und Text
% https://tex.stackexchange.com/a/26522/193364
\setlength{\intextsep}{14.0pt plus 2.0pt minus 2.0pt}
% Abstand zur Fussnote vergrössern
% https://tex.stackexchange.com/a/371139
\addtolength{\skip\footins}{6pt}
% fbox-Abstände
\fboxsep = 2pt % Abstand innerhalb von fbox'en
\fboxrule = .3pt % Randstärke von fbox'en
% Seitenabstände
% Für A4 / A5 anpassen
\headheight = 10mm % Abstand vom oberen Rand zum Text
\footskip = 10mm
\oddsidemargin = 0mm % Rand aller ungeraden Seiten
\textwidth = 160mm % Gesamtbreite des Textrumpfes
\textheight = 235mm % Gesamthöhe des Textrumpfes
% Kopf-/Fusszeile
\RequirePackage{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\headmark} % Kopfzeile aussen: Links: Kapitel, rechts: Unterkapitel
\ofoot*{\pagemark} % Fusszeile aussen: Seite
% Mathematik...
\RequirePackage{mathtools} % dcases-Environment
% Float (für Positionierungsoption "H")
\RequirePackage{float}
%%% Quelltexte
% newfloat, wird durch minted automatisch geladen
% https://tex.stackexchange.com/questions/95631/defining-a-new-type-of-floating-environment
%\RequirePackage{newfloat}
%\DeclareFloatingEnvironment[within=chapter,fileext=boxlst,placement={!ht},name="Box"]{box}
% Schrift "Source Code Pro" für Typewriter verwenden, besser zu lesen
\RequirePackage{sourcecodepro}
% Probleme mit Backtick (`) beheben, siehe
% https://github.com/silkeh/latex-sourcecodepro/issues/4
% Sonst:
% Package textcomp Info: Symbol \textasciigrave not provided by
% (textcomp) font family SourceCodePro-TLF in TS1 encoding.
% (textcomp) Default family used instead on input line 21.
% ???
% Minted für schönere Quelltextformatierung
\RequirePackage[
newfloat, % newfloat-Paket nutzen
cachedir=.mintedcache % Cache-Verzeichnis
]{minted}
% R-Eigenschaften
\newmintedfile{R}{
breaklines=true, % Automatischer Zeilenumbruch
breakindentnchars=4, % Einrücken bei Zeilenumruch
breaksymbolleft=, % Kein Symbol bei Zeilenumbruch
fontsize=\small, % Schriftgröße
frame=single, % Vollständiger Rahmen
framesep=6pt, % Innerer Abstand
framerule=.3pt, % Rahmenbreite
numbers=left, % Zeilennummern links
rulecolor=\color{gray!55}, % Rahmenfarbe
style=friendly, % Stil -> vgl. pygmentize -L styles
xleftmargin=2em, % Zeilennummern inline
}
% Zeilennummern formatieren
\renewcommand{\theFancyVerbLine}{%
\sffamily\footnotesize\color{gray!75!black}%
\arabic{FancyVerbLine}%
}
% Quelltext-Environment einrichten
\SetupFloatingEnvironment{listing}{name=Quelltext, listname=Quelltexte, placement=h!}
% R aus LaTeX heraus ausführen
% Anmerkung: Der Dateiname darf unter keinen Umständen irgendwelche
% Sonderzeichen (nicht-ASCII) enthalten! Leerzeichen sind in Ordnung.
\newcommand{\executeR}[1]{%
\ignorespaces%
\immediate%
\write18{%
echo;%
echo "executeR: #1:";%
cd "/Users/fox/Documents/Studium - Promotion/Datenanalyse";%
R --no-save --no-restore --slave -f '#1' --args FromLaTeX;%
echo;%
}%
\ignorespaces%
}
%%% Struktur und Gliederung
% Nummerierung bis Gliederungsebene 3. -> Ggf. auch die Tiefe des Inhaltsverzeichnisses anpassen.
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
% Anhang: Nur Kapitel in Gliederung
% https://tex.stackexchange.com/a/214140
\RequirePackage{etoolbox}
\appto\appendix{\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}}
\appto\listoffigures{\addtocontents{lof}{\protect\setcounter{tocdepth}{1}}}
\appto\listoftables{\addtocontents{lot}{\protect\setcounter{tocdepth}{1}}}
% Inhaltsübersicht, funktioniert nur bis zum ersten nachfolgenden \tableofcontents. https://komascript.de/node/1003
\newcommand*{\showtableofcontents}{%
\begingroup
\edef\EndGroup{\endgroup % EndGroup vs. endgroup zum Einfangen der tocdepth
\noexpand\setcounter{tocdepth}{\the\value{tocdepth}}}%
\csname @fileswfalse\endcsname
\setcounter{tocdepth}{1}% <- Gliederungstiefe
\def\contentsname{Inhaltsübersicht}% <- Kapitelbezeichnung
\tableofcontents
\EndGroup
}
% Nummerierung ohne Kapitel
\RequirePackage{chngcntr}
\counterwithout{footnote}{chapter}
\counterwithout{listing}{chapter}
% "Anhang" vor Anhangs-Buchstaben
% https://tex.stackexchange.com/a/319109
\AddToHook{cmd/appendix/after}{%
\AddToHook{cmd/chapterformat/before}{\chapapp\nobreakspace}%
\AddToHook{cmd/chaptermarkformat/before}{\chapapp\nobreakspace}%
\addtocontents{toc}{\appendixtocentry}%
}
\NewDocumentCommand{\appendixtocentry}{}{%
\DeclareTOCStyleEntry[
entrynumberformat=\tocappendixnumber,
dynnumwidth
]{chapter}{chapter}%
}
\NewDocumentCommand{\tocappendixnumber}{m}{%
\appendixname~#1%
}
% Seitenumbruch innerhalb von Listen vermeiden? Klappt aber nicht 100%tig wie gewünscht
% https://tex.stackexchange.com/a/16264
%\makeatletter
%\newcommand*\nobreaklist{\@beginparpenalty=\@M}
%\makeatother
%%% Tabellen
\RequirePackage{tabularx,booktabs,multirow,makecell} % Tabellenformatierung
\RequirePackage{longtable} % Tabellen über mehrere Seiten
%% Zelldefinitionen
% Rechtsbündiger Paragraph
% Verwendung: R{breite}, z.B. R{1cm}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
% Zentrierter Paragraph
% Verwendung: C{breite}, z.B. C{1cm}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
% Dicke vertikale Linie
\newcolumntype{I}{!{\vrule width \heavyrulewidth}}
% Erste Spalte mit rowcolors ohne Rand links (Argument = Zielspalte)
% Verwendung: z.B. A{l} oder in Verbindung mit Paragraphen: A{p{1cm}} oder A{R{1cm}}
\newcolumntype{A}[1]{@{} >{\columncolor{white}[0pt][\tabcolsep]} #1}
% Letzte Spalte mit rowcolors ohne Rand rechts (Argument = Zielspalte)
% Verwendung: Wie A
\newcolumntype{Z}[1]{>{\columncolor{white}[\tabcolsep][0pt]} #1 @{}}
% Head/Body/Foot
\newcommand{\tablehead}{\toprule[\heavyrulewidth]\rowcolor{white}} % Kopfzeile immer weiss
\newcommand{\tablebody}{\midrule[\lightrulewidth]}
\newcommand{\tablefoot}{\bottomrule[\heavyrulewidth]}
% Tabellen-Formatierung setzen
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
% Standardwerte für Tabellen: tabularx-Umgebung neu definieren
\let\regulartabularx=\tabularx
\let\endregulartabularx=\endtabularx
\renewenvironment{tabularx}{%
\small%
\rowcolors{2}{gray!5}{}{}% Wechselnde Zeilenfarben
\vspace{5pt}% Abstand zwischen Caption und Tabellenbeginn
\regulartabularx%
}{%
\endregulartabularx%
\vspace{5pt}% Abstand zwischen Tabellenende und Quellenangabe, wenn nicht oben bei \source
}
% Schöner wäre es sicherlich mit einem optionalen Parameter oder die Stern-Variante,
% aber weil LaTeX so schön einfach und verständlich ist machen wir lieber einen eigenen Befehl,
% weil mir meine Zeit zu schade dafür ist
\newenvironment{tabularxnorowcolors}{%
\small% Kleinere Schrift
\vspace{5pt}% Abstand zwischen Caption und Tabellenbeginn
\regulartabularx%
}{%
\endregulartabularx%
\vspace{5pt}%
}
%%% TikZ
\RequirePackage{tikz}
\usetikzlibrary{decorations.pathreplacing} % Braces etc.
\usetikzlibrary{decorations.text} % text along path, etc.
\usetikzlibrary{positioning} % Relative Positionierung von Knoten: 3pt left of node
\usetikzlibrary{backgrounds} % Rahmen ("show background rectangle" aka "framed")
\usetikzlibrary{fit} % Knoten um andere Knoten herum: fit=(node_a) (node_b) ...
% Baumdiagramme
\RequirePackage[linguistics,edges]{forest}
% Kreisdiagramme
% Achtung: Paket manuell installiert
\RequirePackage{pgf-pie}
% Standardschrift für tikz setzen
\tikzset{every picture/.style={font=\sffamily}}
% Rahmen um jedes forest setzen
% Funktioniert nicht mit Forest: \tikzset{every picture/.style={show background rectangle}}
\forestset{default preamble={tikz+={\tikzset{show background rectangle}}}}
% Bewertungspunkte: \score{1}{3} = 1 von 3 Punkten = *oo
\newcommand\score[2]{
\pgfmathsetmacro\pgfxa{#1+1}
\tikzstyle{scorestars}=[circle, draw, inner sep=1.8pt, anchor=west]
\begin{tikzpicture}[baseline]
\foreach \i in {1,...,#2} {
\pgfmathparse{(\i<=#1?"black!60":"white")}
\edef\starcolor{\pgfmathresult}
\draw (\i*1.6ex,3pt) node[name=star\i, scorestars, fill=\starcolor] {};
}
\end{tikzpicture}
}
% Fortschrittsbalken: \progress{90.3}{3.5cm} # Prozent, Gesamtbreite
\newcommand\progress[2]{
\begin{tikzpicture}[baseline=1mm]
\pgfmathparse{(#2*#1/100)}
\edef\barwidth{\pgfmathresult}
\fill [black!20] (0,0) rectangle (\barwidth, .4);
\draw [black!50] (0,0) rectangle (#2, .4);
\node [anchor=west, inner sep=0, font=\smaller\sffamily] at (.1, .2) {\StrSubstitute{#1}{.}{,}\,\%};
\end{tikzpicture}
}
\newcommand\progressLessThanOnePercent[1]{
\begin{tikzpicture}[baseline=1mm]
\draw [black!50] (0,0) rectangle (#1, .4);
\node [anchor=west, inner sep=0, font=\smaller\sffamily] at (.1, .2) {$<$~0,1\,\%};
\end{tikzpicture}
}
%%% Fußnoten innerhalb von Floats (Tabellen, Grafiken)
% Mit \pushftn vor Float sammeln und mit \popftn am Ende freigeben.
% Korrekte Seitenplatzierung muss geprüft werden
% https://tex.stackexchange.com/a/43695
\makeatletter
\newtoks\FTN@ftn
\def\pushftn{%
\let\@footnotetext\FTN@ftntext\let\@xfootnotenext\FTN@xftntext
\let\@xfootnote\FTN@xfootnote}
\def\popftn{%
\global\FTN@ftn\expandafter{\expandafter}\the\FTN@ftn}
\long\def\FTN@ftntext#1{%
\edef\@tempa{\the\FTN@ftn\noexpand\footnotetext
[\the\csname c@\@mpfn\endcsname]}%
\global\FTN@ftn\expandafter{\@tempa{#1}}}%
\long\def\FTN@xftntext[#1]#2{%
\global\FTN@ftn\expandafter{\the\FTN@ftn\footnotetext[#1]{#2}}}
\def\FTN@xfootnote[#1]{%
\begingroup
\csname c@\@mpfn\endcsname #1\relax
\unrestored@protected@xdef\@thefnmark{\thempfn}%
\endgroup
\@footnotemark\FTN@xftntext[#1]}
\makeatother
%%% Fußnoten: Abstand zwischen Ziffer und Text
% https://tex.stackexchange.com/a/79065
\RequirePackage[hang, bottom]{footmisc}
\setlength{\footnotemargin}{-0.5em}
\makeatletter
\ifFN@para
\else
\long\def\@makefntext#1{%
\ifFN@hangfoot
\bgroup
\setbox\@tempboxa\hbox{%
\ifdim\footnotemargin>0pt
\hb@xt@\footnotemargin{\@makefnmark\hss}%
\else
\@makefnmark\hskip-\footnotemargin %%Changed here
\fi
}%
\leftmargin\wd\@tempboxa
\rightmargin\z@
\linewidth \columnwidth
\advance \linewidth -\leftmargin
\parshape \@ne \leftmargin \linewidth
\footnotesize
\@setpar{{\@@par}}%
\leavevmode
\llap{\box\@tempboxa}%
\parskip\hangfootparskip\relax
\parindent\hangfootparindent\relax
\else
\parindent1em
\noindent
\ifdim\footnotemargin>\z@
\hb@xt@ \footnotemargin{\hss\@makefnmark}%
\else
\ifdim\footnotemargin=\z@
\llap{\@makefnmark}%
\else
\llap{\hb@xt@ -\footnotemargin{\@makefnmark\hss}}%
\fi
\fi
\fi
\footnotelayout#1%
\ifFN@hangfoot
\par\egroup
\fi
}
\fi
\makeatother
% vdots ohne vertikalen Abstand
% https://tex.stackexchange.com/a/112212/193364
\makeatletter
\DeclareRobustCommand{\rvdots}{%
\vbox{
\baselineskip4\p@\lineskiplimit\z@
\kern-\p@
\hbox{.}\hbox{.}\hbox{.}
}}
\makeatother
%%% String-Funktionen
% Würde ohnehin von BibLaTeX geladen werden
\RequirePackage{xstring}
% Leerzeichen, falls danach nicht ein Punkt-Zeichen kommt, benötigt für die folgenden Befehle
\RequirePackage{xspace}
% "z.B." und "u.a." mit schmalem Leerzeichen, vgl. https://www2.informatik.hu-berlin.de/sv/lehre/typographie.pdf
\newcommand{\zB}{z.\,B.\xspace}
\newcommand{\ua}{u.\,a.\xspace}
\newcommand{\dasheisst}{d.\,h.\xspace}
% Seitenanzahl mit schmalem Leerzeichen
\newcommand{\pg}[1]{S.\,\StrSubstitute{#1}{ }{\,}\xspace}
%%% Work in progress: Demotexte
\RequirePackage{blindtext}
%%% hyperref muss als letztes Paket geladen werden. Das weiss man doch...
% "My guess is that you are not following the rule "load hyperref as the last package" and that something is redefining footnote."
% https://tex.stackexchange.com/a/16269/193364
% "Which packages should be loaded after hyperref instead of before?"
% https://tex.stackexchange.com/q/1863
\RequirePackage[
colorlinks=true, hyperindex,
linkcolor=black, citecolor=black, urlcolor=black,
plainpages=false, pdfpagelabels=true,
bookmarksopen=true, bookmarksopenlevel=0, bookmarksnumbered=true,
pdfauthor={\theauthor},
pdftitle={\thetitle},
pdfsubject={\thesubject},
pdfcreator={LaTeX},
pdfkeywords={}
]{hyperref}
% URL-Schriftart (Paket url, geladen mit hyperref)
\urlstyle{same}