author | Chengsong |
Thu, 23 Jun 2022 16:59:58 +0100 | |
changeset 546 | 6e97f4aa7cd0 |
parent 201 | 2585e2a7a7ab |
permissions | -rw-r--r-- |
200
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
\usepackage{listings} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
\usepackage{etoolbox} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
\setmonofont[Scale=.95]{Consolas} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
\newfontfamily{\consolas}{Consolas} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
|
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
\definecolor{codered}{rgb}{0.6,0,0} % for strings |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
\definecolor{codegreen}{rgb}{0.25,0.5,0.35} % comments |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
\definecolor{codepurple}{rgb}{0.5,0,0.35} % keywords |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
\definecolor{codedocblue}{rgb}{0.25,0.35,0.75} % doc |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
\definecolor{codeblue}{rgb}{0.25,0.35,0.75} % types |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
|
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
\BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
\AfterEndEnvironment{lstlisting}{\end{minipage}\par} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
|
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
\lstdefinelanguage{Scala}{ |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
morekeywords={abstract,case,catch,class,def,% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
do,else,extends,false,final,finally,% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
for,if,implicit,import,match,mixin,% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
new,null,object,override,package,% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
private,protected,requires,return,sealed,% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
super,this,throw,trait,true,try,% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
type,val,var,while,with,yield,write,read},% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
otherkeywords={=>,<-,<\%,<:,>:,\#},% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
sensitive=true,% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
%directives={Int,Char,Rexp,String,Boolean,BigInt,Unit,List,Set},% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
%moredelim=*[directive]:,% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
morecomment=[l]{//},% |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
morecomment=[n]{/*}{*/}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
morestring=[s]{"""}{"""}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
morestring=[b]", |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
morestring=[b]', |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
}[keywords,comments,strings] |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
|
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
\lstdefinelanguage{While}{ |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
morekeywords={if,then,else,while,do,true,false,write,upto,read,for,skip}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
morecomment=[l]{//}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
morecomment=[n]{/*}{*/}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
morestring=[b]", |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
otherkeywords={=,!=,:=,<,>,\%;*,/}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
}[keywords,comments,strings] |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
|
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
\lstdefinestyle{mystyle} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
{basicstyle=\ttfamily, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
keywordstyle=\color{codepurple}\bfseries, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
stringstyle=\color{codegreen}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
commentstyle=\color{codegreen}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
morecomment=[s][\color{codedocblue}]{/**}{*/}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
numbers=left, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
numberstyle=\tiny\color{black}, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
stepnumber=1, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
numbersep=10pt, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
tabsize=2, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
showspaces=false, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
54 |
showstringspaces=false, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
55 |
xleftmargin=8mm, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
56 |
emphstyle=\color{codeblue}\bfseries, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
57 |
keepspaces |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
58 |
} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
|
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
\lstset{language=Scala, |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
style=mystyle} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
|
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
63 |
|
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
64 |
\newcommand{\code}[1]{{\lstinline{#1}}} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
65 |
\newcommand{\pcode}[1]{\mbox{\lstset{language={},keywordstyle=\color{black}}\lstinline!#1!}} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
\newcommand{\scode}[1]{\mbox{\lstset{language={},basicstyle=\ttfamily\color{codegreen}}\lstinline!#1!}} |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
\makeatother |
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
68 |
|
10c096d59218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
\lstset{escapeinside={(*@}{@*)}} |
201
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
70 |
|
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
71 |
|
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
72 |
|
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
73 |
\newcommand\grid[1]{% |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
74 |
\begin{tikzpicture}[baseline=(char.base)] |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
75 |
\path[use as bounding box] |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
76 |
(0,0) rectangle (1em,1em); |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
77 |
\draw[red!50, fill=red!20] |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
78 |
(0,0) rectangle (1em,1em); |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
79 |
\node[inner sep=1pt,anchor=base west] |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
80 |
(char) at (0em,\gridraiseamount) {#1}; |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
81 |
\end{tikzpicture}} |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
82 |
\newcommand\gridraiseamount{0.12em} |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
83 |
|
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
84 |
\makeatletter |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
85 |
\newcommand\Grid[1]{% |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
86 |
\@tfor\z:=#1\do{\grid{\z}}} |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
87 |
\makeatother |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
88 |
|
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
89 |
\newcommand\Vspace[1][.3em]{% |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
90 |
\mbox{\kern.06em\vrule height.3ex}% |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
91 |
\vbox{\hrule width#1}% |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
92 |
\hbox{\vrule height.3ex}} |
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
93 |
|
2585e2a7a7ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
200
diff
changeset
|
94 |
\def\VS{\Vspace[0.6em]} |