Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

What is the docstrip utility? I have seen the string below many times, in many sources:

generated with the docstrip utility

but what is it? Is it a kind of LaTeX editor?

share|improve this question

2 Answers 2

up vote 14 down vote accepted

DocStrip is primarily method for removing comments from source files. While not such a big issue today, historically it was desirable to convert

% Some comment about code
% More comments about code
\CodeIsHere
% Followed by more description

to just

\CodeIsHere

as TeX has fewer lines to process and so will read a file more quickly.

DocStrip is able to do this conversion, leaving a 'source' file with comments and a 'production' one without. However, by using what are called guards DocStrip also offers selectivity in this conversion. For example, I've got a demo .dtx file only my blog which uses various guards to allow a single source file to be extracted to produce a README, a .ins file (traditionally needed by DocStrip for the extraction process itself) and one or more .sty files. I use this in for example siunitx to allow me to have one file containing both a LaTeX package and various configuration files. You can also extract several .sty files from a single source. This is more 'advanced' than simply removing comments, as you could use a commented .sty file directly with LaTeX, but could not do that if the source contains more than one file to extract.

DocStrip is not limited to extracting TeX-like material: it offers a series of commands to alter how the strip process operates. Probably the most common use of DocStrip after extracting TeX code is extracting Lua code for use with LuaTeX. Both the TeX and Lua code can be containing inside a single source, and DocStrip will deal with the extraction properly (with the correct set up).

share|improve this answer
    
To see various demos of the .dtx format, there is a dtx tag on the site. Quite a lot of the questions seem to involve my demo .dtx file! –  Joseph Wright Nov 16 '12 at 13:30

You can probably go texdoc docstrip to get the documentation for it or there is a copy here http://www.tug.org/texlive/Contents/live/texmf-dist/doc/latex/base/docstrip.pdf

It is a set of tex macros distributed as part of the core LaTeX which produces packages and class files .sty and .dtx by removing comments from documented versions (usually .dtx files. It can do some other things as well, re-arranging and combining code, but basically removing comments is its main function (and the origin of its name).

All of the core LaTeX distribution and many contributed packages are distributed in documented form with the actual package being generated by running TeX on a file which uses the docstrip macros to generate the final package.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.