TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 17 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
% Followed by more description

to just


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


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.