-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpythonformat.tex
More file actions
111 lines (98 loc) · 3.32 KB
/
Copy pathpythonformat.tex
File metadata and controls
111 lines (98 loc) · 3.32 KB
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
\usepackage[Glenn]{fncychap}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\newtheorem{note}{Note:}
\newcommand{\experiment}{{\noindent\colorbox{blue!35}{\strut\makebox[\dimexpr\linewidth-2\fboxsep][c]{\bfseries EXPERIMENT DETAILS}}}}
\newcommand{\aim}{{\noindent\colorbox{blue!25}{\strut\makebox[\dimexpr\linewidth-2\fboxsep][l]{\bfseries AIM}}}}
\newcommand{\dat}{{\noindent\colorbox{blue!25}{\strut\makebox[\dimexpr\linewidth-2\fboxsep][l]{\bfseries DATE}}}}
\newcommand{\algorithm}{{\noindent\colorbox{blue!25}{\strut\makebox[\dimexpr\linewidth-2\fboxsep][l]{\bfseries ALGORITHM}}}}
\newcommand{\code}{{\noindent\colorbox{blue!25}{\strut\makebox[\dimexpr\linewidth-2\fboxsep][l]{\bfseries CODE}}}}
\newcommand{\results}{{\noindent\colorbox{blue!25}{\strut\makebox[\dimexpr\linewidth-2\fboxsep][l]{\bfseries RESULTS}}}}
% Default fixed font does not support bold face
\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{12} % for bold
\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{12} % for normal
\usepackage[T1]{fontenc} % to retain double quotes in lstlistings
\usepackage{listings} % to typeset code
\usepackage{upquote} % to retain single qutoes in lstlistings
% 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}
\definecolor{mygray}{RGB}{245,245,245}
\lstdefinestyle{verbos}{ % code typesetting optins
basicstyle=\small\ttfamily,
breaklines=true,
breakatwhitespace=true,
language=Python,
tabsize=1,
resetmargins=true,
xleftmargin=0pt,
frame=single,
showstringspaces=false
}
\lstnewenvironment{result}[1][]
{\lstset{style=verbos,#1}}
{}
% Python style for highlighting
\newcommand\pythonstyle{\lstset{breaklines=true,
language=python,
backgroundcolor=\color{mygray},
basicstyle=\ttm,
otherkeywords={self}, % Add keywords here
keywordstyle=\ttb\color{deepblue},
emph={MyClass,__init__}, % Custom highlighting
emphstyle=\ttb\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]{{\pythonstyle\lstinline!#1!}}
\newcounter{commentCount}
\newcounter{filePrg}
\newcounter{inputPrg}
\usepackage[dvipsnames]{xcolor}
\usepackage{minted}
\usepackage[many]{tcolorbox}
\tcbuselibrary{listings}
\tcbuselibrary{minted}
\usepackage{ifthen}
\usepackage{fontawesome}
\usepackage{tabularx}
\newcolumntype{\CeX}{>{\centering\let\newline\\\arraybackslash}X}%
\newcommand{\TwoSymbolsAndText}[3]{%
\begin{tabularx}{\textwidth}{c\CeX c}%
#1 & #2 & #3
\end{tabularx}%
}
\newtcblisting[use counter=inputPrg, number format=\arabic]{codeInput}[4]{
listing engine=minted,
minted language=#1,
minted options={autogobble,linenos,breaklines, firstnumber={#4}},
listing only,
size=title,
arc=1.5mm,
breakable,
enhanced jigsaw,
colframe=brown,
coltitle=White,
boxrule=0.5mm,
colback=white,
coltext=Black,
title=\TwoSymbolsAndText{\faCode}{%
\textbf{Input program \thetcbcounter}\ifthenelse{\equal{#2}{}}{}{\textbf{:} \textit{#2}}%
}{\faCode},
label=inputPrg:#3
}