/[escript]/trunk/doc/cookbook/pythonlisting.tex
ViewVC logotype

Contents of /trunk/doc/cookbook/pythonlisting.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2775 - (show annotations)
Wed Nov 25 05:01:43 2009 UTC (9 years, 8 months ago) by ahallam
File MIME type: application/x-tex
File size: 2631 byte(s)
minor updates to cookbook; new python syntax highlighting
1 % Python listing setup
2 % from http://blog.miliauskas.lt/2008/09/python-syntax-highlighting-in-latex.html
3
4 \usepackage{color}
5 \usepackage[procnames]{listings}
6 \usepackage{textcomp}
7 \usepackage{setspace}
8 \usepackage{palatino}
9 \renewcommand{\lstlistlistingname}{Code Listings}
10 \renewcommand{\lstlistingname}{Code Listing}
11 \definecolor{gray}{gray}{0.5}
12 \definecolor{green}{rgb}{0,0.5,0}
13 \definecolor{lightgreen}{rgb}{0,0.7,0}
14 \definecolor{purple}{rgb}{0.5,0,0.5}
15 \definecolor{darkred}{rgb}{0.5,0,0}
16 \definecolor{orange}{rgb}{1.0,0.4,0.1}
17 \lstnewenvironment{python}[1][]{
18 \lstset{
19 language=python,
20 basicstyle=\ttfamily\small\setstretch{1},
21 stringstyle=\color{green},
22 showstringspaces=false,
23 alsoletter={1234567890},
24 otherkeywords={\ , \}, \{},
25 keywordstyle=\color{blue},
26 emph={access,and,as,break,class,continue,def,del,elif,else,%
27 except,exec,finally,for,from,global,if,import,in,is,%
28 lambda,not,or,pass,print,raise,return,try,while,assert},
29 emphstyle=\color{orange}\bfseries,
30 emph={[2]self},
31 emphstyle=[2]\color{gray},
32 emph={[4]ArithmeticError,AssertionError,AttributeError,BaseException,%
33 DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,%
34 False,FloatingPointError,FutureWarning,GeneratorExit,IOError,%
35 ImportError,ImportWarning,IndentationError,IndexError,KeyError,%
36 KeyboardInterrupt,LookupError,MemoryError,NameError,None,%
37 NotImplemented,NotImplementedError,OSError,OverflowError,%
38 PendingDeprecationWarning,ReferenceError,RuntimeError,RuntimeWarning,%
39 StandardError,StopIteration,SyntaxError,SyntaxWarning,SystemError,%
40 SystemExit,TabError,True,TypeError,UnboundLocalError,UnicodeDecodeError,%
41 UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,%
42 UserWarning,ValueError,Warning,ZeroDivisionError,abs,all,any,apply,%
43 basestring,bool,buffer,callable,chr,classmethod,cmp,coerce,compile,%
44 complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,%
45 execfile,exit,file,filter,float,frozenset,getattr,globals,hasattr,%
46 hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,%
47 license,list,locals,long,map,max,min,object,oct,open,ord,pow,property,%
48 quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,%
49 slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,%
50 vars,xrange,zip},
51 emphstyle=[4]\color{purple}\bfseries,
52 upquote=true,
53 morecomment=[s][\color{lightgreen}]{"""}{"""},
54 commentstyle=\color{red}\slshape,
55 literate={>>>}{\textbf{\textcolor{darkred}{>{>}>}}}3%
56 {...}{{\textcolor{gray}{...}}}3,
57 procnamekeys={def,class},
58 procnamestyle=\color{blue}\textbf,
59 %framexleftmargin=1mm, framextopmargin=1mm, frame=box,
60 %rulesepcolor=\color{gray},#1
61 }}{}
62

  ViewVC Help
Powered by ViewVC 1.1.26