1 % \iffalse meta-comment
4 % The LaTeX3 Project and any individual authors listed elsewhere
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
18 % This file has the LPPL maintenance status "maintained".
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
31 %<class>\NeedsTeXFormat{LaTeX2e}
32 %<class>\ProvidesClass{ltxdoc}
33 %<class> [2015/03/26 v2.0w Standard LaTeX documentation class]
36 \documentclass{ltxdoc}
37 \GetFileInfo{ltxdoc.cls}
38 \providecommand\dst{\expandafter{\normalfont\scshape docstrip}}
39 \title{The file \texttt{ltxdoc.dtx} for use with
40 \LaTeXe.\thanks{This file has version
41 number \fileversion, dated \filedate.}\\[2pt]
42 It contains the code for \texttt{ltxdoc.cls}}
44 \author{David Carlisle}
46 \MaintainedByLaTeXTeam{latex}
55 % \changes{v2.0i}{1994/04/29}{Update the documentation.}
56 % \changes{v2.0s}{1998/08/17}{(RmS) Documentation fixes.}
58 % \section{Documentation of the \LaTeX\ sources}
60 % This class file is designed for documenting the \LaTeX\ source files.
61 % You may however find it generally useful as a class for typesetting
62 % the documentation of files produced in `doc' format.
64 % Each documented file in the standard distribution comes with extension
65 % |dtx|. The appropriate class package or initex file will be extracted
66 % from the source by the docstrip system. Each |dtx| file may be
67 % directly processed with \LaTeXe, for example
69 % latex2e docclass.dtx
71 % would produce the documentation of the Class and package interface.
73 % Each file that is used in producing the \LaTeXe\ format (ie not
74 % including the standard class and packages) will be printed together in
75 % one document if you \LaTeX\ the file |sources2e.tex|. This has the
76 % advantage that one can produce a full index of macro usage across all
79 % If you need to customise the typesetting of any of these files, there
82 % \item You can use \dst\ with the module `driver' to extract a small
83 % \LaTeX\ file that you may edit to use whatever class or package
84 % options you require, before inputting the source file.
85 % \item You can create a file |ltxdoc.cfg|. This configuration file will
86 % be read whenever the |ltxdoc| class is used, and so can be used to
87 % customise the typesetting of all the source files, without having to
88 % edit lots of small driver files.
91 % The second option is usually more convenient. Various possibilities
92 % are discussed in the next section.
94 % \section{Customisation}
96 % The simplest form of customisation is to pass more options to the
97 % |article| class which is loaded by |ltxdoc|. For instance if you wish
98 % all the documentation to be formatted for A4 paper, add the following
99 % line to |ltxdoc.cfg|:
101 % \PassOptionsToClass{a4paper}{article}
104 % All the source files are in two parts, separated by |\StopEventually|.
105 % The first part (should) contain `user' documentation. The second part
106 % is a full documented listing of the source code. The |doc| package
107 % provides the command |\OnlyDescription| which suppresses the code
108 % listings. This may also be used in the configuration file, but as the
109 % |doc| package is read later, you must delay the execution of
110 % |\OnlyDescription| until after the |doc| package has been read. The
111 % simplest way is to use |\AtBeginDocument|. Thus you could put the
112 % following in your |ltxdoc.cfg|.
114 % \AtBeginDocument{\OnlyDescription}
118 % If the full source listing |sources2e.tex| is processed, then an index
119 % and change history are produced by default, however indices are not
120 % normally produced for individual files.
122 % As an example, consider |ltclass.dtx|, which contains the sources for
123 % the new class and package interface commands. With no |cfg|
124 % file, a 19~page document is produced. With the above configuration
125 % a slightly more readable document (4~pages) is produced.
127 % Conversely, if you really want to read the source listings in detail,
128 % you will want to have an index. Again the index commands provided by
129 % the doc package may be used, but their execution must be delayed.
131 % \AtBeginDocument{\CodelineIndex\EnableCrossrefs}
132 % \AtEndDocument{\PrintIndex}
135 % The |doc| package writes index files to be sorted using MakeIndex with
136 % the |gind| style, so one would then use a command such as
138 % makeindex -s gind.ist ltclass.idx
142 % Similarly to print a Change history, you would add
144 % \AtBeginDocument{\RecordChanges}
145 % \AtEndDocument{\PrintChanges}
147 % to |ltxdoc.cfg|, and use MakeIndex with a command such as
149 % makeindex -s gglo.ist -o ltclass.gls ltclass.glo
152 % Finally if you do not want to list all the sections of |source2e.tex|,
153 % you can use |\includeonly| in the |cfg| file:
155 % \includeonly{ltvers,ltboxes}
165 \DeclareOption{a5paper}{\@latexerr{Option not supported}%
171 \PassOptionsToClass {\CurrentOption}{article}}
174 % \section{Configuration}
175 % Input a local configuration file, if it exists.
177 \InputIfFileExists{ltxdoc.cfg}
178 {\typeout{*************************************^^J%
179 * Local config file ltxdoc.cfg used^^J%
180 *************************************}}
185 % \section{Option Processing}
191 % \section{Loading article and doc}
201 % Make \verb+|+ be a `short verb' character, but not in the document
202 % preamble, where an active character may interfere with packages that
205 \AtBeginDocument{\MakeShortVerb{\|}}
208 % As `doc' documents tend to have a lot of monospaced material,
209 % Set up some |tt| substitutions to occur silently.
210 % \changes{v2.0p}{1995/11/02}{Add font substitutions}
211 % \changes{v2.0t}{1999/04/17}{Replaced octal number, CAR}
213 \DeclareFontShape{OT1}{cmtt}{bx}{n}{<-> ssub * cmtt/m/n}{}
214 \DeclareFontFamily{OMS}{cmtt}{\skewchar\font 48} % '60
215 \DeclareFontShape{OMS}{cmtt}{m}{n}{<-> ssub * cmsy/m/n}{}
216 \DeclareFontShape{OMS}{cmtt}{bx}{n}{<-> ssub * cmsy/b/n}{}
218 % This substitution is in the standard fd file, but not silent.
220 \DeclareFontShape{OT1}{cmss}{m}{it}{<->ssub*cmss/m/sl}{}
228 % Increase the text width slightly so that with the standard fonts
229 % 72 columns of code may appear in a |macrocode| environment.
230 % \changes{v2.0c}{1994/03/15}{Set \cs{textwidth}.}
232 \setlength{\textwidth}{355pt}
235 % Increase the marginpar width slightly, for long command names.
236 % And increase the left margin by a similar amount
238 % {1994/05/25}{Increase \cs{marginparwidth}}
239 % \changes{v2.0q}{1995/11/28}
240 % {Increase \cs{marginparwidth} and page margin.}
242 \addtolength\marginparwidth{30pt}
243 \addtolength\oddsidemargin{20pt}
244 \addtolength\evensidemargin{20pt}
249 \setcounter{StandardModuleDepth}{1}
252 % \section{Useful abbreviations}
254 % |\cmd{\foo}| Prints |\foo| verbatim. It may be used inside moving
255 % arguments. It can \emph{not} be use to record commands that are defined as
256 % ``|\outer|'' nor is it possible to use it on conditionals such as
257 % |\iftrue| or defined by |\newif|.
258 % |\cs{foo}| also prints |\foo|, for those who prefer that
259 % syntax. (This second form can be used to record all types of command so the
260 % above restrictions do not apply.
261 % \begin{macro}{\cmd}
262 % \changes{v2.0k}{1994/05/21}{New definition, so \cmd\{ works.}
264 % \changes{v2.0d}{1994/03/17}{Add \cs{cs}}
266 \def\cmd#1{\cs{\expandafter\cmd@to@cs\string#1}}
267 \def\cmd@to@cs#1#2{\char\number`#2\relax}
268 \DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
273 % \changes{v2.0r}{1996/01/11}{Removed \cs{star} since useless pr/2039}
275 % \begin{macro}{\marg}
276 % \changes{v2.0d}{1994/03/17}{Add \cs{marg}}
277 % |\marg{text}| prints \marg{text}, `mandatory argument'.
279 \providecommand\marg[1]{%
280 {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
284 % \begin{macro}{\oarg}
285 % |\oarg{text}| prints \oarg{text}, `optional argument'.
287 \providecommand\oarg[1]{%
288 {\ttfamily[}\meta{#1}{\ttfamily]}}
292 % \begin{macro}{\parg}
293 % |\parg{te,xt}| prints \parg{te,xt}, `picture mode argument'.
294 % \changes{v2.0h}{1994/04/28}{Add \cs{parg}}
295 % \changes{v2.0o}{1995/08/09}{Use \cs{meta} when showing arguments}
297 \providecommand\parg[1]{%
298 {\ttfamily(}\meta{#1}{\ttfamily)}}
303 % \section{Old Comments}
305 % The \LaTeXe\ sources contain a lot of code inherited from
306 % \LaTeX2.09. The comments in this code were not designed to be
307 % typeset, and do not contain the necessary \LaTeX\ markup. The
308 % \texttt{oldcomments} environment typesets these comments,
309 % automatically sensing when any control sequence appears, and
310 % implicitly adding the |\verb|. This procedure does not produce
311 % particularly beautiful pages, but it allows us to fully document new
312 % sections, and have some form of typeset comments on all the old
314 % \changes{v2.0e}{1994/03/18}{Use a fixed font.}
316 % Scan control names and put them in tt.
317 % Will actually (incorrectly) scan past |\\| but this does not matter as
318 % this is almost never followed by a letter in practice.
319 % (ie |\\foo|) would put |foo| in |\ttfamily|.
323 \egroup\let\next\oc@bslash\else
325 #1\let\next\oc@scan\else
327 \def\next{\char`\%\egroup}%
334 \def\oc@bslash{\bgroup\oc@ttf\char`\\\oc@scan}%
341 \uppercase{\def~{{\oc@ttf\char`#1}}}}
347 \catcode`\/=\catcode`\\
349 /catcode`<=/catcode`{%
350 /catcode`>=/catcode`}%
353 /gdef/oldc< \end{oldcomments}>%
354 /gdef/begmac< \begin{macrocode}>%
355 /gdef/obs</def <</oc@ttf/ >>>%
361 \catcode`\/=\catcode`\\
363 /catcode`/|=/catcode`/%
367 /let/do/oc@verb/dospecials
368 /frenchspacing/@vobeyspaces/obs
376 /ttfamily/expandafter/let/expandafter/oc@ttf/the/font
387 \gdef\oc@percent#1^^M{%
389 \def\commentline{#1}%
390 \ifx\commentline\oldc%
393 \ifx\commentline\begmac%
400 {\oc@ttf\char`\%}#1^^M%
406 % \section{DocInclude}
409 \@addtoreset{CodelineNo}{part}
412 % \begin{macro}{\DocInclude}
413 % More or less exactly the same as |\include|, but uses |\DocInput|
414 % on a |dtx| file, not |\input| on a |tex| file.
415 % \changes{v2.0b}{1994/03/14}{Rename from \cs{docinclude}}
416 % \changes{v2.0f}{1994/03/25}{Use \cs{part}}
417 % \changes{v2.0u}{1999/08/08}{Also works for .fdd (M. Schroeder)}
423 \newcommand*{\DocInclude}[1]{%
427 \IfFileExists{#1.fdd}%
428 {\def\currentfile{#1.fdd}}%
429 {\def\currentfile{#1.dtx}}%
430 \ifnum\@auxout=\@partaux
431 \@latexerr{\string\include\space cannot be nested}\@eha
432 \else \@docinclude#1 \fi}
433 \def\@docinclude#1 {\clearpage
434 \if@filesw \immediate\write\@mainaux{\string\@input{#1.aux}}\fi
435 \@tempswatrue\if@partsw \@tempswafalse\edef\@tempb{#1}\@for
436 \@tempa:=\@partlist\do{\ifx\@tempa\@tempb\@tempswatrue\fi}\fi
437 \if@tempswa \let\@auxout\@partaux \if@filesw
438 \immediate\openout\@partaux #1.aux
439 \immediate\write\@partaux{\relax}\fi
441 % We need to save (and later restore) various index-related
442 % commands which might be changed by the included file.
444 \let\@ltxdoc@PrintIndex\PrintIndex
445 \let\PrintIndex\relax
446 \let\@ltxdoc@PrintChanges\PrintChanges
447 \let\PrintChanges\relax
448 \let\@ltxdoc@theglossary\theglossary
449 \let\@ltxdoc@endtheglossary\endtheglossary
452 \xdef\filekey{\filekey, \thepart={\ttfamily\currentfile}}}%
453 \DocInput{\currentfile}%
454 \let\PrintIndex\@ltxdoc@PrintIndex
455 \let\PrintChanges\@ltxdoc@PrintChanges
456 \let\theglossary\@ltxdoc@theglossary
457 \let\endtheglossary\@ltxdoc@endtheglossary
459 \@writeckpt{#1}\if@filesw \immediate\closeout\@partaux \fi
460 \else\@nameuse{cp@#1}\fi\let\@auxout\@mainaux}
464 \gdef\codeline@wrindex#1{\if@filesw
465 \immediate\write\@indexfile
466 {\string\indexentry{#1}%
467 {\filesep\number\c@CodelineNo}}\fi}%
476 % \begin{macro}{\aalph}
477 % Special form of |\alph| as currently |source2e.tex|
478 % includes more than 26 files
479 % \changes{v2.0n}{1994/05/27}{Use uppercase letters, for makeindex}.
481 \def\aalph#1{\@aalph{\csname c@#1\endcsname}}
483 \ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or
484 j\or k\or l\or m\or n\or o\or p\or q\or r\or s\or
485 t\or u\or v\or w\or x\or y\or z\or A\or B\or C\or
486 D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
487 N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or
488 X\or Y\or Z\else\@ctrerr\fi}
492 % \begin{macro}{\docincludeaux}
493 % \changes{v2.06}{1994/03/31}{Use \cs{footnotesize} in file key.}
494 % \changes{v2.0k}{1994/05/21}{Use \cs{aalph}}
497 \def\thepart{\aalph{part}}\def\filesep{\thepart-}%
499 \g@addto@macro\index@prologue{%
500 \gdef\@oddfoot{\parbox{\textwidth}{\strut\footnotesize
501 \raggedright{\bfseries File Key:} \filekey}}%
502 \let\@evenfoot\@oddfoot}%
503 \global\let\docincludeaux\relax
505 \expandafter\ifx\csname ver@\currentfile\endcsname\relax
506 File \thepart: {\ttfamily\currentfile} %
508 \GetFileInfo{\currentfile}%
509 File \thepart: {\ttfamily\filename} %
514 \let\@evenfoot\@oddfoot}%
518 % \begin{macro}{\MaintainedByLaTeXTeam}
519 % \changes{v2.0v}{2015/03/25}{macro added}
520 % \changes{v2.0w}{2015/03/25}{use display block not footnote text}
521 % Generate boilerplate reference to bug database.
523 \def\MaintainedBy#1{\gdef\@maintainedby{#1}}
527 \let\@maintainedby\@empty
531 \def\MaintainedByLaTeXTeam#1{%
532 {\gdef\@maintainedby{%
533 This file is maintained by the \LaTeX{} Project team.\\%
534 Bug reports can be opened (category \texttt{#1}) at\\%
535 \url{http://latex-project.org/bugs.html}.}}}
544 \let \footnote \thanks
545 {\LARGE \@title \par}%
549 \begin{tabular}[t]{c}%
554 \ifx\@maintainedby\@empty
557 \fbox{\fbox{\begin{tabular}{@{}l@{}}\@maintainedby\end{tabular}}}%
565 % \begin{macro}{\url}
567 \providecommand\url{\texttt}