Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc8af0a

Browse files
committed
Lots of stuff:
Handle most (all?) of the page style / numbering magic here so the documents don't have to do it individually. Revise the \bcode / \ecode stuff so that the {verbatim} environment handles it right directly. \bcode / \ecode will be completely removed from all files (to be checked in momentarily). Have the {verbatim} environment get the samples indented a bit; this appearantly had been attempted in the old code, but didn't work because paragraphs weren't indented. Make all headers, from chapters on down to subparagraphs, have sans-serif titles. \setindexsubitem{}: New macro. Replaces \renewcommand{\indexsubitem{}(...)} everywhere. This allows LaTeX2HTML to be made to work correctly for this. That was near impossible with the old mechanisms. For all {*desc} environments, make the name of the described thing bold as well as monospaced. {opcodedesc} environment: Don't index the byte code names; that doesn't seem terribly useful, and there are a lot of them. \var{}: More magic to make sure that the size is right even if embedded in \file{} or some other macro that uses the sans-serif font in running text. \bfcode{}: New macro. Makes the font \code{} and bold. (Was unreasonable using old LaTeX 2.09.) \file{}: Adjust the size of the sans-serif font a little. \email{}, \url{}, Make these use the same font as \file{}, but not the surrounding single-quotes. Update many comments. Lots of minor nits and a little cleanliness.
1 parent cffaebb commit dc8af0a

1 file changed

Lines changed: 126 additions & 71 deletions

File tree

Doc/myformat.sty

Lines changed: 126 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
\parindent = 0mm
2727
\parskip = 2mm
2828

29+
\pagestyle{empty} % start this way; change for
30+
\pagenumbering{roman} % ToC & chapters
31+
\setcounter{secnumdepth}{1}
32+
2933
% old code font selections:
3034
\let\codefont=\tt
3135
\let\sectcodefont=\tt
@@ -36,26 +40,59 @@
3640
% Variable used by begin code command
3741
\newlength{\codewidth}
3842

43+
\newcommand{\examplevspace}{2mm}
44+
\newcommand{\exampleindent}{1cm}
3945
% Command to start a code block (follow this by \begin{verbatim})
40-
\newcommand{\bcode}{
41-
% Calculate the text width for the minipage:
42-
\setlength{\codewidth}{\linewidth}
43-
\addtolength{\codewidth}{-\parindent}
44-
%
45-
\par
46-
\vspace{3mm}
47-
\indent
48-
\begin{minipage}[t]{\codewidth}
46+
\newcommand{\b@code}{%
47+
\begingroup%
48+
\setlength{\parindent}\exampleindent%
49+
% Calculate the text width for the minipage:
50+
\setlength{\codewidth}{\linewidth}%
51+
\addtolength{\codewidth}{-\parindent}%
52+
%
53+
\par%
54+
\vspace\examplevspace%
55+
\indent%
56+
\begin{minipage}[t]{\codewidth}%
57+
\small%
4958
}
5059

5160
% Command to end a code block (precede this by \end{verbatim})
52-
\newcommand{\ecode}{
53-
\end{minipage}
54-
\vspace{3mm}
55-
\par
56-
\noindent
61+
\newcommand{\e@code}{%
62+
\end{minipage}%
63+
\endgroup%
5764
}
5865

66+
\let\OldVerbatim=\verbatim
67+
\let\OldEndVerbatim=\endverbatim
68+
\renewcommand{\verbatim}{\b@code\OldVerbatim}
69+
\renewcommand{\endverbatim}{\OldEndVerbatim\e@code}
70+
71+
% Augment the sectioning commands used to get our own font family in
72+
% place:
73+
\newcommand{\HeaderFamily}{\sffamily}
74+
\renewcommand{\section}{\@startsection {section}{1}{\z@}%
75+
{-3.5ex \@plus -1ex \@minus -.2ex}%
76+
{2.3ex \@plus.2ex}%
77+
{\reset@font\Large\HeaderFamily}}
78+
\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
79+
{-3.25ex\@plus -1ex \@minus -.2ex}%
80+
{1.5ex \@plus .2ex}%
81+
{\reset@font\large\HeaderFamily}}
82+
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
83+
{-3.25ex\@plus -1ex \@minus -.2ex}%
84+
{1.5ex \@plus .2ex}%
85+
{\reset@font\normalsize\HeaderFamily}}
86+
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
87+
{3.25ex \@plus1ex \@minus.2ex}%
88+
{-1em}%
89+
{\reset@font\normalsize\HeaderFamily}}
90+
\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
91+
{3.25ex \@plus1ex \@minus .2ex}%
92+
{-1em}%
93+
{\reset@font\normalsize\HeaderFamily}}
94+
95+
5996
% Underscore hack (only act like subscript operator if in math mode)
6097
%
6198
% The following is due to Mark Wooding (the old version didn't work with
@@ -72,20 +109,23 @@
72109
\expandafter\endgroup\next
73110

74111
%
75-
% This is the old hack, which didn't work with 2e.
76-
% If you're still using Latex 2.09, you can give it a try if the above fails.
112+
% This is the old hack, which didn't work with 2e.
113+
% You should not need this since the rest of the documentation is now
114+
% LaTeX2e-only.
77115
%
78116
%\def\_{\ifnum\fam=\ttfamily \char'137\else{\tt\char'137}\fi}
79117
%\catcode`\_=12
80118
%\catcode`\_=\active\def_{\ifnum\fam=\ttfamily \char'137 \else{\tt\char'137}\fi}
81119

