langs.sty
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 18 Oct 2016 11:13:37 +0100
changeset 454 edb4ad356c56
parent 427 546f2090ce12
child 480 9e42ccbbd1e6
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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}
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
     3
\setmonofont[Scale=.95]{Consolas}
218
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
\newfontfamily{\consolas}{Consolas}
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
     6
\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
     7
\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
     8
\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
     9
\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
    10
\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
    11
238
527fdb90fffe updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 237
diff changeset
    12
\BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}}
527fdb90fffe updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 237
diff changeset
    13
\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
    14
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    15
\lstdefinelanguage{Scala}{
237
370c0647a9bf more material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 235
diff changeset
    16
  morekeywords={abstract,case,catch,class,def,%
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    17
    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
    18
    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
    19
    new,null,object,override,package,%
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    20
    private,protected,requires,return,sealed,%
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    21
    super,this,throw,trait,true,try,%
379
fa2589ec0fae updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
    22
    type,val,var,while,with,yield,write,read},%
254
dcd4688690ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
    23
  otherkeywords={=>,<-,<\%,<:,>:,\#},%
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    24
  sensitive=true,%
235
bc460179148c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 234
diff changeset
    25
  %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
    26
  %moredelim=*[directive]:,%
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    27
  morecomment=[l]{//},%
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    28
  morecomment=[n]{/*}{*/},
254
dcd4688690ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
    29
  morestring=[s]{"""}{"""},
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    30
  morestring=[b]",
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    31
  morestring=[b]',
235
bc460179148c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 234
diff changeset
    32
}[keywords,comments,strings]
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    33
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    34
\lstdefinelanguage{While}{
272
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    35
  morekeywords={if,then,else,while,do,true,false,write,upto,read,for,skip},
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    36
  morecomment=[l]{//},
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    37
  morecomment=[n]{/*}{*/},
272
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    38
  morestring=[b]",
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    39
  otherkeywords={=,!=,:=,<,>,\%;*,/},
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    40
}[keywords,comments,strings]
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    41
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    42
\lstdefinestyle{mystyle}
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    43
       {basicstyle=\ttfamily,
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    44
	keywordstyle=\color{codepurple}\bfseries,
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    45
	stringstyle=\color{codegreen},
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    46
	commentstyle=\color{codegreen},
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    47
	morecomment=[s][\color{codedocblue}]{/**}{*/},
218
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
	numbers=left,
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
	numberstyle=\tiny\color{black},
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
	stepnumber=1,
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
	numbersep=10pt,
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
	tabsize=2,
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
	showspaces=false,
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    54
	showstringspaces=false,
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    55
        xleftmargin=8mm,
237
370c0647a9bf more material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 235
diff changeset
    56
        emphstyle=\color{codeblue}\bfseries,
254
dcd4688690ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
    57
        keepspaces
dcd4688690ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
    58
}
218
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
\lstset{language=Scala,
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    61
        style=mystyle}
218
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
237
370c0647a9bf more material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 235
diff changeset
    64
\newcommand{\code}[1]{{\lstinline{#1}}}
242
35104ee14f87 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    65
\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
    66
\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
    67
\makeatother
399
5c1fbb39c93e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 379
diff changeset
    68
427
546f2090ce12 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 399
diff changeset
    69
%%\lstset{escapeinside={(*@}{@*)}}
546f2090ce12 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 399
diff changeset
    70
\lstset{escapeinside={/*@}{@*/}}