langs.sty
changeset 157 3a8fff66d62b
child 160 4cbd6ca025e6
equal deleted inserted replaced
156:3b831b9dc616 157:3a8fff66d62b
       
     1 \usepackage{listings}
       
     2 \usepackage{etoolbox}
       
     3 \setmonofont[Scale=.95]{Consolas}
       
     4 \newfontfamily{\consolas}{Consolas}
       
     5 
       
     6 \definecolor{codered}{rgb}{0.6,0,0}            % for strings
       
     7 \definecolor{codegreen}{rgb}{0.25,0.5,0.35}    % comments
       
     8 \definecolor{codepurple}{rgb}{0.5,0,0.35}      % keywords
       
     9 \definecolor{codedocblue}{rgb}{0.25,0.35,0.75} % doc
       
    10 \definecolor{codeblue}{rgb}{0.25,0.35,0.75}    % types
       
    11 
       
    12 \BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}}
       
    13 \AfterEndEnvironment{lstlisting}{\end{minipage}\par}
       
    14 
       
    15 \lstdefinelanguage{Scala}{
       
    16   morekeywords={abstract,case,catch,class,def,%
       
    17     do,else,extends,false,final,finally,%
       
    18     for,if,implicit,import,match,mixin,%
       
    19     new,null,object,override,package,%
       
    20     private,protected,requires,return,sealed,%
       
    21     super,this,throw,trait,true,try,%
       
    22     type,val,var,while,with,yield},%
       
    23   otherkeywords={=>,<-,<\%,<:,>:,\#,@},%
       
    24   sensitive=true,%
       
    25   %directives={Int,Char,Rexp,String,Boolean,BigInt,Unit,List,Set},%
       
    26   %moredelim=*[directive]:,%
       
    27   morecomment=[l]{//},%
       
    28   morecomment=[n]{/*}{*/},
       
    29   morestring=[b]",
       
    30   morestring=[b]',
       
    31   morestring=[b]"""
       
    32 }[keywords,comments,strings]
       
    33 
       
    34 \lstdefinelanguage{While}{
       
    35   morekeywords={if,then,else,while,do,true,false,write,upto,for,skip},
       
    36   otherkeywords={=,!=,:=,<,>,;},
       
    37   sensitive=true,
       
    38   morecomment=[n]{/*}{*/},
       
    39 }
       
    40 
       
    41 \lstdefinestyle{mystyle}
       
    42        {basicstyle=\ttfamily,
       
    43 	keywordstyle=\color{codepurple}\bfseries,
       
    44         %directivestyle=\color{codeblue}\bfseries,
       
    45 	stringstyle=\color{codegreen},
       
    46 	commentstyle=\color{codegreen},
       
    47 	morecomment=[s][\color{codedocblue}]{/**}{*/},
       
    48 	numbers=left,
       
    49 	numberstyle=\tiny\color{black},
       
    50 	stepnumber=1,
       
    51 	numbersep=10pt,
       
    52 	tabsize=2,
       
    53 	showspaces=false,
       
    54 	showstringspaces=false,
       
    55         xleftmargin=8mm,
       
    56         emphstyle=\color{codeblue}\bfseries,
       
    57         keepspaces}
       
    58 
       
    59 \lstset{language=Scala,
       
    60         style=mystyle}
       
    61 
       
    62 
       
    63 \newcommand{\code}[1]{{\lstinline{#1}}}