forked from modelica/ModelicaSpecification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preamble.tex
231 lines (217 loc) · 10 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
% 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
% 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
\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 default (magenta for urls and red for internal links) isn't nice
\hypersetup{colorlinks=true, urlcolor=blue, linkcolor=blue}
% Using longtable to have tables split across pages
% Most starting with \hline \endhead to avoid underfull vbox and not have first part duplicated on new pages
%
% But in some cases there are actual headings that are copied to next page.
% Note that this can often lead to overfull vbox
% See https://tex.stackexchange.com/questions/71096/underfull-vbox-in-each-longtable-can-it-be-fixed-or-must-it-be-ignored
\usepackage{longtable}
\usepackage{multirow} % for multirow entries in tables
\usepackage{listings}
\usepackage{color}
\usepackage[table]{xcolor}
%\def\doublelabel#1{\label{#1}\hypertarget{#1}{}}
\def\doublelabel#1{\label{#1}}
\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
\renewcommand{\labelenumi}{\arabic{enumi}.}
\renewcommand{\labelenumii}{\labelenumi\arabic{enumii}.}
\renewcommand{\labelenumiii}{\labelenumii\arabic{enumiii}.}
\renewcommand{\labelenumiv}{\labelenumiii\arabic{enumiv}.}
\lstset{
basicstyle=\color{blue}\ttfamily,
keywordstyle=\color{red}\ttfamily\bfseries,
commentstyle=\color{green}\sffamily,
}
\setcounter{secnumdepth}{5}
% Note: Toc changed for appendex
\setcounter{tocdepth}{1}
\definecolor{keywordcolor1}{rgb}{0,0,.4}
\definecolor{keywordcolor2}{rgb}{.90,0,0}
% See https://github.com/modelica-tools/listings-modelica/blob/master/listings-modelica.cfg
% Note: Changed comment color from green to [rgb]{0,0.4,0} - since the other variant was too distracting
% And added pure,impure,stream as keywords
% Remove cross as red
% Note: have basicstyle=\footnotesize\ttfamily in all languages,
% except the dialect [short]modelica - which is used for inline listings.
% Apart from that change that dialect should be identical to modelica
\lstdefinelanguage{modelica}{%
alsoletter={...},%
basicstyle=\footnotesize\ttfamily, % size of fonts used for the code
%otherkeywords={-, =, +, [, ], (, ), \{, \}, :, *, !},%
morekeywords=[1]{},% blue Keywords
morekeywords=[2]{% blue + bold keywords
annotation,assert,block,break,class,connector,constant,constrainedby,discrete,%
each,encapsulated,else,elseif,elsewhen,end,exit,expandable,extends,external,final,flow,for,%
function,if,in,inner,initial,input,import,loop,model,nondiscrete,operator,outer,%
output,package,parameter,partial,record,redeclare,replaceable,return,%
size,stream,terminate,then,type,when,while,algorithm,equation,%
protected,public,and,false,not,or,true,pure,impure,transition,initialState},%
% Note: initial is in both variants - depending on context, use first variant
morekeywords=[3]{% red keywords
abs,acos,asin,atan,atan2,connect,cos,cosh,der,edge,exp,%
noEvent,pre,reinit,sample,sign,sin,sinh,tan,tanh,terminal,%
start,Real,Integer,Boolean,String,homotopy,spatialDistribution,cardinality},%
comment=[l]{//}, % comment lines
morecomment=[s]{/*}{*/}, % comment blocs
morestring=[b]{'}, %
morestring=[b]{"},
}[keywords,comments,strings]
\lstdefinelanguage[short]{modelica}{%
alsoletter={...},%
basicstyle=\ttfamily, % size of fonts used for the code
%otherkeywords={-, =, +, [, ], (, ), \{, \}, :, *, !},%
morekeywords=[1]{},% blue Keywords
morekeywords=[2]{% blue + bold keywords
annotation,assert,block,break,class,connector,constant,constrainedby,discrete,%
each,encapsulated,else,elseif,elsewhen,end,exit,expandable,extends,external,final,flow,for,%
function,if,in,inner,initial,input,import,loop,model,nondiscrete,operator,outer,%
output,package,parameter,partial,record,redeclare,replaceable,return,%
size,stream,terminate,then,type,when,while,algorithm,equation,%
protected,public,and,false,not,or,true,pure,impure,transition,initialState},%
% Note: initial is in both variants - depending on context, use first variant
morekeywords=[3]{% red keywords
abs,acos,asin,atan,atan2,connect,cos,cosh,der,edge,exp,%
noEvent,pre,reinit,sample,sign,sin,sinh,tan,tanh,terminal,%
start,Real,Integer,Boolean,String,homotopy,spatialDistribution,cardinality},%
comment=[l]{//}, % comment lines
morecomment=[s]{/*}{*/}, % comment blocs
morestring=[b]{'}, %
morestring=[b]{"},
}[keywords,comments,strings]
% Note: within only a keyword in grammar
\lstdefinelanguage{grammar}{
alsoletter={...},
alsodigit={-},
basicstyle=\footnotesize\ttfamily, % size of fonts used for the code
breaklines=true,
breakatwhitespace=true,
morekeywords=[2]{letters,
annotation,assert,block,break,class,connector,constant,constrainedby,discrete,%
each,encapsulated,else,elseif,elsewhen,end,exit,expandable,extends,external,final,flow,for,%
function,if,in,inner,initial,input,import,loop,model,nondiscrete,operator,outer,%
output,package,parameter,partial,record,redeclare,replaceable,return,%
size,stream,terminate,then,type,when,while,algorithm,equation,%
protected,public,and,false,not,or,true,pure,impure,stream,transition,initialState,%
within},
morekeywords=[1]{|}
}[keywords,comments,strings]
\lstset{ %
backgroundcolor=\color{white}, % choose the background color
%basicstyle=\footnotesize\ttfamily, % size of fonts used for the code
breaklines=true, % automatic line breaking only at whitespace
captionpos=b, % sets the caption-position to bottom
commentstyle=\color[rgb]{0,0.4,0}\sffamily, % comment style
keywordstyle=\color{blue}\ttfamily\bfseries, % keyword style
keywordstyle=[1]\color{keywordcolor1},
keywordstyle=[2]\color{keywordcolor1}\bfseries,
keywordstyle=[3]\color{keywordcolor2},
stringstyle=\color{black}, % string literal style
language=[short]modelica, % Set your language (you can change the language for each code-block optionally)
showstringspaces=false,
frame=lrtb, %
xleftmargin=\fboxsep, %
xrightmargin=-\fboxsep, %
}
% Duplicate this definition here to avoid issue - and name it "fortran77" to avoid problem in LatexML
\lstdefinelanguage{fortran77}%
{basicstyle=\footnotesize\ttfamily, % size of fonts used for the code
morekeywords={ASSIGN,BACKSPACE,CALL,CHARACTER,%
CLOSE,COMMON,COMPLEX,CONTINUE,DATA,DIMENSION,DO,DOUBLE,%
ELSE,ELSEIF,END,ENDIF,ENDDO,ENTRY,EQUIVALENCE,EXTERNAL,%
FILE,FORMAT,FUNCTION,GO,TO,GOTO,IF,IMPLICIT,%
INQUIRE,INTEGER,INTRINSIC,LOGICAL,%
OPEN,PARAMETER,PAUSE,PRECISION,PRINT,PROGRAM,READ,REAL,%
RETURN,REWIND,STOP,SUBROUTINE,THEN,%
WRITE,SAVE},%
morekeywords=[2]{ACCESS,BLANK,BLOCK,DIRECT,EOF,ERR,EXIST,%
FMT,FORM,FORMATTED,IOSTAT,NAMED,NEXTREC,NUMBER,OPENED,%
REC,RECL,SEQUENTIAL,STATUS,TYPE,UNFORMATTED,UNIT},%
morekeywords=[3]{INT,DBLE,CMPLX,ICHAR,CHAR,AINT,ANINT,% left out real
NINT,ABS,MOD,SIGN,DIM,DPROD,MAX,MIN,AIMAG,CONJG,SQRT,EXP,LOG,%
LOG10,SIN,COS,TAN,ASIN,ACOS,ATAN,ATAN2,SINH,COSH,TANH,LGE,LLE,LLT,%
LEN,INDEX},%
morekeywords=[4]{AND,EQ,EQV,FALSE,GE,GT,OR,LE,LT,NE,NEQV,NOT,TRUE},%
sensitive=f,%% not Fortran-77 standard, but allowed in Fortran-95 %%
morecomment=[f]*,%
morecomment=[f]C,%
morecomment=[f]c,%
morestring=[d]",%% not Fortran-77 standard, but allowed in Fortran-95 %%
morestring=[d]'%
}[keywords,comments,strings]%
\lstdefinelanguage{C}%
{basicstyle=\footnotesize\ttfamily, % size of fonts used for the code
morekeywords={auto,break,case,char,const,continue,default,do,double,%
else,enum,extern,float,for,goto,if,int,long,register,return,%
short,signed,sizeof,static,struct,switch,typedef,union,unsigned,%
void,volatile,while},%
sensitive,%
morecomment=[s]{/*}{*/},%
morecomment=[l]//,% nonstandard
morestring=[b]",%
morestring=[b]',%
moredelim=*[directive]\#,%
moredirectives={define,elif,else,endif,error,if,ifdef,ifndef,line,%
include,pragma,undef,warning}%
}[keywords,comments,strings,directives]%
% Note: \lstinline!...! used for inline Modelica using [short]modelica
\title{Modelica® - A Unified Object-Oriented Language for Systems
Modeling\\[2\baselineskip]Language
Specification\\[2\baselineskip]Version 3.5-dev}
\date{\today}
\author{Modelica Association}