forked from Fedjmike/cucats-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbase.tex
115 lines (104 loc) · 3.31 KB
/
base.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{color}
\usepackage{listings}
\usepackage{etoolbox}
\usepackage{calc}
\setlength{\fboxsep}{0.5mm}
\definecolor{orange}{rgb}{1,0.5,0}
\definecolor{green}{rgb}{0,0.5,0}
\definecolor{gray}{rgb}{0.25,0.25,0.25}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\definecolor{red}{rgb}{1.0,0,0}
\colorlet{punct}{green}
\colorlet{delim}{green}
\colorlet{num}{mauve}
\definecolor{codebg}{rgb}{1.0,1.0,0.8}
\definecolor{jargonbg}{rgb}{0.8,1.0,0.8}
\definecolor{spacebg}{rgb}{1.0,0.8,0.0}
\definecolor{lightspacebg}{rgb}{1.0,0.9,0.5}
\newtoggle{InString}{}% Keep track of if we are within a string
\togglefalse{InString}% Assume not initally in string
\newcommand*{\ColorIfNotInString}[1]{\iftoggle{InString}{#1}{\color{num}#1}}
\newcommand*{\ProcessQuote}[1]{\color{red}#1\iftoggle{InString}{\global\togglefalse{InString}}{\global\toggletrue{InString}}}
\lstdefinelanguage{py}{
morekeywords={if,elif,else,for,in,while,break,continue,def,class,True,False,print,return,and,or,not,with,None,try,except,finally,raise,as,input,open,len},
morecomment=[l]\#,
literate=
*{=}{{{\color{punct}{=}}}}{1}
{|}{{{\color{punct}{|}}}}{1}
{\^}{{{\color{punct}{\^{}}}}}{1}
{\{}{{{\color{punct}{\{}}}}{1}
{\}}{{{\color{punct}{\}}}}}{1}
{[}{{{\color{punct}{[}}}}{1}
{]}{{{\color{punct}{]}}}}{1}
{)}{{{\color{punct}{)}}}}{1}
{(}{{{\color{punct}{(}}}}{1}
{<}{{{\color{punct}{<}}}}{1}
{>}{{{\color{punct}{>}}}}{1}
{*}{{{\color{punct}{*}}}}{1}
{?}{{{\color{punct}{?}}}}{1}
{:}{{{\color{punct}{:}}}}{1}
{,}{{{\color{punct}{,}}}}{1}
{\&}{{{\color{punct}{\&}}}}{1}
{!}{{{\color{punct}{!}}}}{1}
{-}{{{\color{punct}{-}}}}{1}
{+}{{{\color{punct}{+}}}}{1}
{.}{{{\color{punct}{.}}}}{1}
{\%}{{{\color{punct}{\%}}}}{1}
{/}{{{\color{punct}{/}}}}{1}
{\~}{{{$\color{punct}{\sim}$}}}{1}
{;}{{{\color{punct}{;}}}}{1}
%{"}{{{\ProcessQuote{"}}}}1% Disable coloring within double quotes
%{'}{{{\ProcessQuote{'}}}}1% Disable coloring within single quote
{0}{{{\ColorIfNotInString{0}}}}1
{1}{{{\ColorIfNotInString{1}}}}1
{2}{{{\ColorIfNotInString{2}}}}1
{3}{{{\ColorIfNotInString{3}}}}1
{4}{{{\ColorIfNotInString{4}}}}1
{5}{{{\ColorIfNotInString{5}}}}1
{6}{{{\ColorIfNotInString{6}}}}1
{7}{{{\ColorIfNotInString{7}}}}1
{8}{{{\ColorIfNotInString{8}}}}1
{9}{{{\ColorIfNotInString{9}}}}1,
}
\lstset{
language=py,
%
captionpos=b, % sets the caption-position to bottom
mathescape=true,
keepspaces=true,
showspaces=false,
showstringspaces=false, % underline spaces within strings only
showtabs=false, % show tabs within strings adding particular underscores
stepnumber=1,
tabsize=4,
title=\lstname,
morestring=[b]",
morestring=[b]',
belowskip=-0.8 \baselineskip,
%
numberstyle=\footnotesize\color{gray},
rulecolor=\color{black},
basicstyle=\ttfamily\small,
backgroundcolor=\color{codebg},
keywordstyle=\color{blue},
commentstyle=\color{orange},
stringstyle=\color{red},
}
\lstdefinestyle{output}{
basicstyle=\small\ttfamily,
numbers=none,
frame=tblr,
columns=fullflexible,
backgroundcolor=\color{blue!10},
linewidth=0.9\linewidth,
xleftmargin=0.1\linewidth
}
\newlength{\DepthReference}
\settodepth{\DepthReference}{g}
\newlength{\HeightReference}
\settoheight{\HeightReference}{T}
\newlength{\Width}
\newcommand{\evenbox}[2]{\colorbox{#1}{\rule[-2pt]{0pt}{10pt}#2}}