-
Notifications
You must be signed in to change notification settings - Fork 14
/
lstdefinitions.tex
63 lines (53 loc) · 1.51 KB
/
lstdefinitions.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
% Default fixed font does not support bold face
\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{10} % for bold
\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{10} % for normal
% Custom colors
\usepackage{color}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}
% Python style for highlighting
\newcommand\pythonstyle{\lstset{
language=Python,
basicstyle=\footnotesize,
otherkeywords={self}, % Add keywords here
keywordstyle=\bfseries\color{black},
emph={MyClass,__init__}, % Custom highlighting
emphstyle=\color{deepred}, % Custom highlighting style
stringstyle=\color{deepgreen},
frame=tb, % Any extra options here
showstringspaces=false %
}}
% Python environment
\lstnewenvironment{python}[1][]
{
\pythonstyle
\lstset{#1}
}
{}
% Python for external files
\newcommand\pythonexternal[2][]{{
\pythonstyle
\lstinputlisting[#1]{#2}}}
% Python for inline
\newcommand\pythoninline[1]{\text{#1}}
% Algorithm style for highlighting
\newcommand\algstyle{\lstset{
language=Python,
basicstyle=\footnotesize,
otherkeywords={self}, % Add keywords here
keywordstyle=\bfseries\color{black},
emph={MyClass,__init__}, % Custom highlighting
emphstyle=\color{black}, % Custom highlighting style
stringstyle=\color{black},
frame=tb, % Any extra options here
showstringspaces=false, %
captionpos=t
}}
% Algorithm environment
\lstnewenvironment{algorithm}[1][]
{
\algstyle
\lstset{#1}
}
{}