-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.tex
More file actions
24 lines (17 loc) · 754 Bytes
/
Copy pathcode.tex
File metadata and controls
24 lines (17 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
% !TEX root = keeping-up.tex
%%
\section{Code Snippets}
\label{sec:code}
Code Snippets are defined by the listings package. Snippets are floating elements, which can be formatted tailored to a specific programming language. \fref{lst:python} shows an example of the custom environment for Python code
\begin{python}[numbers=left, frame=lines,
label={lst:python},
caption={Python code example}]
class Dog: `\label{ln:class} `
def __init__(self, name, age):
self.name = name
self.age = age
def bark(self):
print(f"woof-woof. I'm {self.name}")
\end{python}
Inline code environment can also be defined to add them to text paragraphs, as referring to the \spy{class Dog} definition in \fref{ln:class}.
\endinput