File: example_macros.tex

package info (click to toggle)
pyutilib 6.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,924 kB
  • sloc: python: 18,448; xml: 135; perl: 75; makefile: 50; sh: 32
file content (139 lines) | stat: -rw-r--r-- 3,498 bytes parent folder | download | duplicates (3)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
%\newfloat{example}{htbp}{lop}
%\floatname{example}{Example}

%\newcommand{\code}[1]{\textmd{\texttt{#1}}}
%\newcommand{\todo}[1]{\textbf{\textit{TODO: #1}}}
%\newcommand{\comment}[1]{\marginpar{\textit{#1}}}

%\newenvironment{notebox}%
  %{\begin{table}\begin{center}\begin{Sbox}\begin{minipage}{.8\textwidth}{\bf NOTE:}}
  %{\end{minipage}\end{Sbox}\fbox{\TheSbox}\end{center}\end{table}}
%
%\newenvironment{Xnotebox}%
  %{\begin{table}\begin{center}\begin{svgraybox}\begin{minipage}{.8\textwidth}{\bf NOTE:}}
  %{\end{minipage}\end{svgraybox}\end{center}\end{table}}

\lstnewenvironment{otherlisting}%
  {\lstset{
    aboveskip=0.3em,
    belowskip=0.3em,
    xleftmargin=1.5em,
    xrightmargin=1.5em,
    showspaces=false,
    showstringspaces=false,
    columns=fullflexible,
    frame=single,
    basicstyle=\footnotesize\ttfamily ,
    backgroundcolor=\color{white}
    }}
  {}

\lstnewenvironment{qlisting}%
  {\lstset{
    aboveskip=0.3em,
    belowskip=0.3em,
    xleftmargin=1.5em,
    xrightmargin=1.5em,
    showspaces=false,
    showstringspaces=false,
    columns=fullflexible,
    frame=single,
    basicstyle=\footnotesize\ttfamily ,
    backgroundcolor=\color{white},
    language=Python
    }}
  {}

\lstnewenvironment{qautobreaklisting}%
  {\lstset{
    aboveskip=0.3em,
    belowskip=0.3em,
    xleftmargin=1.5em,
    xrightmargin=1.5em,
    showspaces=false,
    showstringspaces=false,
    columns=fullflexible,
    frame=single,
    breaklines=true,
    breakatwhitespace=true,
    prebreak={\textbackslash},
    basicstyle=\footnotesize\ttfamily ,
    backgroundcolor=\color{white},
    language=Python
    }}
  {}


%
% Syntax: \listing{<filename>}{<anchor>}{<firstline>}{<lastline>}
%
% NOTE: the firstline and lastline data is automatically generated.  For example:
%
%   \listing{foo}{bar}
%
% is initialized to find the 'bar' anchor in file 'foo'.  Additionally, if we have
%
%   \listing{foo}{}
%
% then the entire file 'foo' is include.
%
\newcommand{\listing}[4]{\lstinputlisting[firstline=#3,lastline=#4,
    aboveskip=0.3em,
    belowskip=0.3em,
    xleftmargin=1.5em,
    xrightmargin=1.5em,
    showspaces=false,
    showstringspaces=false,
    columns=fullflexible,
    frame=single,
    basicstyle=\footnotesize\ttfamily ,
    backgroundcolor=\color{white},
    language=Python
    ]{#1}}

\newcommand{\autobreaklisting}[4]{\lstinputlisting[firstline=#3,lastline=#4,
    aboveskip=0.3em,
    belowskip=0.3em,
    xleftmargin=1.5em,
    xrightmargin=1.5em,
    showspaces=false,
    showstringspaces=false,
    columns=fullflexible,
    frame=single,
    breaklines=true,
    breakatwhitespace=true,
    prebreak={\textbackslash},
    basicstyle=\footnotesize\ttfamily ,
    backgroundcolor=\color{white},
    language=Python
    ]{#1}}


\newcommand{\scriptsizelisting}[4]{\lstinputlisting[firstline=#3,lastline=#4,
    aboveskip=0.3em,
    belowskip=0.3em,
    xleftmargin=1.5em,
    xrightmargin=1.5em,
    showspaces=false,
    showstringspaces=false,
    columns=fullflexible,
    frame=single,
    basicstyle=\scriptsize\ttfamily ,
    backgroundcolor=\color{white},
    language=Python
    ]{#1}}

\newcommand{\tinylisting}[4]{\lstinputlisting[firstline=#3,lastline=#4,
    aboveskip=0.3em,
    belowskip=0.3em,
    xleftmargin=1.5em,
    xrightmargin=1.5em,
    showspaces=false,
    showstringspaces=false,
    columns=fullflexible,
    frame=single,
    basicstyle=\tiny\ttfamily ,
    backgroundcolor=\color{white},
    language=Python
    ]{#1}}