DETEX(1)
π DETEX(1) β the detex manual π
β¨ NAME β¨
okay so detex is a filter that strips TeX commands out of a .tex file π
β¨ SYNOPSIS β¨
detex [ -clnstw ] [ -e environment-list ] [ filename[.tex] ... ]
β¨ DESCRIPTION β¨
bestie, so detex reads each file in order, nukes all the comments and TeX control sequences, and writes whatever's left on the standard output π§ Everything in math mode and display mode gets deleted too, no cap. By default it follows \input commands. If a file can't be opened, you get a warning and that command gets ignored π If you use the -n option, no \input or \include commands get processed, which is lowkey perfect for single file processing. And if you don't give it any input file on the command line, it just reads from standard input π
If the magic sequence \begin{document} shows up in the text, detex figures out it's dealing with LaTeX source and starts recognizing extra LaTeX-only stuff, like the \include and \includeonly commands π¦ You can force LaTeX mode with -l, or force TeX mode with -t no matter what the input looks like. Main character energy π
Text inside certain LaTeX environments gets ignored. The default ones are array, eqnarray, equation, longtable, picture, tabular and verbatim πΈ Use -e to pick your own comma separated environment-list of environments to ignore. Heads up: your list replaces the defaults, so if you pass an empty list, nothing at all gets ignored π«Ά
The -c option works in LaTeX mode and makes detex echo the arguments to \cite, \ref, and \pageref macros. This is super useful when you're sending the output to a style checker β¨
detex assumes the standard character classes are being used for TeX. It also lets white space sit between control sequences and magic characters like { when it's recognizing things like LaTeX environments π
The -r option tries to naively swap out $..$, $$..$$, \(..\) and \[..\] for nouns and verbs (like "noun" and "verbs") in a way that keeps your sentences readable π
If you give the -w flag, the output becomes a word list: one word per line, where a word is a string of two or more letters and apostrophes that begins with a letter. Every other character gets ignored π Without -w, the output follows the original text, minus the deletions from above. Newline characters are kept where possible, so the lines of output line up with the input as closely as they can π
The -1 option prefixes each printed line with filename:linenumber:, so you can see exactly where that line came from in the original (La)TeX document π₯
The TEXINPUTS environment variable is what detex uses to find \input and \include files. Like TeX, it treats a leading or trailing : as the default TEXINPUTS. It does not support the // directory expansion magic sequence π
Okay, the glow-up: detex now handles the basic TeX ligatures as a special case, swapping them for acceptable character4 substitutes. This stops you from getting spelling errors just from removing them β¨ The ligatures are \aa, \ae, \oe, \ss, \o, \l (and their upper-case equivalents). The special "dotless" characters \i and \j also get replaced with i and j respectively π¦
Now, the tea. Older versions of detex replaced control sequences with a space character so words wouldn't run together. But that meant accents in the middle of words would break the word apart and create "spelling errors" nobody wanted π So the new version just removes these accents instead. If you still want the old behavior, you can basically get it back with the -s option π
β¨ SEE ALSO β¨
tex(1) πΈ
β¨ DIAGNOSTICS β¨
Nesting \input is allowed, but the number of opened files must not go over the system's limit on how many files can be open at once. Also, detex ignores unrecognized option characters, but it prints a warning first so you know π«Ά
β¨ AUTHOR β¨
Originally written by Daniel Trinkle, Computer Science Department, Purdue University. π
Maintained by Piotr Kubowicz <https://github.com/pkubowicz/opendetex> π
β¨ BUGS β¨
Real talk: detex is not a TeX interpreter. It basically reads the input with a (f)lex program, so it gets confused by some constructs. Most errors give you too much output rather than too little π
Running LaTeX source without a \begin{document} through detex may produce errors π
Suggestions for improvements are (mildly) encouraged π§
Sign-off time, bestie π This page is from Purdue University, dated August 12, 1993, and it lives under DETEX(1) forever ππ¦β¨
π¦ where this page comes from
- alpine 3.24: texlive-doc 2026.0-r0 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- arch rolling: texlive-doc 2026.1-1 Β· GPL
- debian trixie: texlive-binaries 2024.20240313.70630+ds-6 Β· TeX-Live
- fedora 44: texlive-detex 12:svn70015-105.fc44 Β· NCSA
- fedora 44: texlive-detex 12:svn70015-111.fc44 Β· NCSA
- opensuse-leap 16.0: texlive-detex 2025.221.svn70015-160000.3.1 Β· LPPL-1.0
- ubuntu questing: texlive-binaries 2024.20240313.70630+ds-6ubuntu2 Β· TeX-Live
- ubuntu resolute: texlive-binaries 2025.20250727.75242+ds-5build1 Β· TeX-Live
- ubuntu stonking: texlive-binaries 2026.20260303.78225+ds-5ubuntu1 Β· TeX-Live
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms