Guido van Rossum | 643d932 | 1992-03-31 18:53:47 +0000 | [diff] [blame] | 1 | % Style parameters and macros used by most documents here |
Guido van Rossum | 515834a | 1991-01-22 11:45:29 +0000 | [diff] [blame] | 2 | |
Guido van Rossum | ec24f1f | 1992-04-06 14:02:23 +0000 | [diff] [blame] | 3 | \input{a4wide.sty} % Take this out if it doesn't exist or doesn't work |
Guido van Rossum | adb6bf6 | 1995-03-28 13:32:57 +0000 | [diff] [blame] | 4 | \input{times.sty} % And this (at CWI, this uses PostScript fonts) |
Guido van Rossum | ec24f1f | 1992-04-06 14:02:23 +0000 | [diff] [blame] | 5 | |
Guido van Rossum | 643d932 | 1992-03-31 18:53:47 +0000 | [diff] [blame] | 6 | % This has to be tuned each time the repair person takes the printer apart: |
Guido van Rossum | adb6bf6 | 1995-03-28 13:32:57 +0000 | [diff] [blame] | 7 | %\addtolength{\oddsidemargin}{-2.5mm} |
| 8 | %\addtolength{\evensidemargin}{-2.5mm} |
Guido van Rossum | 515834a | 1991-01-22 11:45:29 +0000 | [diff] [blame] | 9 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 10 | % Style parameters |
| 11 | \raggedbottom |
| 12 | \sloppy |
| 13 | \parindent = 0mm |
| 14 | \parskip = 2mm |
| 15 | |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 16 | % Variable used by begin code command |
Guido van Rossum | 44000ed | 1991-01-24 16:54:29 +0000 | [diff] [blame] | 17 | \newlength{\codewidth} |
Guido van Rossum | 44000ed | 1991-01-24 16:54:29 +0000 | [diff] [blame] | 18 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 19 | % Command to start a code block (follow this by \begin{verbatim}) |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 20 | \newcommand{\bcode}{ |
| 21 | % Calculate the text width for the minipage: |
| 22 | \setlength{\codewidth}{\linewidth} |
| 23 | \addtolength{\codewidth}{-\parindent} |
| 24 | % |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 25 | \par |
Guido van Rossum | 92fba02 | 1991-11-12 15:44:51 +0000 | [diff] [blame] | 26 | \vspace{3mm} |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 27 | \indent |
| 28 | \begin{minipage}[t]{\codewidth} |
| 29 | } |
| 30 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 31 | % Command to end a code block (precede this by \end{verbatim}) |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 32 | \newcommand{\ecode}{ |
| 33 | \end{minipage} |
| 34 | \vspace{3mm} |
| 35 | \par |
| 36 | \noindent |
| 37 | } |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 38 | |
Guido van Rossum | b7fc4af | 1992-08-07 16:06:42 +0000 | [diff] [blame] | 39 | % Underscores are not magic throughout the Python documentation. |
| 40 | % This still only gives the right effect in the tt font!!! |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 41 | \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 Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 44 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 45 | % 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 Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame] | 52 | \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 53 | |
| 54 | % And three entries (using only one level of subentries) |
Guido van Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame] | 55 | \newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 56 | |
| 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 Rossum | 6886c83 | 1992-04-03 14:44:27 +0000 | [diff] [blame] | 69 | \newcommand{\exindex}[1]{\indexii{exception}{#1@{\tt#1}}} |
| 70 | \newcommand{\obindex}[1]{\indexii{object}{#1}} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 71 | \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 Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 90 | \newcommand{\funcitem}[2]{% |
| 91 | \ttindex{#1}% |
| 92 | %\item[{\tt #1(#2)}] |
| 93 | \item[\code{#1(\varvars{#2})}] |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 94 | \ |
| 95 | } |
| 96 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 97 | |
| 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 Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame] | 110 | \newcommand{\optional}[1]{{\ \Large[}{#1}\hspace{0.5mm}{\Large]}\ } |
| 111 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 112 | |
| 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 Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 124 | % Define \dataitem{name}: define a data item |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 125 | \newcommand{\dataitem}[1]{% |
| 126 | \ttindex{#1}% |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 127 | \item[{\tt #1}] |
| 128 | \ |
| 129 | } |
| 130 | |
| 131 | % Define \excitem{name}: define an exception item |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 132 | \newcommand{\excitem}[1]{% |
| 133 | \ttindex{#1}% |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 134 | \item[{\tt #1}] |
| 135 | \itembreak |
| 136 | } |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 137 | |
| 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 Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame] | 144 | \newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}} |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 145 | \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 Rossum | 4541602 | 1995-03-30 16:00:58 +0000 | [diff] [blame] | 164 | \newcommand{\dfn}[1]{{\em #1\/}} |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 165 | \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 Rossum | e7af5a0 | 1994-08-01 12:39:35 +0000 | [diff] [blame] | 175 | \newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3\\ |
| 176 | \hline}{\hline\end{tabular}\end{center}} |
| 177 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 178 | \newenvironment{tableiii}[5]{\begin{center}\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}\begin{tabular}{#1}\hline#3\\ |
| 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 | |