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 |
| 4 | |
Guido van Rossum | 643d932 | 1992-03-31 18:53:47 +0000 | [diff] [blame] | 5 | % 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 Rossum | 515834a | 1991-01-22 11:45:29 +0000 | [diff] [blame] | 8 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 9 | % Style parameters |
| 10 | \raggedbottom |
| 11 | \sloppy |
| 12 | \parindent = 0mm |
| 13 | \parskip = 2mm |
| 14 | |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 15 | % Variable used by begin code command |
Guido van Rossum | 44000ed | 1991-01-24 16:54:29 +0000 | [diff] [blame] | 16 | \newlength{\codewidth} |
Guido van Rossum | 44000ed | 1991-01-24 16:54:29 +0000 | [diff] [blame] | 17 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 18 | % Command to start a code block (follow this by \begin{verbatim}) |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 19 | \newcommand{\bcode}{ |
| 20 | % Calculate the text width for the minipage: |
| 21 | \setlength{\codewidth}{\linewidth} |
| 22 | \addtolength{\codewidth}{-\parindent} |
| 23 | % |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 24 | \par |
Guido van Rossum | 92fba02 | 1991-11-12 15:44:51 +0000 | [diff] [blame] | 25 | \vspace{3mm} |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 26 | \indent |
| 27 | \begin{minipage}[t]{\codewidth} |
| 28 | } |
| 29 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 30 | % Command to end a code block (precede this by \end{verbatim}) |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 31 | \newcommand{\ecode}{ |
| 32 | \end{minipage} |
| 33 | \vspace{3mm} |
| 34 | \par |
| 35 | \noindent |
| 36 | } |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 37 | |
Guido van Rossum | b7fc4af | 1992-08-07 16:06:42 +0000 | [diff] [blame] | 38 | % Underscores are not magic throughout the Python documentation. |
| 39 | % This still only gives the right effect in the tt font!!! |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 40 | \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 Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 43 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 44 | % 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 Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame^] | 51 | \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 52 | |
| 53 | % And three entries (using only one level of subentries) |
Guido van Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame^] | 54 | \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] | 55 | |
| 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 Rossum | 6886c83 | 1992-04-03 14:44:27 +0000 | [diff] [blame] | 68 | \newcommand{\exindex}[1]{\indexii{exception}{#1@{\tt#1}}} |
| 69 | \newcommand{\obindex}[1]{\indexii{object}{#1}} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 70 | \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 Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 89 | \newcommand{\funcitem}[2]{% |
| 90 | \ttindex{#1}% |
| 91 | %\item[{\tt #1(#2)}] |
| 92 | \item[\code{#1(\varvars{#2})}] |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 93 | \ |
| 94 | } |
| 95 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 96 | |
| 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 Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame^] | 109 | \newcommand{\optional}[1]{{\ \Large[}{#1}\hspace{0.5mm}{\Large]}\ } |
| 110 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 111 | |
| 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 Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 123 | % Define \dataitem{name}: define a data item |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 124 | \newcommand{\dataitem}[1]{% |
| 125 | \ttindex{#1}% |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 126 | \item[{\tt #1}] |
| 127 | \ |
| 128 | } |
| 129 | |
| 130 | % Define \excitem{name}: define an exception item |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 131 | \newcommand{\excitem}[1]{% |
| 132 | \ttindex{#1}% |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 133 | \item[{\tt #1}] |
| 134 | \itembreak |
| 135 | } |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 136 | |
| 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 Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame^] | 143 | \newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}} |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 144 | \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 Rossum | e7af5a0 | 1994-08-01 12:39:35 +0000 | [diff] [blame] | 174 | \newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3\\ |
| 175 | \hline}{\hline\end{tabular}\end{center}} |
| 176 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 177 | \newenvironment{tableiii}[5]{\begin{center}\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}\begin{tabular}{#1}\hline#3\\ |
| 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 | |