DETEX(1)

πŸ“¦
version 70015 Β· 5 versions
, in alpine 3.24, arch rolling, debian trixie, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸŽ€ 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 πŸ’œπŸ¦‹βœ¨