langs.sty
author Christian Urban <urbanc@in.tum.de>
Wed, 16 Nov 2016 23:34:05 +0000
changeset 53 9f8751912560
parent 21 610f7a4a9ede
child 123 556cd74cbba9
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\usepackage{listings}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
\usepackage{etoolbox}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
\setmonofont[Scale=.95]{Consolas}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
\newfontfamily{\consolas}{Consolas}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
\definecolor{codered}{rgb}{0.6,0,0}            % for strings
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\definecolor{codegreen}{rgb}{0.25,0.5,0.35}    % comments
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
\definecolor{codepurple}{rgb}{0.5,0,0.35}      % keywords
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
\definecolor{codedocblue}{rgb}{0.25,0.35,0.75} % doc
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
\definecolor{codeblue}{rgb}{0.25,0.35,0.75}    % types
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
\BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
\AfterEndEnvironment{lstlisting}{\end{minipage}\par}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
\lstdefinelanguage{Scala}{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  morekeywords={abstract,case,catch,class,def,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
    do,else,extends,false,final,finally,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
    for,if,implicit,import,match,mixin,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
    new,null,object,override,package,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
    private,protected,requires,return,sealed,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
    super,this,throw,trait,true,try,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
    type,val,var,while,with,yield,write,read},%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  otherkeywords={=>,<-,<\%,<:,>:,\#},%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
  sensitive=true,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  %directives={Int,Char,Rexp,String,Boolean,BigInt,Unit,List,Set},%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
  %moredelim=*[directive]:,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
  morecomment=[l]{//},%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
  morecomment=[n]{/*}{*/},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  morestring=[s]{"""}{"""},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
  morestring=[b]",
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
  morestring=[b]',
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
}[keywords,comments,strings]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
\lstdefinelanguage{While}{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
  morekeywords={if,then,else,while,do,true,false,write,upto,read,for,skip},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
  morecomment=[l]{//},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
  morecomment=[n]{/*}{*/},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
  morestring=[b]",
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
  otherkeywords={=,!=,:=,<,>,\%;*,/},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
}[keywords,comments,strings]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
\lstdefinestyle{mystyle}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
       {basicstyle=\ttfamily,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
	keywordstyle=\color{codepurple}\bfseries,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
	stringstyle=\color{codegreen},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
	commentstyle=\color{codegreen},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
	morecomment=[s][\color{codedocblue}]{/**}{*/},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
	numbers=left,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
	numberstyle=\tiny\color{black},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
	stepnumber=1,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
	numbersep=10pt,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
	tabsize=2,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
	showspaces=false,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
	showstringspaces=false,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
        xleftmargin=8mm,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
        emphstyle=\color{codeblue}\bfseries,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
        keepspaces
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
\lstset{language=Scala,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
        style=mystyle}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
\newcommand{\code}[1]{{\lstinline{#1}}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
\newcommand{\pcode}[1]{\mbox{\lstset{language={},keywordstyle=\color{black}}\lstinline!#1!}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
\newcommand{\scode}[1]{\mbox{\lstset{language={},basicstyle=\ttfamily\color{codegreen}}\lstinline!#1!}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
\makeatother
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
%%\lstset{escapeinside={(*@}{@*)}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
\lstset{escapeinside={/*@}{@*/}}