.dtx, and will normally be ‘stripped’ before use with LaTeX; an installation (
.ins) file is normally provided, to automate this process of removing comments for speed of loading. If the
.insfile is available, you may process it with LaTeX to produce the package (and, often, auxiliary files). Output should look something like:
The lines “Generating file(s) ./foo.sty Processing file foo.dtx (package) -> foo.sty File foo.dtx ended by \endinput. Lines processed: 2336 Comments removed: 1336 Comments passed: 2 Codelines passed: 972
Processing … ended by” may be repeated if the
.dtxfile provides more than one ‘unpacked’ file. To read the comments “as a document”, you can run LaTeX on the
.dtxfile to produce a nicely formatted version of the documented code. (Most LaTeX packages on ctan, nowadays, already have PDF of the result of processing the
.dtxfile, as “documentation”.) Several packages may be included in one
.dtxfile, with conditional sections, and there are facilities for indexes of macros, etc. All of this mélange is sorted out by directives in the
.insfile; conventional indexing utilities may be necessary for “full” output. Anyone may write
.dtxfiles; the format is explained in The LaTeX Companion, and a tutorial is available from CTAN (which comes with skeleton
.insfiles). Composition of
.dtxfiles is supported in emacs by AUC-TeX. The (unix-based) script dtxgen generates a proforma basic
.dtxfile, which could be useful when starting a new project. Another route to an
.dtxfile is to write the documentation and the code separately, and then to combine them using the makedtx system. This technique has particular value in that the documentation file can be used separately to generate HTML output; it is often quite difficult to make LaTeX to HTML conversion tools deal with
.dtxfiles, since they use an unusual class file. The sty2dtx system goes one step further: it attempts to create a
.dtxfile from a ‘normal’
.styfile with comments. It works well, in some circumstances, but can become confused by comments that aspire to “structure” (e.g., tabular material, as in many older packages’ file headers). The
.dtxfiles are not used by LaTeX after they have been processed to produce
.cls(or whatever) files. They need not be kept with the working system; however, for many packages the
.dtxfile is the primary source of documentation, so you may want to keep
.dtxfiles elsewhere. An interesting sideline to the story of
.dtxfiles is the docmfp package, which extends the model of the doc package to Metafont and MetaPost, thus permitting documented distribution of bundles containing code for Metafont and MetaPost together with related LaTeX code.
This answer last edited: 2014-06-03
Go to previous question, or next question
Go to FAQ home.
URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=dtx
Comments, suggestions, or error reports? - see “how to improve the FAQ”.
This is FAQ version 3.28, released on 2014-06-10.