-
Notifications
You must be signed in to change notification settings - Fork 3
/
common.tex
374 lines (336 loc) · 12.2 KB
/
common.tex
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
%\usepackage[showframe]{geometry}
\usepackage{geometry}
\geometry{nohead,
%height=466pt,
width=345pt, % <- make sure the width is the same as b5
%tmargin=113pt,
%top=2.5truecm,
bottom=3truecm,
paperwidth=170truemm,
paperheight=240truemm}
%\usepackage[frame,noinfo,width=176truemm,height=246truemm,center]{crop}
\usepackage[noinfo,width=176truemm,height=246truemm,center]{crop}
\input{common-lite}
% Refer to a parsec.
\RenewDocumentCommand{\sref}{m}{\textSref{%
\ifthenelse{%
\equal{\value{parsec}}{\ourrawref{#1::parsec}}%
}{%
\ref{#1::point}%
}{%
\ref{#1}%
}%
}}
\newcommand{\colofon}[5]{%
\vspace*{4em}
\noindent
\begin{center}
#5
\vspace{3em}
\textcolor{darkblue}{\textsf{\textbf{ Identifiers}}}
\vspace{.5em}
\href{https://hdl.handle.net/#4}{hdl:~#4}
\vspace{.5em}
\href{https://arxiv.org/abs/#3}{arXiv:~#3}
\vspace{.5em}
\textsc{isbn:}~#2
\end{center}
\vspace{3em}
\begin{center}
\textcolor{darkblue}{\textsf{\textbf{ Persistent links}}}
\vspace{.5em}
\purl{https://arxiv.org/abs/#3}
\vspace{.5em}
\purl{https://doi.org/#4}
\vspace{.5em}
\purl{https://hdl.handle.net/#4}
\end{center}
\vspace{3em}
\begin{center}
\textcolor{darkblue}{\textsf{\textbf{Source code}}}
\vspace{.5em}
\begin{tabular}{rl}
\LaTeX{} & \purl{https://github.com/westerbaan/theses} \\
cover & \purl{https://github.com/westerbaan/ndpt}
\end{tabular}
\end{center}
\vfill{}
\noindent
Printed by GVO drukkers \& vormgevers B.V., Ede,
\purl{https://proefschriften.nl}.
\vspace{1em}
\noindent
Where applicable,
\ccCopy{}~2019 #1,
\ccLogo{}\,\ccAttribution{} available under \textsc{cc by}, \cite{ccby40}.
\newpage
}
% used for arithmetic
\newcounter{tmptmp}
\newcounter{tmptmp2}
% The content of this thesis is grouped into numbered paragraphs,
% which are called "parsecs" (for paragraph--section),
% and these parsecs contain several points.
\newcounter{parsec} % keeps track of the current parsec number
\newcounter{parsecMajor}
\newcounter{parsecMinor} % parsec = 10 * parsecMajor + parsecMinor
\newcommand\refsforparsec{%
\setcounter{parsecMajor}{\value{parsec}/10}%
\setcounter{parsecMinor}{\value{parsec}-10*\value{parsecMajor}}%
\setcounter{parsec}{\value{parsec}-1}%
\refstepcounter{parsec}%
}
% The first argument is the label this parsec will have--use \sref
% to refer to a parsec.
\NewDocumentEnvironment{parsec}{g o}{%
\leavevmode\unskip%
\par\vskip1em\noindent%
\renewcommand{\theparsec}{\the\value{parsecMajor}\alph{parsecMinor}}%
\setcounter{parsec}{#1}%
\refsforparsec{}%
%%\setcounter{point}{0}% - point is set to 0 by \numberwithin
% In the footer of every odd page we list the parsecs present on
% the spread. We pass this information to the footer via the
% \markboth,\leftmark,\rightmark-mechanism, which is normally
% used to display the section and subsection names and numbers
% in the header.
% Recall that \leftmark will return the LAST value passed
% to the first argument of \markboth on this page. (The difficulty
% of implementing \leftmark is that a \markboth that will belong
% to the next page can be called before the current page is shipped,
% because this \markboth may be part of the text that overflows the
% current page.)
% \rightmark will return the FIRST value passed to the second
% argument of \markboth on this page.
% Since we would not only like to know if this parsec with number
% say N is present on this spread, but also whether it spills over
% to the next spread (or has spilled over from the previous spread),
% we keep track of whether the parsec started on this spread,
% encoded by 2N, or whether the parsec ended on this spread,
% encoded by 2N+1.
\setcounter{tmptmp}{2*\value{parsec}}%
\markboth{\the\value{tmptmp}}{\the\value{tmptmp}}%
\IfValueT{#2}{\label{#2}}%
% For the table of contents:
\renewcommand{\thepoint}{\the\value{parsecMajor}\alph{parsecMinor}}%
\setcounter{point}{\value{point}-1}%
\refstepcounter{point}%
\label{parsec-\the\value{parsec}}%
% Display the parsec number in the margin.
\marginnote{\makebox[3em][c]{\textParsecNumber{%
\the\value{parsecMajor}%
\alph{parsecMinor}%
}}}%
\ignorespaces%
}{%
\leavevmode\unskip%
\setcounter{tmptmp}{2*\value{parsec}+1}%
\markboth{\the\value{tmptmp}}{\the\value{tmptmp}}%
\ignorespaces%
}
\newcounter{point} % keeps track of the current point
\newcounter{pointMajor}
\newcounter{pointMinor}
\numberwithin{point}{parsec}
\newcounter{pointdepth} % keeps track of the depth of the current point
% --- points may be nested.
\newcommand\refsforpoint{%
\setcounter{pointMajor}{\value{point}/10}%
\setcounter{pointMinor}{\value{point}-10*\value{pointMajor}}%
\setcounter{point}{\value{point}-1}%
\refstepcounter{point}%
}
\NewDocumentEnvironment{point}{g o g}{%
\leavevmode\unskip%
\setcounter{pointdepth}{\value{pointdepth}+1}%
\refstepcounter{point}% TODO: <- is this needed?
\setcounter{point}{#1}%
% setup labels
\IfValueT{#2}{%
\renewcommand{\thepoint}{\the\value{parsec}}%
\refsforpoint{}%
\label{#2::parsec}%
\renewcommand{\thepoint}{\Roman{pointMajor}\alph{pointMinor}}%
\refsforpoint{}%
\label{#2::point}%
\renewcommand{\thepoint}{\theparsec\,\Roman{pointMajor}\alph{pointMinor}}%
\refsforpoint{}%
\label{#2}%
}%
\renewcommand{\thepoint}{\theparsec\,\Roman{pointMajor}\alph{pointMinor}}%
\refsforpoint{}%
\label{parsec-\the\value{parsec}.\the\value{point}}%
\ifthenelse{\equal{\value{point}}{10}}{}{%
\ifthenelse{\equal{\value{pointdepth}}{1}}{%
\par\penalty-100\vskip.6em\noindent%
}{%
\ifthenelse{\equal{\value{pointdepth}}{2}}{%
\par\penalty-50\vskip.2em\noindent%
}{%
\par\penalty-25\vskip.1em\noindent%
}%
}%
\marginnote{\makebox[2em][c]{\small%
\ifthenelse{\equal{\value{pointdepth}}{1}}{%
\textPointNumberI{\Roman{pointMajor}\alph{pointMinor}}%
}{%
\ifthenelse{\equal{\value{pointdepth}}{2}}{%
\textPointNumberII{\Roman{pointMajor}\alph{pointMinor}}%
}{%
\textPointNumberIII{\Roman{pointMajor}\alph{pointMinor}}%
}%
}}}%
}%
\IfValueT{#3}{%
\ifthenelse{\equal{\value{pointdepth}}{1}}{%
\textPointHeaderI{#3}%
}{%
\ifthenelse{\equal{\value{pointdepth}}{2}}{%
\textPointHeaderII{#3}%
}{%
\textPointHeaderIII{(#3)}%
}}%
\ \ }%
\ignorespaces%
}{%
\leavevmode\unskip%
\setcounter{pointdepth}{\value{pointdepth}-1}%
\ignorespaces%
}
% Adjust footer and header:
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt} % we want no header line
% Since we use \markboth,\leftmark,\rightmark to keep track of the parsecs
% on a given spread, we should neutralize its old user:
\renewcommand{\chaptermark}[1]{}
\renewcommand{\sectionmark}[1]{}
\fancyhead{}
% These counters are used for computation
\newcounter{firstParsec}
\newcounter{lastParsec}
\newcounter{firstParsecF}
\newcounter{lastParsecF}
\newcounter{firstParsecMajor}
\newcounter{firstParsecMinor}
\newcounter{lastParsecMajor}
\newcounter{lastParsecMinor}
% parsecToBeContinued is 1 if the previous spread spilled a parsec,
% and 0 otherwise.
\newcounter{parsecToBeContinued}
\setcounter{parsecToBeContinued}{0}
\newcommand\ourfancyfooters{%
% Set the footer. It contains the parsecs on this page.
% We use "\rightmark+0", because \rightmark might be empty.
\fancyfoot[CE]{%
\IfInteger{\rightmark}{%
\setcounter{tmptmp}{\leftmark+0}%
\ifthenelse{\equal{\value{tmptmp}}{\value{lastParsecF}}}{%
% the last parsec encountered on this page is the same as
% the last parsec encountered on the previous page;
% so either the parsec spans the whole of this even page,
% or there's no parsec active at all.
% In both cases the first parsec on the spread will
% be the first parsec on the odd page that
% comes next, so we need not set firstParsecF here.
\setcounter{firstParsecF}{0}%
}{%
\setcounter{firstParsecF}{\rightmark+0}%
}
}{%
}%
}%
\fancyfoot[RO]{%
\textsf{\footnotesize\textcolor{lightgray}{\thepage}}}%
\fancyfoot[CO]{%
% firstParsecF is already set by the even page that came before,
% ... unless it is 0.
\ifthenelse{\equal{\value{firstParsecF}}{0}}{%
\setcounter{firstParsecF}{\rightmark+0}%
}{%
%do nothing
}
\setcounter{firstParsec}{\value{firstParsecF}/2}%
\setcounter{lastParsecF}{\leftmark+0}%
\ifthenelse{\equal{\value{lastParsecF}}{0}}{%
% do nothing
}{%
\setcounter{lastParsec}{\value{lastParsecF}/2}%
\textPointNumberI{%
\ifthenelse{\equal{\value{parsecToBeContinued}}{1}}{..}{}%
\setcounter{firstParsecMajor}{\value{firstParsec}/10}%
\setcounter{firstParsecMinor}{\value{firstParsec}-\value{firstParsecMajor}*10}%
\the\value{firstParsecMajor}\alph{firstParsecMinor}%
\ifthenelse{\equal{\value{firstParsec}}{\value{lastParsec}}}{%
% TODO
}{% no footer without parsecs
\setcounter{tmptmp}{\value{firstParsec}+1}%
\ifthenelse{\equal{\value{tmptmp}}{\value{lastParsec}}}{, }{--}% TODO: fix this, maybe?
\setcounter{lastParsecMajor}{\value{lastParsec}/10}%
\setcounter{lastParsecMinor}{\value{lastParsec}-\value{lastParsecMajor}*10}%
\the\value{lastParsecMajor}\alph{lastParsecMinor}%
}%
\setcounter{tmptmp}{\value{lastParsec}*2}%
\ifthenelse{\equal{\value{tmptmp}}{\value{lastParsecF}}}{%
..\setcounter{parsecToBeContinued}{1}%
}{%
\setcounter{parsecToBeContinued}{0}%
}%
}%
}%
}%
}
\ourfancyfooters
\fancypagestyle{plain}{\ourfancyfooters}
% Index support for parsecs
\def\parsechyperlink#1{\sref{parsec-#1}}
\makeatletter
\def\@wrindex#1{%
\protected@write\@indexfile{}%
{\string\indexentry{#1|parsechyperlink{\the\value{parsec}.\the\value{point}}}{\the\value{parsec}.\the\value{point}}}%
\endgroup
\@esphack}%
\makeatother
% TOC support for parsecs
\let\oldchapter\chapter%
\renewcommand\chapter[1]{%
\oldchapter{#1}%
\setcounter{tmptmp}{(\value{parsec}/10)*10+10}
\addtocontents{parsectoc}{\protect\contentsline{chapter}{\numberline{\thechapter} #1}{\sref{parsec-\the\value{tmptmp}}}{chapter.\thechapter}}%
}
\let\oldsection\section%
\renewcommand\section[1]{%
\oldsection{#1}%
\setcounter{tmptmp}{(\value{parsec}/10)*10+10}
\addtocontents{parsectoc}{\protect\contentsline{section}{\numberline{\thesection} #1}{\sref{parsec-\the\value{tmptmp}}}{section.\thesection}}%
}
\let\oldsubsection\subsection%
\renewcommand\subsection[1]{%
\oldsubsection{#1}%
\setcounter{tmptmp}{(\value{parsec}/10)*10+10}
\addtocontents{parsectoc}{\protect\contentsline{subsection}{\numberline{\thesubsection} #1}{\sref{parsec-\the\value{tmptmp}}}{subsection.\thesubsection}}%
}
\let\oldsubsubsection\subsubsection%
\renewcommand\subsubsection[1]{%
\oldsubsubsection{#1}%
\setcounter{tmptmp}{(\value{parsec}/10)*10+10}
\addtocontents{parsectoc}{\protect\contentsline{subsubsection}{\numberline{\thesubsubsection} #1}{\sref{parsec-\the\value{tmptmp}}}{subsubsection.\thesubsubsection}}%
}
\newcommand\backmattertitle[1]{{%
\sffamily\color{darkblue}\Huge\bfseries #1\vspace{1em}}}
% customize title of index
\makeatletter
\renewenvironment{theindex}
{\if@twocolumn
\@restonecolfalse
\else
\@restonecoltrue
\fi
\twocolumn[\backmattertitle{Index}]%
\thispagestyle{plain}\parindent\z@
\parskip\z@ \@plus .3\p@\relax
\columnseprule \z@
\columnsep 35\p@
\let\item\@idxitem}
{\if@restonecol\onecolumn\else\clearpage\fi}
\makeatother