Debian Codegraph @

texmf-dist/tex/latex/seminar/tvz-code.sty

raw
1 %% BEGIN tvz-code.sty
2 %% 93/04/01
3 %% Tim Van Zandt [email protected]
4 %%
5 %% Lousy hacks for typesetting the documented code for the
6 %%
7 %% This file may be distributed and/or modified under the conditions of
8 %% the LaTeX Project Public License, either version 1.2 of this license
9 %% or (at your option) any later version. The latest version of this
10 %% license is in:
11 %%
12 %% http://www.latex-project.org/lppl.txt
13 %%
14 %% and version 1.2 or later is part of all distributions of LaTeX version
15 %% 1999/12/01 or later.
16 %%
17 %% seminar.sty and PSTricks packages.
18
19 \input tvz-hax.sty
20 \input doc.sty % Tested with v1.7k
21 \input art11.sty
22
23
24 %%%%%%%%%%%%%%%%%%% PAGE PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%
25
26 % Paragraphs are marked by space rather than indentation:
27 \parindent 0pt
28 \parskip 4pt plus 1pt minus 1pt
29
30 % Textwidth just wide enough for 78 characters of code.
31 \setbox\@tempboxa=\hbox{\small\tt f}
32 \textwidth 78\wd\@tempboxa
33 \oddsidemargin\paperwidth\relax
34 \advance\oddsidemargin -\textwidth
35 \divide\oddsidemargin 2
36 \advance\oddsidemargin -1in
37 \setbox\@tempboxa=\hbox{\tiny 999\ }
38 \advance\oddsidemargin\wd\@tempboxa
39 \evensidemargin\oddsidemargin
40
41 \if@twoside
42 \advance\oddsidemargin .3in
43 \advance\evensidemargin -.3in
44 \fi
45
46 % No headers, 1in top margin
47 \topmargin 0pt
48 \headheight 0pt
49 \headsep 0pt
50
51 % Total bottom margin 1in, text height 9in
52 \textheight 9in
53 \footskip .625in
54
55 % Now adjust for different paper size:
56 \@tempdima=\paperheight
57 \advance\@tempdima-11in
58 \divide\@tempdima 2
59 \advance\topmargin \@tempdima
60
61 % Marginal notes always on left.
62 \marginparwidth 3.5cm
63 \marginparsep .5cm
64 \reversemarginpar
65
66
67 %%%%%%%%%%%%%%%%%%% MACROCODE PATCH FOR SHORT META %%%%%%%%%%%
68
69 \expandafter\def\expandafter\macrocode\expandafter{%
70 \expandafter\DeleteShortMeta
71 \macrocode}
72
73 %%%%%%%%%%%%%%%%%%%% DOC PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
74
75 \newbox\junkbox
76 \def\DocInput#1{%
77 \MakePercentIgnore
78 \setbox\junkbox=\hbox\bgroup
79 \input{#1}%
80 \MakePercentComment}
81 \let\EndDocPreamble\egroup
82
83 %%%%%%%%%%%%%%%%%%%%%%%%%%% VERBATIM %%%%%%%%%%%%%%%%%%%%%%%%%
84
85 % Use fancybox.sty's LVerbatim environment. Each line should contain
86 % percent plus three spaces (or other char), including blank lines. E.g.,
87 % \begin{LVerbatim}
88 % foo
89 % bar
90 % \end{LVerbatim}
91
92 \def\EveryVerbatimLine#1#2#3#4{}
93 \begingroup
94 \catcode`\%=12
95 \catcode`\ =\active
96 \global\EndVerbatimTokens{% }
97 \endgroup
98 \AltGetVerbatim
99
100
101 %%%%%%%%%%%%%%%%%% INDEXING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102
103 % Things are faster without \MakeIndex
104
105 \def\MakeIndex{\makeindex\EnableCrossrefs}
106 \DisableCrossrefs
107
108 % Use \codelabel[int]{foo} to label last line of code plus int.
109 % E.g., to label first and then last line of some code:
110 % \codelabel[1]{foo}
111 % \begin{macrocode}
112 % foo
113 % bar
114 % \end{macrocode}
115 % \codelabel{foo}
116
117 \def\codelabel{\@ifnextchar[{\@codelabel}{\@codelabel[0]}}
118 \def\@codelabel[#1]#2{%
119 \@bsphack
120 \begingroup
121 \advance\c@CodelineNo #1
122 \def\@currentlabel{\the\c@CodelineNo}%
123 \label{#2}%
124 \endgroup
125 \@esphack}
126
127 % Definitions in code are indexed by page number, but other occurences
128 % are indexed by the line of code.
129
130 \CodelineIndex
131 \def\SpecialMainPageIndex#1{%
132 {\let\special@index\index\SpecialMainIndex{#1}}}
133 \renewcommand{\theCodelineNo}{{\rm\tiny\arabic{CodelineNo}}}
134
135 % Index numbers for main definitions are set in bold rather than underlined.
136
137 \def\main#1{{\bf #1}}
138
139 % two column index
140
141 \setcounter{IndexColumns}{2}
142
143 % Customize index prologue:
144
145 \def\index@prologue{%
146 \section*{Index}\markboth{Index}{Index}%
147 \addcontentsline{toc}{section}{Index}%
148 The {\bf bold} numbers denote the pages where the entries are defined,
149 and all other numbers indicate the {\em lines of code} where
150 the entries are used.}
151
152
153 %%%%%%%%%%%%%%%%%%%%%%%%%% MACRO %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
154
155 % A change to the macro environment; prints macro names within the margins
156 % of the text, instead of as marginal notes. Use one \macro command,
157 % with comma separated macro names.
158
159 \newif\iffirst@macroname
160 \newif\ifnestedmacro
161
162 \def\macro{%
163 \ifnum\macro@level=\z@
164 \def\next{\MakePrivateLetters \m@cro@}%
165 \else
166 \def\next{\@latexerr{Nested \string\begin{macro}}\@eha
167 \endgroup\end{macro}\macro@level=\z@\begin{macro}}
168 \fi
169 \next}
170 \def\m@cro@#1{%
171 \first@macronametrue
172 \m@@cro@@#1,\@nil,}
173 \def\m@@cro@@#1,{%
174 \def\@tempa{#1}\def\@tempb{\@nil}%
175 \ifx\@tempa\@tempb
176 \let\next\finishm@@cro@@
177 \else
178 {\advance\c@CodelineNo\@ne\SpecialMainPageIndex{#1}\nobreak}%
179 \DoNotIndex{#1}%
180 \iffirst@macroname
181 \edef\saved@macronames{\string#1}%
182 \first@macronamefalse
183 \else
184 \def\comma{\noexpand\comma}%
185 \edef\saved@macronames{\saved@macronames\comma\string#1}%
186 \fi
187 \let\next\m@@cro@@
188 \fi
189 \next}
190 \def\finishm@@cro@@{%
191 \advance\macro@level\@ne
192 \def\comma{{\rm, }}%
193 \ListMacroNames{\saved@macronames}}
194
195 \let\endmacro\relax
196
197 \def\ListMacroNames{%
198 \@startsection{subsubsection}{3}{\z@}{-2.25ex plus -.5ex minus-.2ex}%
199 {1.3ex plus.2ex}{\csname reset@font\endcsname\large\tt}*}
200
201 \MacroIndent 0pt
202
203 \def\MacroFont{\small\tt}
204
205
206 %%%%%%%%%%%%%%%%%%%%% DoNot Index %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
207
208 \DoNotIndex{\ ,\!,\[,\\,\],\^,\`,\{,\},\~}
209 \DoNotIndex{\@warning,\active}
210 \DoNotIndex{\begingroup,\catcode,\char,\csname,\def,\do}
211 \DoNotIndex{\docdate,\dospecials,\edef,\else,\endcsname,\endgroup}
212 \DoNotIndex{\expandafter,\fi,\filedate,\fileversion}
213 \DoNotIndex{\gdef,\if,\ifcat}
214 \DoNotIndex{\ifx,\immediate,\lccode,\let}
215 \DoNotIndex{\lowercase,\next,\noexpand}
216 \DoNotIndex{\relax,\space,\the}
217 \DoNotIndex{\toks@,\typeout,\write}
218 \DoNotIndex{\@M,\@arabic,\@author,\@auxout,\@bsphack,\@car,\@date}
219 \DoNotIndex{\@dblarg,\@dblfloat,\@eha,\@empty,\@esphack,\@evenfoot}
220 \DoNotIndex{\@evenhead,\@float,\@gobble,\@gobbletwo,\@gtempa,\@ifnextchar}
221 \DoNotIndex{\@ifundefined,\@ixpt,\@latexerr,\@listI,\@listi,\@listii}
222 \DoNotIndex{\@listiii,\@listiv,\@listv,\@listvi,\@makefnmark,\@mkboth}
223 \DoNotIndex{\@namedef,\@nameuse,\@mne,\@nil,\@normalsize,\@oddfoot}
224 \DoNotIndex{\@oddhead,\@tempa,\@tempb,\@tempc,\@tempd}
225 \DoNotIndex{\@tempdima,\@testfalse,\@testtrue,\test@member}
226 \DoNotIndex{\@thanks,\@thefnmark,\@title}
227 \DoNotIndex{\@topnum,\@viiipt,\@viipt,\@vipt,\@vpt,\@xiipt}
228 \DoNotIndex{\@xipt,\@xpt,\@xivpt,\@xviipt,\@xxpt,\@xxvpt}
229 \DoNotIndex{\addcontentsline}
230 \DoNotIndex{\advance,\aftergroup,\baselinestretch,\begin}
231 \DoNotIndex{\belowdisplayshortskip,\belowdisplayskip,\bf,\bgroup}
232 \DoNotIndex{\box,\c@@page,\c@page,\c@secnumdepth,\clearpage,\columnsep}
233 \DoNotIndex{\columnwidth,\copy,\dimen@,\dimen@i,\dimen@ii,\divide}
234 \DoNotIndex{\dp,\ds@article,\ds@notes,\ds@notesonly}
235 \DoNotIndex{\ds@slidesonly,\egrou,\end,\end@dblfoloat,\end@float}
236 \DoNotIndex{\endinput,\fnsymbol,\footheight,\footnotesep,\footskip}
237 \DoNotIndex{\global,\globaldefs,\hbox,\headheight,\headsep,\hfil}
238 \DoNotIndex{\hrule,\hskip,\hss,\ht,\Huge,\huge}
239 \DoNotIndex{\if@filesw,\if@test,\if@twocolumn,\if@twoside}
240 \DoNotIndex{\ifcase,\ifdim,\ifvmode,\ignorespaces}
241 \DoNotIndex{\input,\interlinepenalty,\itemsep,\ixpt,\label}
242 \DoNotIndex{\labelsep,\labelwidth,\LARGE,\large,\Large}
243 \DoNotIndex{\leavevmode,\leftmargin,\leftmargini,\leftmarginii}
244 \DoNotIndex{\leftmarginiii,\leftmarginiv,\leftmarginv}
245 \DoNotIndex{\leftmarginvi,\leftmark,\leftskip,\lineskip}
246 \DoNotIndex{\magstep,\marginparsep,\marginparwidth,\markboth}
247 \DoNotIndex{\markright,\medbreak,\multiply,\newbox,\newcount}
248 \DoNotIndex{\newcounter,\newdimen,\newif,\newlabel,\newpage}
249 \DoNotIndex{\newtoks,\nobreak,\nointerlineskip,\normallineskip}
250 \DoNotIndex{\normalsize,\null,\number,\numberline,\oddsidemargin}
251 \DoNotIndex{\offinterlineskip,\or,\par,\parbox,\parskip,\partopsep}
252 \DoNotIndex{\prevdepth,\protect,\ref,\refstepcounter,\rightmrk}
253 \DoNotIndex{\rm,\scriptsize,\section,\sectionmark,\setbox,\setcounter}
254 \DoNotIndex{\sl,\small,\stepcounter,\string,\textheight,\textwidth}
255 \DoNotIndex{\thefootnote,\thepage,\thesection,\thesubsection}
256 \DoNotIndex{\thispagestyle,\tiny,\topmargin,\topsep,\uppercase}
257 \DoNotIndex{\vbox,\vfill,\viiipt,\viipt,\vipt,\vpt,\vskip,\vss}
258 \DoNotIndex{\wd,\xcommentloaded@,\xdef,\xiipt,\xipt,\xivpt,\xpt}
259 \DoNotIndex{\xviipt,\xxpt,\xxvpt,\z@}
260 \DoNotIndex{\abovedisplayskip,\abovedisplayshortskip,\@currentlabel}
261 \DoNotIndex{\@dottedtocline,\@ne\@setsize,\@starttoc,\@tempboxa,\@}
262 \DoNotIndex{\arraystretch,\centerline,\egroup,\end@dblfloat}
263 \DoNotIndex{\evensidemargin,\footnotesize,\ifnum,\parindent,\parsep}
264 \DoNotIndex{\rightmark,\@afterindenttrue,\@ne,\if@specialpage.\long}
265 \DoNotIndex{\fboxrule,\fboxsep,\@for,\vfil}
266 \DoNotIndex{\@@fortmp,\@@tempa,\@@tempb,\@ehd,\@for,\@fortmp,\@m}
267 \DoNotIndex{\@mparswitchfalse,\@mparswitchtrue,\@nnil,\@spaces}
268 \DoNotIndex{\@specialstyle,\@temptokena,\@twosidefalse,\@twosidetrue}
269 \DoNotIndex{\@whilenum,\alph,\arabic,\count@,\errhelp,\errmessage}
270 \DoNotIndex{\fbox,\index,\minipage,\newcommand,\overfullrule}
271 \DoNotIndex{\pagestyle,\raggedright,\ref@stepcounter,renewcommand}
272 \DoNotIndex{\semcolor@loaded,today,\@tempcnta,\@tempcntb,\trivlist,\t,\p}
273 \DoNotIndex{\today,\item,\@colht,\@currenvir,\@thefoot,\@thehead}
274 \DoNotIndex{\@totalleftmargin,\allowbreak,\@captype,\@footnotetext}
275 \DoNotIndex{\@listdepth,\@minipagefalse,\@minipagetrue,\@mpfn,\@mpfootins}
276 \DoNotIndex{\endtrivlist,\everypar,\hsize,\ifvoid,\lastskip}
277 \DoNotIndex{\linewidth,\skip,\thempfn,\thempfootnote,\topskip,\unvbox}
278 \DoNotIndex{\@@input,\@@par,\@acci,\@accii,\@acciii,\@cclv,\@height}
279 \DoNotIndex{\@maxdepth,\@tempdimb,\@tempg,\@temph,\@texttop,\@twocolumnfalse}
280 \DoNotIndex{\@xfloat,\addvspace,\alloc@,\bigskipamount,\botmark,\chardef}
281 \DoNotIndex{\closein,\closeout,\count,\countdef,\dimen,\glossary,\goodbreak}
282 \DoNotIndex{\insc@unt,\intextsep,\kern,\mag,\marginpar,\maxdepth,\medskip}
283 \DoNotIndex{\moveleft,\newinsert,\newskip,\onecolumn,\openin,\openout}
284 \DoNotIndex{\read,\renewcommand,\repeat,\rightskip,\strut,\vfuzz,\voffset}
285 \DoNotIndex{\vsize}
286
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288
289 \endinput
290
291 %% END tvz-code.sty