.DTX

DTX File

Documented LaTeX Source File
Ask a question
QUICK ANSWER

A DTX file is a Documented LaTeX Source file - the standard format for distributing LaTeX packages on CTAN. To extract the usable .sty or .cls files, run latex package.ins using the companion .ins installer file. To just read it, open it in any text editor; it is plain text.

Developer: LaTeX Project (DocStrip by Frank Mittelbach; ltxdoc class by LATEX3 team) Category: Developer Files Open standard MIME: text/x-tex
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Aug 5, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the DTX file format?

A .dtx file is a Documented LaTeX Source file - the standard format for distributing LaTeX packages on CTAN (the Comprehensive TeX Archive Network). The format implements a literate programming approach: a single .dtx file interleaves the package's runnable source code with its full typeset documentation in one self-contained plain-text file.

The mechanism relies on DocStrip, a utility included with every TeX distribution. Guard comments in the form % <guard> mark which lines belong to the implementation and which are pure documentation. Running latex package.ins (using the companion .ins installer file) strips out documentation markers and extracts the usable .sty or .cls package files. Running pdflatex package.dtx instead typesets the full manual - complete with annotated, syntax-highlighted source code.

Nearly every CTAN package ships as a .dtx + .ins pair. The .ins file is a short DocStrip script that tells the extractor what output files to produce and where to place them.

.dtx files are plain UTF-8 (or ASCII) text and open in any text editor, though TeX-aware editors such as TeXstudio or Texmaker provide syntax highlighting. The ltxdoc document class, part of the LaTeX kernel, is used to typeset .dtx documentation and provides environments for annotating macro definitions alongside their source code.

Security & safety

RISK: LOW

DTX files are plain-text source files; they pose no direct execution risk when opened in a text editor. Compiling an untrusted .dtx with LaTeX carries the same risk as running any LaTeX document: malicious TeX code could execute shell commands if --shell-escape is enabled. Do not compile .dtx files from untrusted sources with shell-escape enabled.

Format details

in a nutshell
FULL NAMEDocumented LaTeX Source Fileaka DocStrip file, literate LaTeX source
DEVELOPERLaTeX Project (DocStrip by Frank Mittelbach; ltxdoc class by LATEX3 team)since 1989 (DocStrip mechanism introduced with LaTeX2e era)
MIME TYPEtext/x-tex
TYPEplain-text literate programming / documented source (TeX-based)
STANDARDOpen · royalty-free

Programs that open DTX files

Windows5 apps
TeXworks Open-source File → Open .dtx; syntax highlighting for TeX; run LaTeX on the .ins file to extract package files.
Texmaker Open-source Open .dtx in the editor; run latex package.ins via the Tools menu to extract .sty files.
Notepad Open-source Open as plain text; install the TeX/LaTeX syntax plugin for highlighting.
TeXstudio Open-source Open the .dtx file in TeXstudio as a text file; use the editor to read or modify source.
MiKTeX (command line) Open-source Run latex package.ins in terminal to extract .sty/.cls; run pdflatex package.dtx to build PDF docs.
macOS3 apps
TeXworks Open-source Open .dtx; requires MacTeX distribution installed.
Texmaker Open-source Open .dtx; run latex on the companion .ins file.
TeXstudio Open-source Open .dtx in TeXstudio; use MacTeX distribution for compilation.
Linux3 apps
Texmaker Open-source Open .dtx; run latex/pdflatex as needed.
TeXstudio Open-source Open .dtx; use TeX Live for compilation.
vim / emacs with AUCTeX Open-source Standard LaTeX development environment on Linux; AUCTeX provides full .dtx editing support.

Technical details

deep spec
EncodingPlain text - ASCII or UTF-8
MechanismDocStrip literate programming system (Frank Mittelbach, 1989)
Guard syntax% <guard> comments control which lines are extracted as code vs. typeset as documentation
Companion file.ins installer script drives DocStrip extraction process
Extraction commandlatex package.ins - produces .sty or .cls output files
Documentation commandpdflatex package.dtx - typesets annotated source manual
Documentation classltxdoc (part of LaTeX kernel); provides \DescribeMacro and \DescribeEnv environments
Typical file size5 KB - 500 KB (large packages with full documentation can reach several MB)
Distribution platformCTAN (Comprehensive TeX Archive Network) - virtually all CTAN packages use .dtx
Operating systemsWindows, Linux, macOS
Output files.sty (package) or .cls (document class) extracted by DocStrip from the .dtx source
ContainerPlain text; no binary wrapper or compression
Released1989 (DocStrip mechanism introduced with LaTeX2e era)
Latest versionno versioned format spec; governed by current DocStrip and ltxdoc packages in TeX Live
Open standardYes · royalty-free
Specificationctan.org

DTX conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with DTX files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about DTX files.

Frequently asked questions

How do I install a .dtx package into LaTeX?
Run latex package.ins (the companion installer file) to extract the .sty file, then move it to your local texmf tree and run texhash. Or use your distribution's package manager (tlmgr / MiKTeX Package Manager).
Can I open a .dtx file without LaTeX installed?
Yes - it is plain text; open in any text editor. You will see readable LaTeX source and documentation.
What is the difference between .dtx and .ins?
.dtx contains the documented source; .ins is the installer script that instructs DocStrip how to extract .sty/.cls files from the .dtx.
How do I read the documentation of a .dtx package?
Run pdflatex package.dtx to generate a PDF manual. Many CTAN packages also host the pre-built PDF.
Why does my LaTeX editor show .dtx files with mixed comments and code?
That is by design - the interleaved format is the essence of .dtx: documentation and code share one file, separated by DocStrip guard comments.

References

1CTAN - DocStrip packagectan.org
2TeX FAQ - Documented LaTeX sources (dtx files)texfaq.org

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.BINCD/DVD Disc Image (BIN/CUE)
3.PARTPartial Download File
4.CRDOWNLOADChrome Partial Download File
5.MDMarkdown Document
6.RPMSGRestricted Permission Message
7.NOMEDIAAndroid No-Media Marker File
8.PRO6XProPresenter 6 Bundle File
9.PRDXSoftMaker Presentations Document
10.SWFSmall Web Format (Shockwave Flash)

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z