author | Christian Urban <christian.urban@kcl.ac.uk> |
Tue, 19 Oct 2021 22:51:51 +0100 | |
changeset 846 | 3a535de22816 |
parent 820 | 7fd1f611c21d |
child 873 | a25da86f7c8c |
permissions | -rw-r--r-- |
218
8f3f8d82da8b
added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
\usepackage{listings} |
238
527fdb90fffe
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
237
diff
changeset
|
2 |
\usepackage{etoolbox} |
630 | 3 |
%\setmonofont[Scale=.95]{Consolas} |
4 |
%\newfontfamily{\consolas}{Consolas} |
|
5 |
||
6 |
\makeatletter |
|
7 |
\let\old@lstKV@SwitchCases\lstKV@SwitchCases |
|
8 |
\def\lstKV@SwitchCases#1#2#3{} |
|
9 |
\makeatother |
|
10 |
\usepackage{lstlinebgrd} |
|
11 |
\makeatletter |
|
12 |
\let\lstKV@SwitchCases\old@lstKV@SwitchCases |
|
13 |
||
14 |
\lst@Key{numbers}{none}{% |
|
15 |
\def\lst@PlaceNumber{\lst@linebgrd}% |
|
16 |
\lstKV@SwitchCases{#1}% |
|
17 |
{none:\\% |
|
18 |
left:\def\lst@PlaceNumber{\llap{\normalfont |
|
19 |
\lst@numberstyle{\thelstnumber}\kern\lst@numbersep}\lst@linebgrd}\\% |
|
20 |
right:\def\lst@PlaceNumber{\rlap{\normalfont |
|
21 |
\kern\linewidth \kern\lst@numbersep |
|
22 |
\lst@numberstyle{\thelstnumber}}\lst@linebgrd}% |
|
23 |
}{\PackageError{Listings}{Numbers #1 unknown}\@ehc}} |
|
24 |
\makeatother |
|
25 |
||
26 |
||
27 |
||
218
8f3f8d82da8b
added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
|
234
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
29 |
\definecolor{codered}{rgb}{0.6,0,0} % for strings |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
30 |
\definecolor{codegreen}{rgb}{0.25,0.5,0.35} % comments |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
31 |
\definecolor{codepurple}{rgb}{0.5,0,0.35} % keywords |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
32 |
\definecolor{codedocblue}{rgb}{0.25,0.35,0.75} % doc |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
33 |
\definecolor{codeblue}{rgb}{0.25,0.35,0.75} % types |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
34 |
|
238
527fdb90fffe
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
237
diff
changeset
|
35 |
\BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}} |
527fdb90fffe
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
237
diff
changeset
|
36 |
\AfterEndEnvironment{lstlisting}{\end{minipage}\par} |
218
8f3f8d82da8b
added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
|
234
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
38 |
\lstdefinelanguage{Scala}{ |
820 | 39 |
morekeywords={abstract,then,case,catch,class,def,% |
234
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
40 |
do,else,extends,false,final,finally,% |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
41 |
for,if,implicit,import,match,mixin,% |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
42 |
new,null,object,override,package,% |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
43 |
private,protected,requires,return,sealed,% |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
44 |
super,this,throw,trait,true,try,% |
588 | 45 |
type,val,var,while,with,yield,write,read,lazy},% |
591 | 46 |
literate={==>}{{\mbox{\color{codepurple}{\textbf{\texttt{==>}}}}}}2,% |
47 |
otherkeywords={=>,<-,<\%,<:,>:,\#},% |
|
234
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
48 |
sensitive=true,% |
235
bc460179148c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
234
diff
changeset
|
49 |
%directives={Int,Char,Rexp,String,Boolean,BigInt,Unit,List,Set},% |
bc460179148c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
234
diff
changeset
|
50 |
%moredelim=*[directive]:,% |
234
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
51 |
morecomment=[l]{//},% |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
52 |
morecomment=[n]{/*}{*/}, |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
242
diff
changeset
|
53 |
morestring=[s]{"""}{"""}, |
234
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
54 |
morestring=[b]", |
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
55 |
morestring=[b]', |
235
bc460179148c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
234
diff
changeset
|
56 |
}[keywords,comments,strings] |
234
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
57 |
|
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
58 |
\lstdefinelanguage{While}{ |
690 | 59 |
morekeywords={if,then,else,while,do,true,false,write,upto,read,for,skip,new}, |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
60 |
morecomment=[l]{//}, |
234
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
61 |
morecomment=[n]{/*}{*/}, |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
62 |
morestring=[b]", |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
63 |
otherkeywords={=,!=,:=,<,>,\%;*,/}, |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
64 |
}[keywords,comments,strings] |
234
bf7eecc9cefe
updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
230
diff
changeset
|
65 |
|
218
8f3f8d82da8b
added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
|
711 | 67 |
\lstdefinelanguage{JVMIS2}[]{JVMIS} |
68 |
{ |
|
712 | 69 |
morekeywords={if_icmpgt,if_icmpge,iconst_m1,if_icmple} |
647 | 70 |
}[keywords] |
71 |
||
680 | 72 |
\lstdefinelanguage{LLVMIR}{ |
819 | 73 |
otherkeywords={let,in,add,mul,KLet}, |
680 | 74 |
}[strings] |
607 | 75 |
|
237
370c0647a9bf
more material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
235
diff
changeset
|
76 |
\newcommand{\code}[1]{{\lstinline{#1}}} |
711 | 77 |
\newcommand{\instr}[1]{\mbox{\lstinline[language=JVMIS2]{#1}}} |
242
35104ee14f87
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
239
diff
changeset
|
78 |
\newcommand{\pcode}[1]{\mbox{\lstset{language={},keywordstyle=\color{black}}\lstinline!#1!}} |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
242
diff
changeset
|
79 |
\newcommand{\scode}[1]{\mbox{\lstset{language={},basicstyle=\ttfamily\color{codegreen}}\lstinline!#1!}} |
242
35104ee14f87
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
239
diff
changeset
|
80 |
\makeatother |
399
5c1fbb39c93e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
379
diff
changeset
|
81 |
|
427
546f2090ce12
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
399
diff
changeset
|
82 |
%%\lstset{escapeinside={(*@}{@*)}} |
546f2090ce12
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
399
diff
changeset
|
83 |
\lstset{escapeinside={/*@}{@*/}} |
480 | 84 |
|
85 |
%% stripy code |
|
86 |
\usepackage{lstlinebgrd} |
|
87 |
\definecolor{capri}{rgb}{0.0, 0.75, 1.0} |
|
490 | 88 |
|
89 |
||
90 |
\lstdefinestyle{mystyle} |
|
91 |
{basicstyle=\ttfamily, |
|
92 |
keywordstyle=\color{codepurple}\bfseries, |
|
93 |
stringstyle=\color{codegreen}, |
|
94 |
commentstyle=\color{codegreen}, |
|
95 |
morecomment=[s][\color{codedocblue}]{/**}{*/}, |
|
96 |
numbers=none, |
|
97 |
numberstyle=\tiny\color{black}, |
|
98 |
stepnumber=1, |
|
99 |
numbersep=10pt, |
|
100 |
tabsize=2, |
|
101 |
showspaces=false, |
|
102 |
showstringspaces=false, |
|
103 |
xleftmargin=8mm, |
|
104 |
emphstyle=\color{codeblue}\bfseries, |
|
105 |
keepspaces, |
|
106 |
linebackgroundcolor={\ifodd\value{lstnumber}\color{capri!3}\fi} |
|
107 |
} |
|
108 |
||
109 |
\lstset{language=Scala, |
|
110 |
style=mystyle} |