-
Notifications
You must be signed in to change notification settings - Fork 41
/
preamble.tex
312 lines (274 loc) · 10.7 KB
/
preamble.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
% This suppresses warnings about most overfull hboxes.
% Clearly it would be better to fix them, but if we anyway want to
% change the layout that can wait
\hfuzz=50pt
\usepackage{fancyhdr}
% The general view was that parskip without indent was most readable, so use it
\usepackage{parskip}
% Uses some packages:
\usepackage{amsmath}
\allowdisplaybreaks
% For non-floating figures:
\usepackage{float}
% Prefer pdf for pdf
% https://tex.stackexchange.com/questions/1072/which-graphics-formats-can-be-included-in-documents-processed-by-latex-or-pdflat
\usepackage{ifpdf}
\ifpdf
\makeatletter
\let\orig@Gin@extensions\Gin@extensions
\def\Gin@extensions{.pdf,\orig@Gin@extensions} %prepend .pdf before .png
\makeatother
\fi
% Longer section numbers in toc
\ifpdf
\usepackage{tocloft}
\setlength{\cftsecnumwidth}{3em}
\fi
% Need more text:
\usepackage[margin=1in]{geometry}
%\usepackage{t1enc}
\usepackage{graphicx}
\graphicspath{{media/}{../media/}} % so that chapter files can also find the images
% Don't use subfig.sty due to this LaTeXML issue (fixed on master 2020-06-27):
% - https://github.com/brucemiller/LaTeXML/issues/1292 (marked as fixed as of commit 9f5c893b)
% Leaving commented-out code as a hint to anyone who considers using subfig.
%\usepackage{subfig}
\RequirePackage[margin=1em, labelfont=bf,
singlelinecheck=true, font=sl,
compatibility=false% Unsupported feature that suppresses the incompatibility checks...
]{caption}
\captionsetup[figure]{position=bottom}
\captionsetup[table]{position=top}
\ifpdf
\DeclareCaptionOption{parskip}[]{}% Unclear workaround for conflict between captions, subfig, and parskip.
\else
% The \DeclareCaptionOption leaves a ']' behind in the LaTeXML build, see:
% - https://github.com/brucemiller/LaTeXML/issues/1352
% Since we are currently not using subfig, we work around this issue by simply removing the problematic
% \DeclareCaptionOption call.
\fi
\usepackage{verbatim}
% The fixltx2e that was used for textsubscript is no longer needed for pdf, but is needed by latexml
\ifpdf
\else
\usepackage{fixltx2e} %for textsubscript
\fi
% Allow lot of figures on page:
\renewcommand{\textfraction}{0}
\renewcommand{\topfraction}{1}
\renewcommand{\bottomfraction}{1}
% Some problem with raggedright for latexml
\ifpdf
\renewcommand{\newline}{\hspace*{\fill}\linebreak}
\else
\renewcommand{\newline}{\hspace*{\fill}\raggedright\linebreak}
\fi
\setcounter{totalnumber}{1000}
\raggedbottom
\usepackage{hyperref}
% The bookmarks are used as table-of-contents in Acrobat
% The default (magenta for urls and red for internal links) isn't nice
\hypersetup{bookmarksnumbered=true, hidelinks, urlcolor=blue, linkcolor=blue}
\usepackage{multirow} % for multirow entries in tables
% When producing PDF, the ttfamily looks better in size \small, but with LaTeXML this becomes too small,
% and the size is applied deep down on the HTML elements, making it hard to adjust using CSS.
% Thus, the problem has to be addressed already when a listings language's 'basicstyle' is defined.
% This needs to go before mlsshared.sty is loaded.
\ifpdf
\let\smallifpdf\small
\else
\let\smallifpdf\normalsize
\fi
\usepackage{mlsshared}
% Settings in addition to those in mlsshared.sty.
\lstset{%
xleftmargin=\fboxsep,
xrightmargin=-\fboxsep,
}
\def\S0#1#2{\hypertarget{#2}\chapter{#1}\label{#2}}
\def\S1#1#2{\hypertarget{#2}\section{#1}\label{#2}}
\def\S2#1#2{\hypertarget{#2}\subsection{#1}\label{#2}}
\def\S3#1#2{\hypertarget{#2}\subsubsection{#1}\label{#2}}
\def\S4#1#2{\hypertarget{#2}\paragraph{#1}\label{#2}}
\def\S5#1#2{\hypertarget{#2}\subparagraph{#1}\label{#2}}
% Simple numbering of lists, should preferably use \usepackage{enumitem}
% https://stackoverflow.com/questions/2007627/latex-how-can-i-create-nested-lists-which-look-this-1-1-1-1-1-1-1-2-1-2
%\usepackage{enumitem} % Package not available for continuous integration builds.
\renewcommand{\labelenumi}{\arabic{enumi}.}
\renewcommand{\labelenumii}{\labelenumi\arabic{enumii}.}
\renewcommand{\labelenumiii}{\labelenumii\arabic{enumiii}.}
\renewcommand{\labelenumiv}{\labelenumiii\arabic{enumiv}.}
% Non-normative content without paragraph breaks at beginning and end.
% In most cases, one should use the 'nonnormative' environment instead.
\newenvironment{nonnormative*}[0]{%
{[}\itshape\ignorespaces
}{%
\unskip\upshape{]}%
}
% Non-normative content with paragraph breaks at beginning and end.
\newenvironment{nonnormative}[0]{%
\par\begin{nonnormative*}%
}{%
\end{nonnormative*}\par%
}
% Example environment, as a special case of non-normative content.
\newenvironment{example*}[1][\unskip]{%
\begin{nonnormative*}Example #1:
}{%
\end{nonnormative*}
}
\newenvironment{example}[1][\unskip]{%
\begin{nonnormative}Example #1:
}{%
\end{nonnormative}
}
% Like \emph, but marking this as the place where new terminology is introduced.
% In the future, we can change this to something that will automatically add this
% to an index/glossary.
\newcommand{\firstuse}[1]{\emph{#1}}
% Formatting of table headings.
\newcommand{\tablehead}[1]{\textit{#1}}
\newcommand{\glossaryitem}[1]{\textbf{#1}}
\newcommand{\bibitemtitle}[1]{\emph{#1}}
\usepackage[nameinlink,noabbrev]{cleveref}
\def\autoref#1{\errmessage{You are not supposed to use \autoref; use \cref or \Cref instead.}}
% Environment for definitions.
\usepackage{amsthm}
\newtheoremstyle{mlsdefinition}
{\topsep} % ABOVESPACE
{\topsep} % BELOWSPACE
{} % BODYFONT
{} % INDENT (empty value is the same as 0pt)
{\bfseries} % HEADFONT
{.} % HEADPUNCT
{.75em} % HEADSPACE
{#1~#2. \firstuse{#3}} % CUSTOM-HEAD-SPEC
\theoremstyle{mlsdefinition}
% In order to show where the definition ends, we put a \qed at the end. This can't be done using \newtheoremstyle,
% so instead we make the 'definition' environment a wrapper around the amsthm-base environment.
\makeatletter
\newtheorem{definition@inner}{Definition}[chapter]
\crefname{definition@inner}{definition}{definitions}
\Crefname{definition@inner}{Definition}{Definitions}
\newenvironment{definition}{\begin{definition@inner}}{\qed\end{definition@inner}}
\makeatother
\setcounter{secnumdepth}{5}
% Note: Toc changed for appendex
\setcounter{tocdepth}{1}
% Warning: The way of adding \label inside the theoremstyle below is currently working at LaTeXML version 0.8.4,
% but was broken for a while on their master branch, see
% - https://github.com/brucemiller/LaTeXML/issues/1351
% TODO: Remove this comment once it has been verified that this is working once we have upgraded from 0.8.4.
\newtheoremstyle{modelicadefinition}
{\topsep} % ABOVESPACE
{\topsep} % BELOWSPACE
{} % BODYFONT
{} % INDENT (empty value is the same as 0pt)
{\bfseries} % HEADFONT
{\\} % HEADPUNCT
{.75em} % HEADSPACE
{#1~#2 \texttt{#3}\label{modelica:#3}} % CUSTOM-HEAD-SPEC {#1~#2. \texttt{#3}}
\theoremstyle{modelicadefinition}
\newtheorem{operatordefinition}{Operator}[chapter]
\crefname{operatordefinition}{operator}{operators}
\Crefname{operatordefinition}{Operator}{Operators}
\newtheorem{functiondefinition}{Function}[chapter]
\crefname{functiondefinition}{function}{functions}
\Crefname{functiondefinition}{Function}{Functions}
\newtheorem{annotationdefinition}{Annotation}[chapter]
\crefname{annotationdefinition}{annotation}{annotations}
\Crefname{annotationdefinition}{Annotation}{Annotations}
\newtheoremstyle{modelicadefinition*}
{\topsep} % ABOVESPACE
{\topsep} % BELOWSPACE
{} % BODYFONT
{} % INDENT (empty value is the same as 0pt)
{\bfseries} % HEADFONT
{\\} % HEADPUNCT
{.75em} % HEADSPACE
{#1~#2 \texttt{#3}} % CUSTOM-HEAD-SPEC {#1~#2. \texttt{#3}}
\theoremstyle{modelicadefinition*}
\newtheorem{operatordefinition*}[operatordefinition]{Operator} % Note: Not using \theoremstyle*, only difference is not adding \label.
\crefname{operatordefinition*}{operator}{operators}
\Crefname{operatordefinition*}{Operator}{Operators}
\newtheorem{functiondefinition*}[functiondefinition]{Function}
\crefname{functiondefinition*}{function}{functions}
\Crefname{functiondefinition*}{Function}{Functions}
\newtheorem{annotationdefinition*}{Annotation}[chapter]
\crefname{annotationdefinition*}{annotation}{annotations}
\Crefname{annotationdefinition*}{Annotation}{Annotations}
\lstdefinelanguage[synopsis]{modelica}[]{modelica}{% Language for use inside the 'synopsis' environment.
basicstyle=\upshape\ttfamily, % Same size as \lstinline
frame=none,
aboveskip=0pt,
xleftmargin=2em
}
\lstdefinelanguage[synopsis]{grammar}[]{grammar}{% Language for use inside the 'synopsis[grammar]' environment.
basicstyle=\upshape\ttfamily, % Same size as \lstinline
frame=none,
aboveskip=0pt,
xleftmargin=2em
}
\lstdefinelanguage[synopsis]{C}[]{C}{% Language for use inside the 'synopsis[C]' environment.
basicstyle=\upshape\ttfamily, % Same size as \lstinline
frame=none,
aboveskip=0pt,
xleftmargin=2em
}
\newenvironment{synopsis}[1][modelica]{%
\lstset{language=[synopsis]#1}%
~\vspace{-\parskip}\par
}{%
}
\newenvironment{semantics}{%
\list{}{%
\setlength{\leftmargin}{1.5em}%
\setlength{\rightmargin}{1.5em}%
}\item[]%
}{%
\endlist
}
% Change all \cref and \Cref variants below chapter to use "section"
\crefname{subsection}{section}{sections}
\Crefname{subsection}{Section}{Sections}
\crefname{subsubsection}{section}{sections}
\Crefname{subsubsection}{Section}{Sections}
\crefname{paragraph}{section}{sections}
\Crefname{paragraph}{Section}{Sections}
\crefname{subparagraph}{section}{sections}
\Crefname{subparagraph}{Section}{Sections}
% We can't use cleveref.sty the way we want for equations until this LaTeXML has been fixed:
% - https://github.com/brucemiller/LaTeXML/issues/1306 -- fixed on 'master'
% In the meantime, we use \eqref to achieve the same result.
%\crefname{equation}{}{}
%\Crefname{equation}{}{}
\ifpdf
\newcommand{\crefnameref}[1]{\cref{#1}~\emph{\nameref*{#1}}}
\newcommand{\Crefnameref}[1]{\Cref{#1}~\emph{\nameref*{#1}}}
\else
% Don't use \nameref* while waiting for LaTeXML issue to get fixed:
% - https://github.com/brucemiller/LaTeXML/issues/1348
% At the same time, there are also problems with the normal \nameref:
% - https://github.com/brucemiller/LaTeXML/issues/1350
% Since the excessive output of \nameref only replaces the need for \cref for some labels,
% we can't rely on just \nameref, meaning we can't use it at all.
\let\crefnameref\cref
\let\Crefnameref\Cref
\fi
% Make all description lists break the line after each key.
% henrikt-ma: Commenting out use of the enumitem package, see above.
%\setlist[description]{
% style=nextline,
% labelwidth=0pt,
% leftmargin=15pt,
% itemindent=\dimexpr-5pt-\labelsep\relax,
%}
\newenvironment{contributors}{%
\list{}{%
\setlength{\leftmargin}{1.5em}%
\setlength{\itemsep}{-\parskip}%
\addtolength{\itemsep}{2pt}%
}%
}{%
\endlist
}