-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.tex
362 lines (342 loc) · 12 KB
/
main.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
\documentclass[12pt,openright,hyperfootnotes,hidelinks]{book}
\usepackage[utf8]{inputenc}
\usepackage[titletoc,title]{appendix}
\usepackage[cmyk]{xcolor}
% \usepackage[linedheaders,parts,pdfspacing,manychapters]{classicthesis}
\usepackage[]{fullpage}
% \usepackage[standardsections]{scrhack} % https://tex.stackexchange.com/questions/511049/conflict-between-titlesec-package-and-scrbook-class-after-most-recent-update-of
\usepackage[section=chapter,numberedsection,acronym,toc,nonumberlist,index,style=altlist]{glossaries}
\usepackage[stylemods=bookindex,abbreviations]{glossaries-extra} % index style
%
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{booktabs}
% \usepackage{style/rest-api}
\usepackage{style/lst}
\usepackage{verbatim}
\usepackage{enumitem}
\usepackage{url}
\usepackage[authoryear]{natbib}
% \usepackage{pxfonts}
\usepackage{fourier}
%\usepackage{libertine}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage[bf, font={footnotesize}, margin=0.5cm]{caption}
\usepackage[compact, medium, explicit]{titlesec}
\usepackage{afterpage}
\newcommand\blankpage{%
\null
\thispagestyle{empty}%
\addtocounter{page}{-1}%
\newpage}
\usepackage{xhfill}
\titleformat{\chapter}[block]
{\filcenter{\scshape}\Huge}
{\xrfill[0.4ex]{1pt}\ \thechapter.}
{0.3em}
{\textsc{#1}\ \xrfill[0.4ex]{1pt}}
%\titlespacing{\section}{}{0cm}{0cm}
%\titlespacing{\subsection}{}{0cm}{0cm}
%\titlespacing{\subsubsection}{}{0cm}{0cm}
\bibpunct{(}{)}{,}{a}{}{,}
\setlist{noitemsep, topsep=0pt}
% \setlist[1]{labelindent=\parindent} % < Usually a good idea
\setlist[itemize]{label={---}, noitemsep, topsep=0pt}
% the following code puts a line break after a description label even if label is shorter than leftmargin
\renewcommand*{\descriptionlabel}[1]{\hspace\labelsep
\parbox{\linewidth}{#1}}
% \parbox{\linewidth}{\emph{#1}}}
\newlist{labelledlist}{description}{2}
\setlist[labelledlist]{style=nextline, leftmargin=2em, before=\renewcommand*{\descriptionlabel}[1]{\hspace\labelsep}}
\usepackage{multirow}
\usepackage{epigraph} % quotations (at start of chapter)
\usepackage{csquotes}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,fit,positioning,shapes}
\setcounter{tocdepth}{2}
\usepackage{geometry}
\geometry{
b5paper,
total={176mm,250mm},
tmargin=2.6cm,
bmargin=2.3cm,
outer=2.4cm,
inner=2.9cm,
headsep=1.2cm,
footnotesep=0.9cm
}
\usepackage[hang,flushmargin]{footmisc}
\raggedbottom
\renewcommand{\baselinestretch}{1.1}
\let\headheight=\baselineskip
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.5\baselineskip}
\usepackage[titles]{tocloft}
\setlength{\cftbeforechapskip}{3pt}
\interfootnotelinepenalty=10000 %% Completely prevent breaking of footnotes
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% csentered verbatim command
\usepackage{varwidth}
\newenvironment{centerverbatim}{%
\par
\centering
\varwidth{\linewidth}%
\verbatim
}{%
\endverbatim
\endvarwidth
\par
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% make first use \emph
% see: https://tex.stackexchange.com/questions/449104/how-to-style-first-acronym-and-first-glossary-appearance
\newcommand{\firstuseformat}[1]{\emph{#1}}
%
\renewcommand{\glslinkpresetkeys}{% requires v1.26+
\ifglsused{\glslabel}%
{\letcs\glstextformat{@firstofone}}%
{\let\glstextformat\firstuseformat}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% make only the first mention of a term in a chapter hyperlinked
% see: https://tex.stackexchange.com/questions/404051/glossaries-hyperlink-only-at-the-first-occurrence-in-every-chapter
\GlsXtrEnableLinkCounting[section]{general,acronym,abbreviation}
%
% disable hyperlink if link count is greater than 1:
\renewcommand*{\glslinkpresetkeys}{%
\ifnum\GlsXtrLinkCounterValue{\glslabel}>1
\setkeys{glslink}{hyper=false}%
\fi
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bibliographystyle{apalike}
\setabbreviationstyle{short-em-nolong} % abbreviation / acronym should be just short form and emphasis = short-em-nolong
\input{glossary.tex}
\input{acronyms.tex}
%
\newcommand\gloss[1]{\gls{#1}} %singular
\newcommand\glossupper[1]{\Gls{#1}} %singular uppercase
\newcommand\glossplural[1]{\glspl{#1}} % plural
\newcommand\glossupperplural[1]{\Glspl{#1}} % plural uppercase
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% make condition to render text based on it
%%% following example here: https://tex.stackexchange.com/questions/16711/minimal-option-for-cv/21642#21642
\newif\ifdraft
%\drafttrue % Uncomment to compile whole draft document / comment to compile only finished sections.
\ifdraft
\else
\fi
\newif\iftodo
% \todotrue % Uncomment to compile whole draft document / comment to compile only finished sections.
\iftodo
\else
\fi
%%%
%
% make page number a link to jump to toc only in draft mode
\ifdraft
\renewcommand\pagemark{{%
\usekomafont{pagenumber} \hyperref[sec:toc]{\thepage}
}}
\fi
% Statuses only shown in draft mode
\newcommand\wip[1]{
\iftodo \todo[inline,size=\Large]{work in progress: #1}\fi }
\newcommand\orange[1]{
\iftodo \todo[inline,size=\Large]{work in progress: #1}\fi}
\newcommand\green[1]{
\iftodo \todo[inline,size=\Large,backgroundcolor=green]{complete }\fi}
\newcommand\yellow[1]{
\iftodo \todo[inline,size=\Large,backgroundcolor=yellow]{incomplete: #1}\fi}
\newcommand\red[1]{
\iftodo \todo[inline,size=\Large,backgroundcolor=red]{incomplete}\fi}
% \newcommand\red[1]{
% \todo[inline,size=\Large,backgroundcolor=red]{incomplete}}
%
% statuses in section names
% for error explanation see: https://tex.stackexchange.com/questions/64298/error-with-xcolor-package
\colorlet{GREEN}{green}
\colorlet{ORANGE}{orange}
\colorlet{RED}{red}
% none of these work
% \ifdraft
% \usepackage{bbding}
% \usepackage{pifont}
% \newcommand{\cmark}{\ding{51}}%
% \newcommand{\xmark}{\ding{55}}%
% \usepackage{unicode-math}
% \newcommand{\cmark}{\setmainfont{Linux Libertine O}\symbol{"2714}\par}
% \newcommand{\xmark}{\setmainfont{Linux Libertine O}\symbol{"2718}\par}
% \usepackage{fontawesome}
% \def\cmark{\FA\symbol{"F00C}}
% \def\xmark{\FA\symbol{"F00D}}
% \fi
% \newcommand{\cmark}{${\checkmark}$}
% \newcommand{\xmark}{${\times}$}%'
\newcommand{\cmark}{***}
\newcommand{\xmark}{xxx}
\newcommand\statusgreen{\ifdraft \textcolor{green}{\cmark}\fi}
\newcommand\statusyellow{\ifdraft \textcolor{green}{?}\fi}
\newcommand\statusorange{\ifdraft \textcolor{orange}{WIP}\fi}
\newcommand\statusred{\ifdraft \textcolor{red}{\xmark}\fi}
% \newcommand\statusred{ \textcolor{red}{\xmark}}
\newcommand\statuspriority{\ifdraft \textcolor{blue}{PRIORITY}\fi}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\PO{\mathit{PO}}
\newcommand\Keys{\mathcal{K}}
\newcommand\nil{\varnothing}
% \newcommand\swip[1]{\url[SWIP-#1]{https://github.com/ethersphere/SWIPs/blob/master/SWIPs/swip-#1.md}}
\newcommand\defeq{\overset{\textrm{\tiny def}}{=}}
\providecommand{\xor}{\veebar}
\newcommand{\idx}[1]{\texttt{[}\/#1\/\texttt{]}}
\DeclareMathOperator{\concat}{\operatorname{\oplus}}
\DeclareMathOperator{\Concat}{\operatornamewithlimits{\bigoplus}}
\DeclareMathOperator{\rangedel}{:}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% new math environments
\usepackage{thmtools}
\makeatletter
\def\ll@definition{%
\protect\numberline{\csname the\thmt@envname\endcsname}%
\ifx\@empty\thmt@shortoptarg
\thmt@thmname
\else
\thmt@shortoptarg
\fi}
\def\l@thmt@definition{}
\makeatother
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,headfont=\normalfont\bfseries,notefont=\mdseries, notebraces={}{},bodyfont=\normalfont,postheadspace=1em]{theorem}
\declaretheorem[style=theorem]{definition}
\declaretheorem[style=theorem]{theorem}
%\theoremstyle{definition}
%\newtheorem{definition}{Definition}%[section]
%%
% \newtheorem{theorem}{Theorem}[section]
% \newtheorem{lemma}{Lemma}[section]
% \newtheorem{corollary}{Corollary}[section]
\renewcommand{\listtheoremname}{List of definitions}
%
\makeatletter % legacy /sc command support
%\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
%\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
%\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
%\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
%\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
%\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}
\makeatother
\clubpenalty=10000
\widowpenalty=10000
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} % clear all header fields
\fancyhead[RO]{\thepage}
\fancyhead[LE]{\thepage}
\fancyfoot{}
\usepackage{hyperref}
\usepackage[
type={CC},
modifier={by-nc-sa},
version={3.0},
]{doclicense}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the book of swarm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeglossaries
\title{\Huge\sc the book of swarm\\\vskip10pt
\large storage and communication infrastructure\\\vskip-3pt for a self-sovereign digital society\\\vskip10pt}
\author{\sc viktor tr{\'o}n}
\date{}
%\date{v2.0 pre-release 1.4 - worked on \today}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\frontmatter
\maketitle
% instructions for versioning & deployment
% they are hidden automatically if draft is FALSE when compiling
\ifdraft
Instructions for compiling and distributing.
These are hidden if conditional text is not shown (when publishing a version).
\begin{enumerate}[noitemsep]
\item any version being worked on should be named "Version vX - worked on";
\item when publishing, "worked on" should be removed;
\item drafttrue line should be commented out removing conditional text upon compilation;
\item PDF should be generated, saved and pushed to Github repo \\ (https://github.com/ethersphere/publish-bookofswarm/tree/master/pdfs);
\item verify that last commit was autodeployed to Swarm \\ (https://swarm-gateways.net/bzz:/latest.bookofswarm.eth/the-book-of-swarm-viktor-tron.pdf);
\item PDF commit in Github repo should be named with version number;
\item version number in Latex should be bumped up and "worked on" note added: "Version v(X+1) - worked on";
\item Goto 1.
\end{enumerate}
\fi
%
\newpage
\pagestyle{empty}
\ \\\vskip14cm
the book of swarm\\
2024 by viktor trón\\\hrule
{
\footnotesize\raggedright\
\doclicenseThis
}
\texttt{ISBN 978-615-01-9983-2}
\newpage
\input{front/00-quote.tex}
\pagestyle{empty}\ \newpage
\tableofcontents
\listoffigures
% \listoftables % remove if less than 5 tables?
\input{front/01-prolegomena.tex}
\label{sec:toc}
\input{front/02-acknowledgements.tex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mainmatter
\part{Prelude}
\label{part:preface}
\pagestyle{fancy}
\fancyhead{} % clear all header fields
\fancyhead[LO]{\leftmark}
\fancyhead[RO]{\thepage}
\fancyhead[LE]{\thepage}
\fancyhead[RE]{\leftmark} % \textsc{the book of Swarm}
\fancyfoot{}
\input{intro.tex}
\part{Design and architecture} \label{part:designarchitecture}
\input{parts.tex}
% \part{Specifications}
% \label{part:specifications}
% \input{specs.tex}
%%%%%%%%%%%%%%%%%%%%%%
\phantomsection
\addcontentsline{toc}{chapter}{Bibliography}
\bibliography{refs.bib}
%%%%%%%%%%%%%%%%%%%%%
% \appendix
% \part{Appendix}\label{part:appendix}
% \input{10-appendix.tex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\backmatter
\part{Indexes \statusorange}
% main glossary with explanations
% NOTE: cannot find a non-hierarchical style that works well
% maybe we don't need hierarchy in its current form (defined by parent)
% although it looks good in the Index I suppose
% \glossarystyle{listdotted} % listdotted is non-hierarchical
\newglossarystyle{long-fixed}{%
\setglossarystyle{long}%
\renewenvironment{theglossary}%
{\begin{longtable}[l]{@{}p{\dimexpr 3cm-\tabcolsep}p{0.8\hsize}}}% <-- change the value here
{\end{longtable}}%
}
\printglossary[type=main]
\label{sec:glossary}
% index
\printglossary[nonumberlist=false, style=bookindex, title={Index}]
\label{sec:index}
% acronyms
\printglossary[type=\acronymtype,title={Acronyms and abbreviations},style=long-fixed]
\end{document}