langs.sty
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 16 Sep 2014 11:31:55 +0100
changeset 160 4cbd6ca025e6
parent 157 3a8fff66d62b
child 164 08a6e035223e
permissions -rw-r--r--
updated slides
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
157
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
\usepackage{listings}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
\usepackage{etoolbox}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
\setmonofont[Scale=.95]{Consolas}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
\newfontfamily{\consolas}{Consolas}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
3a8fff66d62b 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
3a8fff66d62b 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
3a8fff66d62b 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
3a8fff66d62b 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
3a8fff66d62b 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
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
\BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
\AfterEndEnvironment{lstlisting}{\end{minipage}\par}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
\lstdefinelanguage{Scala}{
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
  morekeywords={abstract,case,catch,class,def,%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
    do,else,extends,false,final,finally,%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
    for,if,implicit,import,match,mixin,%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
    new,null,object,override,package,%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
    private,protected,requires,return,sealed,%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
    super,this,throw,trait,true,try,%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
    type,val,var,while,with,yield},%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
  otherkeywords={=>,<-,<\%,<:,>:,\#,@},%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
  sensitive=true,%
3a8fff66d62b 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},%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
  %moredelim=*[directive]:,%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
  morecomment=[l]{//},%
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
  morecomment=[n]{/*}{*/},
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
  morestring=[b]",
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
  morestring=[b]',
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
  morestring=[b]"""
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
}[keywords,comments,strings]
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
\lstdefinelanguage{While}{
3a8fff66d62b 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,for,skip},
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
  otherkeywords={=,!=,:=,<,>,;},
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
  sensitive=true,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
  morecomment=[n]{/*}{*/},
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
\lstdefinestyle{mystyle}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
       {basicstyle=\ttfamily,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
	keywordstyle=\color{codepurple}\bfseries,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
        %directivestyle=\color{codeblue}\bfseries,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
	stringstyle=\color{codegreen},
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
	commentstyle=\color{codegreen},
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
	morecomment=[s][\color{codedocblue}]{/**}{*/},
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
	numbers=left,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
	numberstyle=\tiny\color{black},
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
	stepnumber=1,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
	numbersep=10pt,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
	tabsize=2,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
	showspaces=false,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
	showstringspaces=false,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
        xleftmargin=8mm,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
        emphstyle=\color{codeblue}\bfseries,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
        keepspaces}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
\lstset{language=Scala,
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
        style=mystyle}
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
3a8fff66d62b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
\newcommand{\code}[1]{{\lstinline{#1}}}
160
4cbd6ca025e6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 157
diff changeset
    64
\newcommand{\pcode}[1]{\mbox{\lstset{language={},keywordstyle=\color{black}}\lstinline!#1!}}
4cbd6ca025e6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 157
diff changeset
    65
\makeatother