blob: f1779cb445c55e62442ce30fac2ea2fe24c80bdc [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
Guido van Rossumadb6bf61995-03-28 13:32:57 +00004\input{times.sty} % And this (at CWI, this uses PostScript fonts)
Guido van Rossumec24f1f1992-04-06 14:02:23 +00005
Guido van Rossum643d9321992-03-31 18:53:47 +00006% This has to be tuned each time the repair person takes the printer apart:
Guido van Rossumadb6bf61995-03-28 13:32:57 +00007%\addtolength{\oddsidemargin}{-2.5mm}
8%\addtolength{\evensidemargin}{-2.5mm}
Guido van Rossum515834a1991-01-22 11:45:29 +00009
Guido van Rossum5badc751992-03-06 10:55:46 +000010% Style parameters
11\raggedbottom
12\sloppy
13\parindent = 0mm
14\parskip = 2mm
15
Guido van Rossum4c22cb21991-01-25 13:28:15 +000016% Variable used by begin code command
Guido van Rossum44000ed1991-01-24 16:54:29 +000017\newlength{\codewidth}
Guido van Rossum44000ed1991-01-24 16:54:29 +000018
Guido van Rossum5badc751992-03-06 10:55:46 +000019% Command to start a code block (follow this by \begin{verbatim})
Guido van Rossum4c22cb21991-01-25 13:28:15 +000020\newcommand{\bcode}{
21 % Calculate the text width for the minipage:
22 \setlength{\codewidth}{\linewidth}
23 \addtolength{\codewidth}{-\parindent}
24 %
Guido van Rossum4c22cb21991-01-25 13:28:15 +000025 \par
Guido van Rossum92fba021991-11-12 15:44:51 +000026 \vspace{3mm}
Guido van Rossum4c22cb21991-01-25 13:28:15 +000027 \indent
28 \begin{minipage}[t]{\codewidth}
29}
30
Guido van Rossum5badc751992-03-06 10:55:46 +000031% Command to end a code block (precede this by \end{verbatim})
Guido van Rossum4c22cb21991-01-25 13:28:15 +000032\newcommand{\ecode}{
33 \end{minipage}
34 \vspace{3mm}
35 \par
36 \noindent
37}
Guido van Rossum5badc751992-03-06 10:55:46 +000038
Guido van Rossumb7fc4af1992-08-07 16:06:42 +000039% Underscores are not magic throughout the Python documentation.
40% This still only gives the right effect in the tt font!!!
Guido van Rossum95cd2ef1992-12-08 14:37:55 +000041\def\_{\ifnum\fam=\ttfam \char'137\else{\tt\char'137}\fi}
42\catcode`\_=12
43\catcode`\_=\active\def_{\ifnum\fam=\ttfam \char'137 \else{\tt\char'137}\fi}
Guido van Rossum5badc751992-03-06 10:55:46 +000044
Guido van Rossum5badc751992-03-06 10:55:46 +000045% Define \itembreak: force the text after an item to start on a new line
46\newcommand{\itembreak}{
47\mbox{}
48\\*[0mm]
49}
50
51% Command to generate two index entries (using subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +000052\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
Guido van Rossum5badc751992-03-06 10:55:46 +000053
54% And three entries (using only one level of subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +000055\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
Guido van Rossum5badc751992-03-06 10:55:46 +000056
57% And four (again, using only one level of subentries)
58\newcommand{\indexiv}[4]{
59\index{#1!#2 #3 #4}
60\index{#2!#3 #4, #1}
61\index{#3!#4, #1 #2}
62\index{#4!#1 #2 #3}
63}
64
65% Command to generate a reference to a function, statement, keyword, operator
66\newcommand{\stindex}[1]{\indexii{statement}{#1@{\tt#1}}}
67\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\tt#1}}}
68\newcommand{\opindex}[1]{\indexii{operator}{#1@{\tt#1}}}
Guido van Rossum6886c831992-04-03 14:44:27 +000069\newcommand{\exindex}[1]{\indexii{exception}{#1@{\tt#1}}}
70\newcommand{\obindex}[1]{\indexii{object}{#1}}
Guido van Rossum5badc751992-03-06 10:55:46 +000071\newcommand{\bifuncindex}[1]{\index{#1@{\tt#1} (built-in function)}}
72
73% Add an index entry for a module
74\newcommand{\modindex}[2]{\index{#1@{\tt#1} (#2module)}}
75\newcommand{\bimodindex}[1]{\modindex{#1}{built-in }}
76\newcommand{\stmodindex}[1]{\modindex{#1}{standard }}
77
78% Additional string for an index entry
79\newcommand{\indexsubitem}{}
80\newcommand{\ttindex}[1]{\index{#1@{\tt#1} \indexsubitem}}
81
82% Define \itemjoin: some negative vspace to join two items together
83\newcommand{\itemjoin}{
84\mbox{}
85\vspace{-\itemsep}
86\vspace{-\parsep}
87}
88
89% Define \funcitem{func}{args}: define a function item
Guido van Rossum95cd2ef1992-12-08 14:37:55 +000090\newcommand{\funcitem}[2]{%
91\ttindex{#1}%
92%\item[{\tt #1(#2)}]
93\item[\code{#1(\varvars{#2})}]
Guido van Rossum5badc751992-03-06 10:55:46 +000094\
95}
96
Guido van Rossum95cd2ef1992-12-08 14:37:55 +000097
98% from user-level, fulllineitems should be called as an environment
99\def\fulllineitems{\list{}{\labelwidth \leftmargin \labelsep 0pt
100\rightmargin 0pt \topsep -\parskip \partopsep \parskip
101\itemsep -\parsep
102\let\makelabel\itemnewline}}
103\let\endfulllineitems\endlist
104
105
106% funcdesc should be called as an \begin{funcdesc} ... \end{funcdesc}
107\newcommand{\funcline}[2]{\item[\code{#1(\varvars{#2})}]\ttindex{#1}}
108\newcommand{\funcdesc}[2]{\fulllineitems\funcline{#1}{#2}}
109\let\endfuncdesc\endfulllineitems
Guido van Rossum16d6e711994-08-08 12:30:22 +0000110\newcommand{\optional}[1]{{\ \Large[}{#1}\hspace{0.5mm}{\Large]}\ }
111
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000112
113% same for excdesc
114\newcommand{\excline}[1]{\item[\code{#1}]\ttindex{#1}}
115\newcommand{\excdesc}[1]{\fulllineitems\excline{#1}}
116\let\endexcdesc\endfulllineitems
117
118% same for datadesc
119\newcommand{\dataline}[1]{\item[\code{#1}]\ttindex{#1}}
120\newcommand{\datadesc}[1]{\fulllineitems\dataline{#1}}
121\let\enddatadesc\endfulllineitems
122
123
Guido van Rossum5badc751992-03-06 10:55:46 +0000124% Define \dataitem{name}: define a data item
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000125\newcommand{\dataitem}[1]{%
126\ttindex{#1}%
Guido van Rossum5badc751992-03-06 10:55:46 +0000127\item[{\tt #1}]
128\
129}
130
131% Define \excitem{name}: define an exception item
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000132\newcommand{\excitem}[1]{%
133\ttindex{#1}%
Guido van Rossum5badc751992-03-06 10:55:46 +0000134\item[{\tt #1}]
135\itembreak
136}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000137
138\let\nodename=\label
139
140\newcommand{\ABC}{{\sc abc}}
141\newcommand{\UNIX}{{\sc Unix}}
142\newcommand{\ASCII}{{\sc ascii}}
143%\newcommand{\C}{{\bf C}}
Guido van Rossum16d6e711994-08-08 12:30:22 +0000144\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000145\newcommand{\C}{C}
146\newcommand{\EOF}{{\sc eof}}
147
148% code is the most difficult one...
149%\frenchspacing removed, because \section, etc., can't handle it
150\newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}%
151\mbox{\tt #1}}}
152%This one does not work
153%%%% myspecials, same as dospecials, but without {, } and \
154%%%\def\myspecials{\do\ \do\$\do\&%
155%%% \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~}
156%%%\newcommand{\code}[1]{\begingroup \catcode``=13 \@noligs
157%%%\tt \let\do\@makeother \myspecials
158%%%#1\endgroup}
159\newcommand{\kbd}[1]{\mbox{\tt #1}}
160\newcommand{\key}[1]{\mbox{\tt #1}}
161\newcommand{\samp}[1]{\mbox{`\code{#1}'}}
162\newcommand{\var}[1]{\mbox{\it#1\/}}
163\let\file=\samp
Guido van Rossum45416021995-03-30 16:00:58 +0000164\newcommand{\dfn}[1]{{\em #1\/}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000165\newcommand{\emph}[1]{{\em #1\/}}
166\newcommand{\strong}[1]{{\bf #1}}
167
168%\newcommand{\varvars}[1]{{\catcode`\,=\active\def,{\tt\char`\,\/tt}\var{#1}}}
169%\newcommand{\varvars}[1]{{\def\,{\/{\tt\char`\,}}\var{#1}}}
170\newcommand{\varvars}[1]{{\def\,{\/{\tt\char`\,}}\def\({\/{\tt\char`\(}}\def\){\/{\tt\char`\)}}\var{#1}}}
171
172\newif\iftexi\texifalse
173%not supported yet%\newif\iflatex\latextrue
174
Guido van Rossume7af5a01994-08-01 12:39:35 +0000175\newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3&#4\\
176\hline}{\hline\end{tabular}\end{center}}
177
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000178\newenvironment{tableiii}[5]{\begin{center}\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}\begin{tabular}{#1}\hline#3&#4&#5\\
179\hline}{\hline\end{tabular}\end{center}}
180
181\newcommand{\itemnewline}[1]{\@tempdima\linewidth
182\advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}}
183
184\newcommand{\sectcode}[1]{{\tt #1}}
185%%%
186%%%\let\orgchapter\chapter
187%%%\def\chapter#1{{\let\code\sectcode\orgchapter{#1}}}
188%%%\let\orgsection\section
189%%%\def\section#1{{\let\code\sectcode\orgsection{#1}}}
190%%%\let\orgsubsection\subsection
191%%%\def\subsection#1{{\let\code\sectcode\orgsubsection{#1}}}
192%%%\let\orgsubsubsection\subsubsection
193%%%\def\subsubsection#1{{\let\code\sectcode\orgsubsubsection{#1}}}
194%%%\let\orgsubsubsubsection\subsubsubsection
195%%%\def\subsubsubsection#1{{\let\code\sectcode\orgsubsubsubsection{#1}}}
196