CoCalc Shared Fileswww / 257 / notes / python.styOpen in CoCalc with one click!
Author: William A. Stein
1
% -- I snipped this from the Python documentation distribution -- William Stein
2
3
% This sets up the {verbatim} environment to be indented and a minipage,
4
% and to have all the other mostly nice properties that we want for
5
% code samples.
6
7
\let\[email protected]=\verbatim
8
\let\[email protected]=\endverbatim
9
\RequirePackage{verbatim}
10
\RequirePackage{ifthen}
11
12
% Variable used by begin code command
13
\newlength{\[email protected]}
14
15
\renewcommand{\verbatim}[1]{%
16
\setlength{\parindent}{1cm}
17
% Calculate the text width for the minipage:
18
\setlength{\[email protected]}{\linewidth}%
19
\addtolength{\[email protected]}{-\parindent}%
20
%
21
\ifthenelse{\equal{#1}{}}{}{%
22
\begin{listing}[#1]\label{listing:#1}\index{code listing!#1}\mbox{}\vspace{-1.5em}\newline{}}%
23
\begin{list}{}{%
24
\ifthenelse{\equal{#1}{}}{\setlength{\leftmargin}{4ex}}%
25
{\setlength{\leftmargin}{0ex}}}%
26
\item%
27
\[email protected]%
28
}
29
\renewcommand{\endverbatim}{%
30
\[email protected]%
31
\end{list}%
32
%\end{listing}%
33
\ifthenelse{\lengthtest{\leftmargin>2ex}}{\vspace{0.5em}}{------------------------------------------------------------------------\end{listing}}%
34
}
35
36