blob: 22d7ad46cf270abb5e88e2cf7bca10bda8244996 [file] [log] [blame]
Guido van Rossum643d9321992-03-31 18:53:47 +00001% Style parameters and macros used by most documents here
Guido van Rossum515834a1991-01-22 11:45:29 +00002
Guido van Rossumec24f1f1992-04-06 14:02:23 +00003\input{a4wide.sty} % Take this out if it doesn't exist or doesn't work
4
Guido van Rossum643d9321992-03-31 18:53:47 +00005% This has to be tuned each time the repair person takes the printer apart:
6\addtolength{\oddsidemargin}{-2.5mm}
7\addtolength{\evensidemargin}{-2.5mm}
Guido van Rossum515834a1991-01-22 11:45:29 +00008
Guido van Rossum5badc751992-03-06 10:55:46 +00009% Style parameters
10\raggedbottom
11\sloppy
12\parindent = 0mm
13\parskip = 2mm
14
Guido van Rossum4c22cb21991-01-25 13:28:15 +000015% Variable used by begin code command
Guido van Rossum44000ed1991-01-24 16:54:29 +000016\newlength{\codewidth}
Guido van Rossum44000ed1991-01-24 16:54:29 +000017
Guido van Rossum5badc751992-03-06 10:55:46 +000018% Command to start a code block (follow this by \begin{verbatim})
Guido van Rossum4c22cb21991-01-25 13:28:15 +000019\newcommand{\bcode}{
20 % Calculate the text width for the minipage:
21 \setlength{\codewidth}{\linewidth}
22 \addtolength{\codewidth}{-\parindent}
23 %
Guido van Rossum4c22cb21991-01-25 13:28:15 +000024 \par
Guido van Rossum92fba021991-11-12 15:44:51 +000025 \vspace{3mm}
Guido van Rossum4c22cb21991-01-25 13:28:15 +000026 \indent
27 \begin{minipage}[t]{\codewidth}
28}
29
Guido van Rossum5badc751992-03-06 10:55:46 +000030% Command to end a code block (precede this by \end{verbatim})
Guido van Rossum4c22cb21991-01-25 13:28:15 +000031\newcommand{\ecode}{
32 \end{minipage}
33 \vspace{3mm}
34 \par
35 \noindent
36}
Guido van Rossum5badc751992-03-06 10:55:46 +000037
Guido van Rossumb7fc4af1992-08-07 16:06:42 +000038% Underscores are not magic throughout the Python documentation.
39% This still only gives the right effect in the tt font!!!
Guido van Rossum95cd2ef1992-12-08 14:37:55 +000040\def\_{\ifnum\fam=\ttfam \char'137\else{\tt\char'137}\fi}
41\catcode`\_=12
42\catcode`\_=\active\def_{\ifnum\fam=\ttfam \char'137 \else{\tt\char'137}\fi}
Guido van Rossum5badc751992-03-06 10:55:46 +000043
Guido van Rossum5badc751992-03-06 10:55:46 +000044% Define \itembreak: force the text after an item to start on a new line
45\newcommand{\itembreak}{
46\mbox{}
47\\*[0mm]
48}
49
50% Command to generate two index entries (using subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +000051\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
Guido van Rossum5badc751992-03-06 10:55:46 +000052
53% And three entries (using only one level of subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +000054\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
Guido van Rossum5badc751992-03-06 10:55:46 +000055
56% And four (again, using only one level of subentries)
57\newcommand{\indexiv}[4]{
58\index{#1!#2 #3 #4}
59\index{#2!#3 #4, #1}
60\index{#3!#4, #1 #2}
61\index{#4!#1 #2 #3}
62}
63
64% Command to generate a reference to a function, statement, keyword, operator
65\newcommand{\stindex}[1]{\indexii{statement}{#1@{\tt#1}}}
66\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\tt#1}}}
67\newcommand{\opindex}[1]{\indexii{operator}{#1@{\tt#1}}}
Guido van Rossum6886c831992-04-03 14:44:27 +000068\newcommand{\exindex}[1]{\indexii{exception}{#1@{\tt#1}}}
69\newcommand{\obindex}[1]{\indexii{object}{#1}}
Guido van Rossum5badc751992-03-06 10:55:46 +000070\newcommand{\bifuncindex}[1]{\index{#1@{\tt#1} (built-in function)}}
71
72% Add an index entry for a module
73\newcommand{\modindex}[2]{\index{#1@{\tt#1} (#2module)}}
74\newcommand{\bimodindex}[1]{\modindex{#1}{built-in }}
75\newcommand{\stmodindex}[1]{\modindex{#1}{standard }}
76
77% Additional string for an index entry
78\newcommand{\indexsubitem}{}
79\newcommand{\ttindex}[1]{\index{#1@{\tt#1} \indexsubitem}}
80
81% Define \itemjoin: some negative vspace to join two items together
82\newcommand{\itemjoin}{
83\mbox{}
84\vspace{-\itemsep}
85\vspace{-\parsep}
86}
87
88% Define \funcitem{func}{args}: define a function item
Guido van Rossum95cd2ef1992-12-08 14:37:55 +000089\newcommand{\funcitem}[2]{%
90\ttindex{#1}%
91%\item[{\tt #1(#2)}]
92\item[\code{#1(\varvars{#2})}]
Guido van Rossum5badc751992-03-06 10:55:46 +000093\
94}
95
Guido van Rossum95cd2ef1992-12-08 14:37:55 +000096
97% from user-level, fulllineitems should be called as an environment
98\def\fulllineitems{\list{}{\labelwidth \leftmargin \labelsep 0pt
99\rightmargin 0pt \topsep -\parskip \partopsep \parskip
100\itemsep -\parsep
101\let\makelabel\itemnewline}}
102\let\endfulllineitems\endlist
103
104
105% funcdesc should be called as an \begin{funcdesc} ... \end{funcdesc}
106\newcommand{\funcline}[2]{\item[\code{#1(\varvars{#2})}]\ttindex{#1}}
107\newcommand{\funcdesc}[2]{\fulllineitems\funcline{#1}{#2}}
108\let\endfuncdesc\endfulllineitems
Guido van Rossum16d6e711994-08-08 12:30:22 +0000109\newcommand{\optional}[1]{{\ \Large[}{#1}\hspace{0.5mm}{\Large]}\ }
110
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000111
112% same for excdesc
113\newcommand{\excline}[1]{\item[\code{#1}]\ttindex{#1}}
114\newcommand{\excdesc}[1]{\fulllineitems\excline{#1}}
115\let\endexcdesc\endfulllineitems
116
117% same for datadesc
118\newcommand{\dataline}[1]{\item[\code{#1}]\ttindex{#1}}
119\newcommand{\datadesc}[1]{\fulllineitems\dataline{#1}}
120\let\enddatadesc\endfulllineitems
121
122
Guido van Rossum5badc751992-03-06 10:55:46 +0000123% Define \dataitem{name}: define a data item
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000124\newcommand{\dataitem}[1]{%
125\ttindex{#1}%
Guido van Rossum5badc751992-03-06 10:55:46 +0000126\item[{\tt #1}]
127\
128}
129
130% Define \excitem{name}: define an exception item
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000131\newcommand{\excitem}[1]{%
132\ttindex{#1}%
Guido van Rossum5badc751992-03-06 10:55:46 +0000133\item[{\tt #1}]
134\itembreak
135}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000136
137\let\nodename=\label
138
139\newcommand{\ABC}{{\sc abc}}
140\newcommand{\UNIX}{{\sc Unix}}
141\newcommand{\ASCII}{{\sc ascii}}
142%\newcommand{\C}{{\bf C}}
Guido van Rossum16d6e711994-08-08 12:30:22 +0000143\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000144\newcommand{\C}{C}
145\newcommand{\EOF}{{\sc eof}}
146
147% code is the most difficult one...
148%\frenchspacing removed, because \section, etc., can't handle it
149\newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}%
150\mbox{\tt #1}}}
151%This one does not work
152%%%% myspecials, same as dospecials, but without {, } and \
153%%%\def\myspecials{\do\ \do\$\do\&%
154%%% \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~}
155%%%\newcommand{\code}[1]{\begingroup \catcode``=13 \@noligs
156%%%\tt \let\do\@makeother \myspecials
157%%%#1\endgroup}
158\newcommand{\kbd}[1]{\mbox{\tt #1}}
159\newcommand{\key}[1]{\mbox{\tt #1}}
160\newcommand{\samp}[1]{\mbox{`\code{#1}'}}
161\newcommand{\var}[1]{\mbox{\it#1\/}}
162\let\file=\samp
163\newcommand{\dfn}[1]{{\sl #1\/}}
164\newcommand{\emph}[1]{{\em #1\/}}
165\newcommand{\strong}[1]{{\bf #1}}
166
167%\newcommand{\varvars}[1]{{\catcode`\,=\active\def,{\tt\char`\,\/tt}\var{#1}}}
168%\newcommand{\varvars}[1]{{\def\,{\/{\tt\char`\,}}\var{#1}}}
169\newcommand{\varvars}[1]{{\def\,{\/{\tt\char`\,}}\def\({\/{\tt\char`\(}}\def\){\/{\tt\char`\)}}\var{#1}}}
170
171\newif\iftexi\texifalse
172%not supported yet%\newif\iflatex\latextrue
173
Guido van Rossume7af5a01994-08-01 12:39:35 +0000174\newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3&#4\\
175\hline}{\hline\end{tabular}\end{center}}
176
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000177\newenvironment{tableiii}[5]{\begin{center}\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}\begin{tabular}{#1}\hline#3&#4&#5\\
178\hline}{\hline\end{tabular}\end{center}}
179
180\newcommand{\itemnewline}[1]{\@tempdima\linewidth
181\advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}}
182
183\newcommand{\sectcode}[1]{{\tt #1}}
184%%%
185%%%\let\orgchapter\chapter
186%%%\def\chapter#1{{\let\code\sectcode\orgchapter{#1}}}
187%%%\let\orgsection\section
188%%%\def\section#1{{\let\code\sectcode\orgsection{#1}}}
189%%%\let\orgsubsection\subsection
190%%%\def\subsection#1{{\let\code\sectcode\orgsubsection{#1}}}
191%%%\let\orgsubsubsection\subsubsection
192%%%\def\subsubsection#1{{\let\code\sectcode\orgsubsubsection{#1}}}
193%%%\let\orgsubsubsubsection\subsubsubsection
194%%%\def\subsubsubsection#1{{\let\code\sectcode\orgsubsubsubsection{#1}}}
195