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}
56 % \changes{v2.0i}{1994/04/29}{Update the documentation.}
57 % \changes{v2.0s}{1998/08/17}{(RmS) Documentation fixes.}
59 % \section{Documentation of the \LaTeX\ sources}
61 % This class file is designed for documenting the \LaTeX\ source files.
62 % You may however find it generally useful as a class for typesetting
63 % the documentation of files produced in `doc' format.
65 % Each documented file in the standard distribution comes with extension
66 % |dtx|. The appropriate class package or initex file will be extracted
67 % from the source by the docstrip system. Each |dtx| file may be
68 % directly processed with \LaTeXe, for example
70 % latex2e docclass.dtx
72 % would produce the documentation of the Class and package interface.
74 % Each file that is used in producing the \LaTeXe\ format (ie not
75 % including the standard class and packages) will be printed together in
76 % one document if you \LaTeX\ the file |sources2e.tex|. This has the
77 % advantage that one can produce a full index of macro usage across all
80 % If you need to customise the typesetting of any of these files, there
83 % \item You can use \dst\ with the module `driver' to extract a small
84 % \LaTeX\ file that you may edit to use whatever class or package
85 % options you require, before inputting the source file.
86 % \item You can create a file |ltxdoc.cfg|. This configuration file will
87 % be read whenever the |ltxdoc| class is used, and so can be used to
88 % customise the typesetting of all the source files, without having to
89 % edit lots of small driver files.
92 % The second option is usually more convenient. Various possibilities
93 % are discussed in the next section.
95 % \section{Customisation}
97 % The simplest form of customisation is to pass more options to the
98 % |article| class which is loaded by |ltxdoc|. For instance if you wish
99 % all the documentation to be formatted for A4 paper, add the following
100 % line to |ltxdoc.cfg|:
102 % \PassOptionsToClass{a4paper}{article}
105 % All the source files are in two parts, separated by |\StopEventually|.
106 % The first part (should) contain `user' documentation. The second part
107 % is a full documented listing of the source code. The |doc| package
108 % provides the command |\OnlyDescription| which suppresses the code
109 % listings. This may also be used in the configuration file, but as the
110 % |doc| package is read later, you must delay the execution of
111 % |\OnlyDescription| until after the |doc| package has been read. The
112 % simplest way is to use |\AtBeginDocument|. Thus you could put the
113 % following in your |ltxdoc.cfg|.
115 % \AtBeginDocument{\OnlyDescription}
119 % If the full source listing |sources2e.tex| is processed, then an index
120 % and change history are produced by default, however indices are not
121 % normally produced for individual files.
123 % As an example, consider |ltclass.dtx|, which contains the sources for
124 % the new class and package interface commands. With no |cfg|
125 % file, a 19~page document is produced. With the above configuration
126 % a slightly more readable document (4~pages) is produced.
128 % Conversely, if you really want to read the source listings in detail,
129 % you will want to have an index. Again the index commands provided by
130 % the doc package may be used, but their execution must be delayed.
132 % \AtBeginDocument{\CodelineIndex\EnableCrossrefs}
133 % \AtEndDocument{\PrintIndex}
136 % The |doc| package writes index files to be sorted using MakeIndex with
137 % the |gind| style, so one would then use a command such as
139 % makeindex -s gind.ist ltclass.idx
143 % Similarly to print a Change history, you would add
145 % \AtBeginDocument{\RecordChanges}
146 % \AtEndDocument{\PrintChanges}
148 % to |ltxdoc.cfg|, and use MakeIndex with a command such as
150 % makeindex -s gglo.ist -o ltclass.gls ltclass.glo
153 % Finally if you do not want to list all the sections of |source2e.tex|,
154 % you can use |\includeonly| in the |cfg| file:
156 % \includeonly{ltvers,ltboxes}
166 \DeclareOption{a5paper}{\@latexerr{Option not supported}%
172 \PassOptionsToClass {\CurrentOption}{article}}
175 % \section{Configuration}
176 % Input a local configuration file, if it exists.
178 \InputIfFileExists{ltxdoc.cfg}
179 {\typeout{*************************************^^J%
180 * Local config file ltxdoc.cfg used^^J%
181 *************************************}}
186 % \section{Option Processing}
192 % \section{Loading article and doc}
202 % Make \verb+|+ be a `short verb' character, but not in the document
203 % preamble, where an active character may interfere with packages that
206 \AtBeginDocument{\MakeShortVerb{\|}}
209 % As `doc' documents tend to have a lot of monospaced material,
210 % Set up some |tt| substitutions to occur silently.
211 % \changes{v2.0p}{1995/11/02}{Add font substitutions}
212 % \changes{v2.0t}{1999/04/17}{Replaced octal number, CAR}
214 \DeclareFontShape{OT1}{cmtt}{bx}{n}{<-> ssub * cmtt/m/n}{}
215 \DeclareFontFamily{OMS}{cmtt}{\skewchar\font 48} % '60
216 \DeclareFontShape{OMS}{cmtt}{m}{n}{<-> ssub * cmsy/m/n}{}
217 \DeclareFontShape{OMS}{cmtt}{bx}{n}{<-> ssub * cmsy/b/n}{}
219 % This substitution is in the standard fd file, but not silent.
221 \DeclareFontShape{OT1}{cmss}{m}{it}{<->ssub*cmss/m/sl}{}
229 % Increase the text width slightly so that with the standard fonts
230 % 72 columns of code may appear in a |macrocode| environment.
231 % \changes{v2.0c}{1994/03/15}{Set \cs{textwidth}.}
233 \setlength{\textwidth}{355pt}
236 % Increase the marginpar width slightly, for long command names.
237 % And increase the left margin by a similar amount
239 % {1994/05/25}{Increase \cs{marginparwidth}}
240 % \changes{v2.0q}{1995/11/28}
241 % {Increase \cs{marginparwidth} and page margin.}
243 \addtolength\marginparwidth{30pt}
244 \addtolength\oddsidemargin{20pt}
245 \addtolength\evensidemargin{20pt}
250 \setcounter{StandardModuleDepth}{1}
253 % \section{Useful abbreviations}
255 % |\cmd{\foo}| Prints |\foo| verbatim. It may be used inside moving
256 % arguments. It can \emph{not} be use to record commands that are defined as
257 % ``|\outer|'' nor is it possible to use it on conditionals such as
258 % |\iftrue| or defined by |\newif|.
259 % |\cs{foo}| also prints |\foo|, for those who prefer that
260 % syntax. (This second form can be used to record all types of command so the
261 % above restrictions do not apply.
262 % \begin{macro}{\cmd}
263 % \changes{v2.0k}{1994/05/21}{New definition, so \cmd\{ works.}
265 % \changes{v2.0d}{1994/03/17}{Add \cs{cs}}
267 \def\cmd#1{\cs{\expandafter\cmd@to@cs\string#1}}
268 \def\cmd@to@cs#1#2{\char\number`#2\relax}
269 \DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
274 % \changes{v2.0r}{1996/01/11}{Removed \cs{star} since useless pr/2039}
276 % \begin{macro}{\marg}
277 % \changes{v2.0d}{1994/03/17}{Add \cs{marg}}
278 % |\marg{text}| prints \marg{text}, `mandatory argument'.
280 \providecommand\marg[1]{%
281 {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
285 % \begin{macro}{\oarg}
286 % |\oarg{text}| prints \oarg{text}, `optional argument'.
288 \providecommand\oarg[1]{%
289 {\ttfamily[}\meta{#1}{\ttfamily]}}
293 % \begin{macro}{\parg}
294 % |\parg{te,xt}| prints \parg{te,xt}, `picture mode argument'.
295 % \changes{v2.0h}{1994/04/28}{Add \cs{parg}}
296 % \changes{v2.0o}{1995/08/09}{Use \cs{meta} when showing arguments}
298 \providecommand\parg[1]{%
299 {\ttfamily(}\meta{#1}{\ttfamily)}}
304 % \section{Old Comments}
306 % The \LaTeXe\ sources contain a lot of code inherited from
307 % \LaTeX2.09. The comments in this code were not designed to be
308 % typeset, and do not contain the necessary \LaTeX\ markup. The
309 % \texttt{oldcomments} environment typesets these comments,
310 % automatically sensing when any control sequence appears, and
311 % implicitly adding the |\verb|. This procedure does not produce
312 % particularly beautiful pages, but it allows us to fully document new
313 % sections, and have some form of typeset comments on all the old
315 % \changes{v2.0e}{1994/03/18}{Use a fixed font.}
317 % Scan control names and put them in tt.
318 % Will actually (incorrectly) scan past |\\| but this does not matter as
319 % this is almost never followed by a letter in practice.
320 % (ie |\\foo|) would put |foo| in |\ttfamily|.
324 \egroup\let\next\oc@bslash\else
326 #1\let\next\oc@scan\else
328 \def\next{\char`\%\egroup}%
335 \def\oc@bslash{\bgroup\oc@ttf\char`\\\oc@scan}%
342 \uppercase{\def~{{\oc@ttf\char`#1}}}}
348 \catcode`\/=\catcode`\\
350 /catcode`<=/catcode`{%
351 /catcode`>=/catcode`}%
354 /gdef/oldc< \end{oldcomments}>%
355 /gdef/begmac< \begin{macrocode}>%
356 /gdef/obs</def <</oc@ttf/ >>>%
362 \catcode`\/=\catcode`\\
364 /catcode`/|=/catcode`/%
368 /let/do/oc@verb/dospecials
369 /frenchspacing/@vobeyspaces/obs
377 /ttfamily/expandafter/let/expandafter/oc@ttf/the/font
388 \gdef\oc@percent#1^^M{%
390 \def\commentline{#1}%
391 \ifx\commentline\oldc%
394 \ifx\commentline\begmac%
401 {\oc@ttf\char`\%}#1^^M%
407 % \section{DocInclude}
410 \@addtoreset{CodelineNo}{part}
413 % \begin{macro}{\DocInclude}
414 % More or less exactly the same as |\include|, but uses |\DocInput|
415 % on a |dtx| file, not |\input| on a |tex| file.
416 % \changes{v2.0b}{1994/03/14}{Rename from \cs{docinclude}}
417 % \changes{v2.0f}{1994/03/25}{Use \cs{part}}
418 % \changes{v2.0u}{1999/08/08}{Also works for .fdd (M. Schroeder)}
424 \newcommand*{\DocInclude}[1]{%
428 \IfFileExists{#1.fdd}%
429 {\def\currentfile{#1.fdd}}%
430 {\def\currentfile{#1.dtx}}%
431 \ifnum\@auxout=\@partaux
432 \@latexerr{\string\include\space cannot be nested}\@eha
433 \else \@docinclude#1 \fi}
434 \def\@docinclude#1 {\clearpage
435 \if@filesw \immediate\write\@mainaux{\string\@input{#1.aux}}\fi
436 \@tempswatrue\if@partsw \@tempswafalse\edef\@tempb{#1}\@for
437 \@tempa:=\@partlist\do{\ifx\@tempa\@tempb\@tempswatrue\fi}\fi
438 \if@tempswa \let\@auxout\@partaux \if@filesw
439 \immediate\openout\@partaux #1.aux
440 \immediate\write\@partaux{\relax}\fi
442 % We need to save (and later restore) various index-related
443 % commands which might be changed by the included file.
445 \let\@ltxdoc@PrintIndex\PrintIndex
446 \let\PrintIndex\relax
447 \let\@ltxdoc@PrintChanges\PrintChanges
448 \let\PrintChanges\relax
449 \let\@ltxdoc@theglossary\theglossary
450 \let\@ltxdoc@endtheglossary\endtheglossary
453 \xdef\filekey{\filekey, \thepart={\ttfamily\currentfile}}}%
454 \DocInput{\currentfile}%
455 \let\PrintIndex\@ltxdoc@PrintIndex
456 \let\PrintChanges\@ltxdoc@PrintChanges
457 \let\theglossary\@ltxdoc@theglossary
458 \let\endtheglossary\@ltxdoc@endtheglossary
460 \@writeckpt{#1}\if@filesw \immediate\closeout\@partaux \fi
461 \else\@nameuse{cp@#1}\fi\let\@auxout\@mainaux}
465 \gdef\codeline@wrindex#1{\if@filesw
466 \immediate\write\@indexfile
467 {\string\indexentry{#1}%
468 {\filesep\number\c@CodelineNo}}\fi}%
477 % \begin{macro}{\aalph}
478 % Special form of |\alph| as currently |source2e.tex|
479 % includes more than 26 files
480 % \changes{v2.0n}{1994/05/27}{Use uppercase letters, for makeindex}.
482 \def\aalph#1{\@aalph{\csname c@#1\endcsname}}
484 \ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or
485 j\or k\or l\or m\or n\or o\or p\or q\or r\or s\or
486 t\or u\or v\or w\or x\or y\or z\or A\or B\or C\or
487 D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
488 N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or
489 X\or Y\or Z\else\@ctrerr\fi}
493 % \begin{macro}{\docincludeaux}
494 % \changes{v2.06}{1994/03/31}{Use \cs{footnotesize} in file key.}
495 % \changes{v2.0k}{1994/05/21}{Use \cs{aalph}}
498 \def\thepart{\aalph{part}}\def\filesep{\thepart-}%
500 \g@addto@macro\index@prologue{%
501 \gdef\@oddfoot{\parbox{\textwidth}{\strut\footnotesize
502 \raggedright{\bfseries File Key:} \filekey}}%
503 \let\@evenfoot\@oddfoot}%
504 \global\let\docincludeaux\relax
506 \expandafter\ifx\csname ver@\currentfile\endcsname\relax
507 File \thepart: {\ttfamily\currentfile} %
509 \GetFileInfo{\currentfile}%
510 File \thepart: {\ttfamily\filename} %
515 \let\@evenfoot\@oddfoot}%
519 % \begin{macro}{\MaintainedByLaTeXTeam}
520 % \changes{v2.0v}{2015/03/25}{macro added}
521 % \changes{v2.0w}{2015/03/25}{use display block not footnote text}
522 % Generate boilerplate reference to bug database.
524 \def\MaintainedBy#1{\gdef\@maintainedby{#1}}
528 \let\@maintainedby\@empty
532 \def\MaintainedByLaTeXTeam#1{%
533 {\gdef\@maintainedby{%
534 This file is maintained by the \LaTeX{} Project team.\\%
535 Bug reports can be opened (category \texttt{#1}) at\\%
536 \url{http://latex-project.org/bugs.html}.}}}
545 \let \footnote \thanks
546 {\LARGE \@title \par}%
550 \begin{tabular}[t]{c}%
555 \ifx\@maintainedby\@empty
558 \fbox{\fbox{\begin{tabular}{@{}l@{}}\@maintainedby\end{tabular}}}%
566 % \begin{macro}{\url}
568 \providecommand\url{\texttt}