How do I install a .dtx file?

When I run:

``````tex algorithms.dtx
``````

for example, I get this message.

``````  ! Undefined control sequence.
l.34 \documentclass
{ltxdoc}
?
``````

Help?

Depending on how the `.dtx` is constructed, it may not work at all with TeX: you have to use (pdf)latex. To unpack the file you may well need an `.ins` file.

• @an_ant: it doesn't need to be deleted, because it might help other users. You could even improve that chance if you change the title to "Installing a dtx file" or similar, so it could be found by users with a similar problem but any arbitrary package. – Stefan Kottwitz Dec 11 '10 at 18:59
• @Stefan Kottwitz: Got it. I'll try to manage it. – user1996 Dec 11 '10 at 19:24
• Thanks! Forgot that you should "Run LaTeX on the .ins file to unpack the .dtx file". – user1996 Dec 11 '10 at 19:29
• Could this answer contain something like "run (pdf)latex on the `.ins` file", so that it's more clear to others with the question (How do I install a .dtx file?) – ShreevatsaR Apr 29 '17 at 7:16

Joseph Wright says "run `latex` on the `.ins`"; however, if you have LaTeX, you also have `ltxdoc.cls`, etc., so that unpacking the `.dtx` doesn't help.

Processing the `.dtx` file with `(pdf)latex` gives all you need -- a file of documentation.

• "gives all you need -- a file of documentation" But I don't want the documentation: I was the cls or sty file. How are those generated? – Victor Eijkhout Nov 1 '17 at 11:52

I was having difficulty to understand the accepted answer. It's not the fault of the answer, just that the accepted answer was not targeted to novice (like me). So here is what I figured that I need to run to get the sty file from a dtx:

`tex algorithms.dtx`

I ran this for `pullquote`, and got the following response (and the required .sty file):

``````This is TeX, Version 3.14159265 (TeX Live 2018) (preloaded format=tex)
(./pullquote.dtx
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/docstrip.tex
Utility: `docstrip' 2.5e <2014/09/29>
English documentation    <2017/03/13>

**********************************************************
* This program converts documented macro-files into fast *
**********************************************************

********************************************************
* No Configuration file found, using default settings. *
********************************************************

)

Generating file(s) pullquote.sty

Processing file pullquote.dtx (package) -> pullquote.sty
File pullquote.dtx ended by \endinput.
Lines  processed: 2209
Codelines passed: 692

Generating file(s) pullquote.ins

Processing file pullquote.dtx (install) -> pullquote.ins
File pullquote.dtx ended by \endinput.
Lines  processed: 2209
Codelines passed: 692

File pullquote.dtx ended by \endinput.
Lines  processed: 2209
Codelines passed: 692

Overall statistics:
Files  processed: 3
Lines  processed: 6627