langs.sty
author Christian Urban <urbanc@in.tum.de>
Thu, 29 Nov 2018 02:18:05 +0000
changeset 613 bfd511b7ecbf
parent 607 3f4fc76dab2f
child 630 9b1c15c3eb6f
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,%
588
a4646557016d updated
Christian Urban <urbanc@in.tum.de>
parents: 490
diff changeset
    22
    type,val,var,while,with,yield,write,read,lazy},%
591
863e502f6a5c updated
Christian Urban <urbanc@in.tum.de>
parents: 588
diff changeset
    23
  literate={==>}{{\mbox{\color{codepurple}{\textbf{\texttt{==>}}}}}}2,%
863e502f6a5c updated
Christian Urban <urbanc@in.tum.de>
parents: 588
diff changeset
    24
  otherkeywords={=>,<-,<\%,<:,>:,\#},%
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    25
  sensitive=true,%
235
bc460179148c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 234
diff changeset
    26
  %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
    27
  %moredelim=*[directive]:,%
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    28
  morecomment=[l]{//},%
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    29
  morecomment=[n]{/*}{*/},
254
dcd4688690ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
    30
  morestring=[s]{"""}{"""},
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    31
  morestring=[b]",
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    32
  morestring=[b]',
235
bc460179148c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 234
diff changeset
    33
}[keywords,comments,strings]
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    34
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    35
\lstdefinelanguage{While}{
272
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    36
  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
    37
  morecomment=[l]{//},
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    38
  morecomment=[n]{/*}{*/},
272
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    39
  morestring=[b]",
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    40
  otherkeywords={=,!=,:=,<,>,\%;*,/},
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    41
}[keywords,comments,strings]
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    42
218
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
607
3f4fc76dab2f updated
Christian Urban <urbanc@in.tum.de>
parents: 591
diff changeset
    44
237
370c0647a9bf more material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 235
diff changeset
    45
\newcommand{\code}[1]{{\lstinline{#1}}}
242
35104ee14f87 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    46
\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
    47
\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
    48
\makeatother
399
5c1fbb39c93e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 379
diff changeset
    49
427
546f2090ce12 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 399
diff changeset
    50
%%\lstset{escapeinside={(*@}{@*)}}
546f2090ce12 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 399
diff changeset
    51
\lstset{escapeinside={/*@}{@*/}}
480
9e42ccbbd1e6 updated
Christian Urban <urbanc@in.tum.de>
parents: 427
diff changeset
    52
9e42ccbbd1e6 updated
Christian Urban <urbanc@in.tum.de>
parents: 427
diff changeset
    53
%% stripy code
9e42ccbbd1e6 updated
Christian Urban <urbanc@in.tum.de>
parents: 427
diff changeset
    54
\usepackage{lstlinebgrd}
9e42ccbbd1e6 updated
Christian Urban <urbanc@in.tum.de>
parents: 427
diff changeset
    55
\definecolor{capri}{rgb}{0.0, 0.75, 1.0}
490
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    56
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    57
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    58
\lstdefinestyle{mystyle}
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    59
       {basicstyle=\ttfamily,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    60
	keywordstyle=\color{codepurple}\bfseries,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    61
	stringstyle=\color{codegreen},
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    62
	commentstyle=\color{codegreen},
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    63
	morecomment=[s][\color{codedocblue}]{/**}{*/},
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    64
	numbers=none,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    65
	numberstyle=\tiny\color{black},
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    66
	stepnumber=1,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    67
	numbersep=10pt,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    68
	tabsize=2,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    69
	showspaces=false,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    70
	showstringspaces=false,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    71
        xleftmargin=8mm,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    72
        emphstyle=\color{codeblue}\bfseries,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    73
        keepspaces,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    74
        linebackgroundcolor={\ifodd\value{lstnumber}\color{capri!3}\fi}
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    75
}
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    76
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    77
\lstset{language=Scala,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    78
        style=mystyle}