langs.sty
author Christian Urban <urbanc@in.tum.de>
Tue, 28 Jan 2020 12:23:53 +0000
changeset 709 c112a6cb5e52
parent 690 8d57433c7b5e
child 711 6f3f3dd01786
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}
630
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
     3
%\setmonofont[Scale=.95]{Consolas}
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
     4
%\newfontfamily{\consolas}{Consolas}
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
     5
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
     6
\makeatletter
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
     7
\let\old@lstKV@SwitchCases\lstKV@SwitchCases
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
     8
\def\lstKV@SwitchCases#1#2#3{}
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
     9
\makeatother
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    10
\usepackage{lstlinebgrd}
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    11
\makeatletter
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    12
\let\lstKV@SwitchCases\old@lstKV@SwitchCases
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    13
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    14
\lst@Key{numbers}{none}{%
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    15
    \def\lst@PlaceNumber{\lst@linebgrd}%
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    16
    \lstKV@SwitchCases{#1}%
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    17
    {none:\\%
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    18
     left:\def\lst@PlaceNumber{\llap{\normalfont
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    19
                \lst@numberstyle{\thelstnumber}\kern\lst@numbersep}\lst@linebgrd}\\%
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    20
     right:\def\lst@PlaceNumber{\rlap{\normalfont
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    21
                \kern\linewidth \kern\lst@numbersep
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    22
                \lst@numberstyle{\thelstnumber}}\lst@linebgrd}%
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    23
    }{\PackageError{Listings}{Numbers #1 unknown}\@ehc}}
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    24
\makeatother
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    25
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    26
9b1c15c3eb6f updated
Christian Urban <urbanc@in.tum.de>
parents: 607
diff changeset
    27
218
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    29
\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
    30
\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
    31
\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
    32
\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
    33
\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
    34
238
527fdb90fffe updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 237
diff changeset
    35
\BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}}
527fdb90fffe updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 237
diff changeset
    36
\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
    37
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    38
\lstdefinelanguage{Scala}{
237
370c0647a9bf more material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 235
diff changeset
    39
  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
    40
    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
    41
    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
    42
    new,null,object,override,package,%
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    43
    private,protected,requires,return,sealed,%
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    44
    super,this,throw,trait,true,try,%
588
a4646557016d updated
Christian Urban <urbanc@in.tum.de>
parents: 490
diff changeset
    45
    type,val,var,while,with,yield,write,read,lazy},%
591
863e502f6a5c updated
Christian Urban <urbanc@in.tum.de>
parents: 588
diff changeset
    46
  literate={==>}{{\mbox{\color{codepurple}{\textbf{\texttt{==>}}}}}}2,%
863e502f6a5c updated
Christian Urban <urbanc@in.tum.de>
parents: 588
diff changeset
    47
  otherkeywords={=>,<-,<\%,<:,>:,\#},%
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    48
  sensitive=true,%
235
bc460179148c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 234
diff changeset
    49
  %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
    50
  %moredelim=*[directive]:,%
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    51
  morecomment=[l]{//},%
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    52
  morecomment=[n]{/*}{*/},
254
dcd4688690ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
    53
  morestring=[s]{"""}{"""},
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    54
  morestring=[b]",
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    55
  morestring=[b]',
235
bc460179148c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 234
diff changeset
    56
}[keywords,comments,strings]
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    57
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    58
\lstdefinelanguage{While}{
690
8d57433c7b5e updated
Christian Urban <urbanc@in.tum.de>
parents: 680
diff changeset
    59
  morekeywords={if,then,else,while,do,true,false,write,upto,read,for,skip,new},
272
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    60
  morecomment=[l]{//},
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    61
  morecomment=[n]{/*}{*/},
272
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    62
  morestring=[b]",
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    63
  otherkeywords={=,!=,:=,<,>,\%;*,/},
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 254
diff changeset
    64
}[keywords,comments,strings]
234
bf7eecc9cefe updated scala ho
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
    65
218
8f3f8d82da8b added two new packages
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
647
180600c04da2 updated
Christian Urban <urbanc@in.tum.de>
parents: 630
diff changeset
    67
\lstdefinelanguage{JVMIS2}{
709
c112a6cb5e52 updated
Christian Urban <urbanc@in.tum.de>
parents: 690
diff changeset
    68
  morekeywords={ldc,iload,istore,ifeq,if_icmpge,if_icmpgt,iadd,goto},
647
180600c04da2 updated
Christian Urban <urbanc@in.tum.de>
parents: 630
diff changeset
    69
}[keywords]
180600c04da2 updated
Christian Urban <urbanc@in.tum.de>
parents: 630
diff changeset
    70
680
eecc4d5a2172 updated
Christian Urban <urbanc@in.tum.de>
parents: 647
diff changeset
    71
\lstdefinelanguage{LLVMIR}{
eecc4d5a2172 updated
Christian Urban <urbanc@in.tum.de>
parents: 647
diff changeset
    72
  otherkeywords={let,in,add,mul},
eecc4d5a2172 updated
Christian Urban <urbanc@in.tum.de>
parents: 647
diff changeset
    73
}[strings]
607
3f4fc76dab2f updated
Christian Urban <urbanc@in.tum.de>
parents: 591
diff changeset
    74
237
370c0647a9bf more material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 235
diff changeset
    75
\newcommand{\code}[1]{{\lstinline{#1}}}
242
35104ee14f87 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    76
\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
    77
\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
    78
\makeatother
399
5c1fbb39c93e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 379
diff changeset
    79
427
546f2090ce12 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 399
diff changeset
    80
%%\lstset{escapeinside={(*@}{@*)}}
546f2090ce12 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 399
diff changeset
    81
\lstset{escapeinside={/*@}{@*/}}
480
9e42ccbbd1e6 updated
Christian Urban <urbanc@in.tum.de>
parents: 427
diff changeset
    82
9e42ccbbd1e6 updated
Christian Urban <urbanc@in.tum.de>
parents: 427
diff changeset
    83
%% stripy code
9e42ccbbd1e6 updated
Christian Urban <urbanc@in.tum.de>
parents: 427
diff changeset
    84
\usepackage{lstlinebgrd}
9e42ccbbd1e6 updated
Christian Urban <urbanc@in.tum.de>
parents: 427
diff changeset
    85
\definecolor{capri}{rgb}{0.0, 0.75, 1.0}
490
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    86
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    87
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    88
\lstdefinestyle{mystyle}
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    89
       {basicstyle=\ttfamily,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    90
	keywordstyle=\color{codepurple}\bfseries,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    91
	stringstyle=\color{codegreen},
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    92
	commentstyle=\color{codegreen},
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    93
	morecomment=[s][\color{codedocblue}]{/**}{*/},
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    94
	numbers=none,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    95
	numberstyle=\tiny\color{black},
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    96
	stepnumber=1,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    97
	numbersep=10pt,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    98
	tabsize=2,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
    99
	showspaces=false,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
   100
	showstringspaces=false,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
   101
        xleftmargin=8mm,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
   102
        emphstyle=\color{codeblue}\bfseries,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
   103
        keepspaces,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
   104
        linebackgroundcolor={\ifodd\value{lstnumber}\color{capri!3}\fi}
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
   105
}
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
   106
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
   107
\lstset{language=Scala,
4fee50f38305 updated
Christian Urban <urbanc@in.tum.de>
parents: 480
diff changeset
   108
        style=mystyle}