82120

121+
83122
%% Lots of index-entry generation support.
84123

85-
% Command to wrap around stuff that refers to function/module/attribute names
86-
% in the index. Default behavior: like \code{}. To just keep the index
87-
% entries in the roman font, uncomment the second definition to use instead;
88-
% it matches O'Reilly style more.
124+
% Command to wrap around stuff that refers to function / module /
125+
% attribute names in the index. Default behavior: like \code{}. To
126+
% just keep the index entries in the roman font, uncomment the second
127+
% definition to use instead; it matches O'Reilly style more.
128+
%
89129
\newcommand{\idxcode}[1]{\codefont{#1}}
90130
%\renewcommand{\idxcode}[1]{#1}
91131

@@ -103,7 +143,8 @@
103143
\index{#4!#1 #2 #3}
104144
}
105145

106-
% Command to generate a reference to a function, statement, keyword, operator
146+
% Command to generate a reference to a function, statement, keyword,
147+
% operator.
107148
\newcommand{\stindex}[1]{\indexii{statement}{#1@{\idxcode{#1}}}}
108149
\newcommand{\opindex}[1]{\indexii{operator}{#1@{\idxcode{#1}}}}
109150
\newcommand{\exindex}[1]{\indexii{exception}{#1@{\idxcode{#1}}}}
@@ -129,9 +170,9 @@
129170
\newcommand{\stmodindex}[1]{\defmodindex{#1}{standard }}
130171

131172
% Additional string for an index entry
132-
\newcommand{\indexsubitem}{}
133-
\newcommand{\setindexsubitem}[1]{\renewcommand{\indexsubitem}{#1}}
134-
\newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \indexsubitem}}
173+
\newcommand{\index@subitem}{}
174+
\newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
175+
\newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}}
135176

136177

137178
% from user-level, fulllineitems should be called as an environment
@@ -146,46 +187,46 @@
146187
% \begin{cfuncdesc}{type}{name}{arglist}
147188
% ... description ...
148189
% \end{cfuncdesc}
149-
\newcommand{\cfuncline}[3]{\item[\code{#1 #2(\varvars{#3})}]\ttindex{#2}}
190+
\newcommand{\cfuncline}[3]{\item[\code{#1 \bfcode{#2}(\varvars{#3})}]\ttindex{#2}}
150191
\newcommand{\cfuncdesc}[3]{\fulllineitems\cfuncline{#1}{#2}{#3}}
151192
\let\endcfuncdesc\endfulllineitems
152193

153-
\newcommand{\cvarline}[2]{\item[\code{#1 #2}]\ttindex{#2}}
194+
\newcommand{\cvarline}[2]{\item[\code{#1 \bfcode{#2}}]\ttindex{#2}}
154195
\newcommand{\cvardesc}[2]{\fulllineitems\cvarline{#1}{#2}}
155196
\let\endcvardesc\endfulllineitems
156197

157-
\newcommand{\ctypeline}[1]{\item[\code{#1}]\ttindex{#1}}
198+
\newcommand{\ctypeline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
158199
\newcommand{\ctypedesc}[1]{\fulllineitems\ctypeline{#1}}
159200
\let\endctypedesc\endfulllineitems
160201

161202
% funcdesc should be called as an \begin{funcdesc} ... \end{funcdesc}
162-
\newcommand{\funcline}[2]{\item[\code{#1(\varvars{#2})}]\ttindex{#1}}
203+
\newcommand{\funcline}[2]{\item[\code{\bfcode{#1}(\varvars{#2})}]\ttindex{#1}}
163204
\newcommand{\funcdesc}[2]{\fulllineitems\funcline{#1}{#2}}
164205
\let\endfuncdesc\endfulllineitems
165-
\newcommand{\optional}[1]{{\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}} }
206+
\newcommand{\optional}[1]{{\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
166207

167208

168209
% same for excdesc
169-
\newcommand{\excline}[1]{\item[\code{#1}]\ttindex{#1}}
210+
\newcommand{\excline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
170211
\newcommand{\excdesc}[1]{\fulllineitems\excline{#1}}
171212
\let\endexcdesc\endfulllineitems
172213

173214
% same for datadesc
174-
\newcommand{\dataline}[1]{\item[\code{#1}]\ttindex{#1}}
215+
\newcommand{\dataline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
175216
\newcommand{\datadesc}[1]{\fulllineitems\dataline{#1}}
176217
\let\enddatadesc\endfulllineitems
177218

178219

179220
% opcodedesc should be called as an \begin{opcodedesc} ... \end{opcodedesc}
180-
\newcommand{\opcodeline}[2]{\item[\code{#1\quad\varvars{#2}}]\ttindex{#1}}
221+
\newcommand{\opcodeline}[2]{\item[\bfcode{#1}\quad\var{#2}]}
181222
\newcommand{\opcodedesc}[2]{\fulllineitems\opcodeline{#1}{#2}}
182223
\let\endopcodedesc\endfulllineitems
183224

184225

185226
\let\nodename=\label
186227

187-
%% For these commands, use \command{} to get the typography right, not
188-
%% {\command}. This works better with the texinfo translation.
228+
% For these commands, use \command{} to get the typography right, not
229+
% {\command}. This works better with the texinfo translation.
189230
\newcommand{\ABC}{{\sc abc}}
190231
\newcommand{\UNIX}{{\sc Unix}}
191232
\newcommand{\POSIX}{POSIX}
@@ -199,29 +240,33 @@
199240
\newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}%
200241
\mbox{\codefont{#1}}}}
201242

243+
\newcommand{\bfcode}[1]{\code{\bfseries#1}} %bold-faced code font
202244
\newcommand{\kbd}[1]{\mbox{\tt #1}}
203245
\newcommand{\key}[1]{\mbox{\tt #1}}
204246
\newcommand{\samp}[1]{\mbox{`\code{#1}'}}
205-
% This weird definition of \var{} allows it to always appear in roman italics,
206-
% and won't get funky in code fragments when we play around with fonts.
207-
\newcommand{\var}[1]{\mbox{\textrm{\textit{#1\/}}}}
247+
% This weird definition of \var{} allows it to always appear in roman
248+
% italics, and won't get funky in code fragments when we play around
249+
% with fonts.
250+
\newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}}
208251
\newcommand{\dfn}[1]{{\em #1\/}}
209252
\renewcommand{\emph}[1]{{\em #1\/}}
210253
\newcommand{\strong}[1]{{\bf #1}}
211254
% let's experiment with a new font:
212-
\newcommand{\file}[1]{\mbox{`\textsf{#1}'}}
255+
\newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}}
256+
\newcommand{\url}[1]{\mbox{\small\textsf{#1}}}
257+
\let\email=\url
213258

214259
\newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
215260

216261
\newif\iftexi\texifalse
217262
\newif\iflatex\latextrue
218263

219-
% Proposed new macros: These should be used for all references to identifiers
220-
% which are used to refer to instances of specific language constructs. See
221-
% the names for specific semantic assignments.
264+
% These should be used for all references to identifiers which are
265+
% used to refer to instances of specific language constructs. See the
266+
% names for specific semantic assignments.
222267
%
223-
% For now, don't do anything really fancy with them; just use them as logical
224-
% markup. This might change in the future.
268+
% For now, don't do anything really fancy with them; just use them as
269+
% logical markup. This might change in the future.
225270
%
226271
\let\module=\code
227272
\let\keyword=\code
@@ -236,8 +281,7 @@
236281

237282
\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
238283
\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
239-
\let\email=\code
240-
\let\url=\code
284+
\newcommand{\program}[1]{\strong{#1}}
241285

242286

243287
\newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3&#4\\
@@ -255,16 +299,16 @@
255299
% Sample usage:
256300
% \begin{seealso}
257301
% \seemodule{rand}{Uniform random number generator}; % Module xref
258-
% \seetext{{\em Encyclopedia Britannica}}. % Ref to a book
302+
% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
259303
% \end{seealso}
260304

261-
\newenvironment{seealso}[0]{{\bf See Also:}\par}{\par}
305+
\newenvironment{seealso}[0]{\strong{See Also:}\par}{\par}
262306
\newcommand{\seemodule}[2]{\ref{module-#1}: \module{#1}\quad(#2)}
263307
\newcommand{\seetext}[1]{\par{#1}}
264308

265-
% Fix the theindex environment to add an entry to the Table of Contents;
266-
% this is much nicer than just having to jump to the end of the book and
267-
% flip around, especially with multiple indexes.
309+
% Fix the theindex environment to add an entry to the Table of
310+
% Contents; this is much nicer than just having to jump to the end of
311+
% the book and flip around, especially with multiple indexes.
268312
%
269313
\let\OldTheindex=\theindex
270314
\renewcommand{\theindex}{%
@@ -287,8 +331,8 @@
287331
\OldEndAbstract
288332
}
289333

290-
% \mytableofcontents wraps the \tableofcontents macro with all the magic to
291-
% get the spacing right and have the right number of pages if the 'openright'
334+
% This wraps the \tableofcontents macro with all the magic to get the
335+
% spacing right and have the right number of pages if the 'openright'
292336
% option has been used. This eliminates a fair amount of crud in the
293337
% individual document files.
294338
%
@@ -308,36 +352,40 @@
308352
\fi%
309353
}%
310354
\pagebreak%
355+
\pagenumbering{arabic}%
311356
}
312357

313-
% Allow the release number to be specified independently of the \date{}. This
314-
% allows the date to reflect the document's date and release to specify the
315-
% Python release that is documented.
358+
% Allow the release number to be specified independently of the
359+
% \date{}. This allows the date to reflect the document's date and
360+
% release to specify the Python release that is documented.
361+
%
316362
\newcommand{\@release}{}
317363
\newcommand{\version}{}
318364
\newcommand{\releasename}{Release}
319365
\newcommand{\release}[1]{%
320366
\renewcommand{\@release}{\releasename\space\version}%
321-
\renewcommand{\version}{#1}%
322-
}
367+
\renewcommand{\version}{#1}}
323368

324-
% Allow specification of the author's address separately from the author's
325-
% name. This can be used to format them differently, which is a good thing.
369+
% Allow specification of the author's address separately from the
370+
% author's name. This can be used to format them differently, which
371+
% is a good thing.
372+
%
326373
\newcommand{\@authoraddress}{}
327374
\newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}}
328375

329-
% Change the title page to look a bit better, and fit in with the fncychap
330-
% ``Bjarne'' style a bit better.
376+
% Change the title page to look a bit better, and fit in with the
377+
% fncychap ``Bjarne'' style a bit better.
378+
%
331379
\renewcommand{\maketitle}{\begin{titlepage}%
332380
\let\footnotesize\small
333381
\let\footnoterule\relax
334382
\@ifundefined{ChTitleVar}{}{%
335383
\mghrulefill{\RW}}%
336384
\begin{flushright}%
337-
{\huge \@title \par}%
338-
{\em\LARGE \@release \par}
385+
{\rm\Huge\HeaderFamily \@title \par}%
386+
{\em\LARGE\HeaderFamily \@release \par}
339387
\vfill
340-
{\LARGE \@author \par}
388+
{\LARGE\HeaderFamily \@author \par}
341389
\vfill\vfill
342390
{\large
343391
\@date \par
@@ -352,12 +400,17 @@
352400
\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
353401
}
354402

355-
% ``minitoc'' support; works fairly well but not all chapters do well with it.
356-
% Has some weird side effects that I haven't tracked down; don't use it for
357-
% real at this time.
403+
% ``minitoc'' support; works fairly well but not all chapters do well
404+
% with it. Has some weird side effects that I haven't tracked down;
405+
% don't use it for real at this time.
358406
%
359-
% To enable, uncomment the following line only:
407+
% To enable, uncomment the following line only (don't do it!):
360408
%\RequirePackage{minitoc}
409+
%
410+
% Maybe this should all be removed. But I think something like this
411+
% would be really nice if it can be integrated with the ``list of
412+
% modules'' at the top of module-documentation chapters. But it might
413+
% require a completely new environment, perhaps based on {list}.
361414

362415
% Leave the rest as-is:
363416
\newif\if@minitocprinted
@@ -401,12 +454,14 @@
401454
\typeout{Including mini Tables of Contents in each chapter.}
402455
}
403456

404-
% This sets up the fancy chapter headings that make the documents look at
405-
% least a little better than the usual LaTeX output.
457+
% This sets up the fancy chapter headings that make the documents look
458+
% at least a little better than the usual LaTeX output.
406459
%
407460
\RequirePackage[Bjarne]{fncychap}
408461
\@ifundefined{ChTitleVar}{}{
409-
\ChTitleVar{\raggedleft \rm\Huge}
462+
\ChNameVar{\raggedleft\normalsize\HeaderFamily}
463+
\ChNumVar{\raggedleft \bfseries\Large\HeaderFamily}
464+
\ChTitleVar{\raggedleft \rm\Huge\HeaderFamily}
410465
% This creates chapter heads without the leading \vspace*{}:
411466
\def\@makechapterhead#1{%
412467
{\parindent \z@ \raggedright \normalfont

0 commit comments

Comments
 (0)