-
Notifications
You must be signed in to change notification settings - Fork 3
/
listings.tex
69 lines (65 loc) · 2.25 KB
/
listings.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
% The language definitions below require the following packages:
%
% \usepackage{courier}
% \usepackage{xcolor}
% \usepackage{relsize}
%
% \input{listings}
% \renewcommand{\Underscore}{\textscale{1}{\textunderscore}}
%
% Without extra packages I had to provide an alternative underscore definition
% to get decent looking underscores.
%
% As an alternative to courier, it is also possible to use the `lmodern`
% package.
%
% \usepackage[T1]{fontenc}
% \usepackage{lmodern}
% \usepackage{xcolor}
% \usepackage{relsize}
%
% \input{listings}
%
% When the python or clingo language is given, tex code can be embedded
% escaping it in `#( ... #)`, which is treated like a comment in Python.
% Furthermore, for logic programs the character sequence is `%%` is not output.
% This can be used to add labels at the end of lines. For example, in a logic
% program one can write
%
% H :- B.%%#( \label{lst:rule} #)
%
% to refer to the rule from the document without having to worry about changing
% line numbers when refactoring. The annotated program will still be runnable
% with clingo.
\providecommand{\Underscore}{\textunderscore}
\lstdefinelanguage{clingo}{%
basicstyle=\ttfamily,%
keywordstyle=[1]\bfseries,%
keywordstyle=[2]\bfseries,%
keywordstyle=[3]\bfseries,%
showstringspaces=false,%
literate={_}{\Underscore}1 {\%\%}{}0,%
escapeinside={\#(}{\#)},%
alsoletter={\#,\&},%
keywords=[1]{not,from,import,def,if,else,elif,return,while,break,and,or,for,in,del,and,class,with,as,is,yield,async},%
keywords=[2]{\#const,\#show,\#minimize,\#base,\#theory,\#count,\#external,\#program,\#script,\#end,\#heuristic,\#edge,\#project,\#show,\#sum},%
keywords=[3]{&,&dom,&sum,&diff,&show},%
morecomment=[l]{\#\ },%
morecomment=[l]{\%\ },%
morestring=[b]",%
stringstyle={\itshape},%
commentstyle={\color{darkgray}}%
}
\lstdefinelanguage{python}{%
basicstyle=\ttfamily,%
keywordstyle=[1]\bfseries,%
showstringspaces=false,%
literate={_}{\Underscore}{1},%
escapeinside={\#(}{\#)},%
alsoletter={\#,\&},%
keywords=[1]{not,from,import,def,if,else,elif,return,while,break,and,or,for,in,del,and,class,with,as,is,yield,async},%
morecomment=[l]{\#\ },%
morestring=[b]",%
stringstyle={\itshape},%
commentstyle={\color{darkgray}}%
}