{
    "mode": "man",
    "parameter": "DETEX",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/DETEX/1/json",
    "generated": "2026-10-20T06:52:05Z",
    "synopsis": "detex [ -clnstw ] [ -e environment-list ] [ filename[.tex] ... ]",
    "sections": {
        "NAME": {
            "content": "detex - a filter to strip TeX commands from a .tex file.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "detex [ -clnstw ] [ -e environment-list ] [ filename[.tex] ... ]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Detex  reads each file in sequence, removes all comments and TeX control sequences and writes\nthe remainder on the standard output.  All text in math mode and display mode is removed.  By\ndefault, detex follows \\input commands.  If a file cannot be opened,  a  warning  message  is\nprinted and the command is ignored.  If the -n option is used, no \\input or \\include commands\nwill  be  processed.   This  allows single file processing.  If no input file is given on the\ncommand line, detex reads from standard input.\n\nIf the magic sequence ``\\begin{document}'' appears in the text, detex assumes it  is  dealing\nwith  LaTeX  source  and detex recognizes additional constructs used in LaTeX.  These include\nthe \\include and \\includeonly commands.  The -l option can be used to force  LaTeX  mode  and\nthe -t option can be used to force TeX mode regardless of input content.\n\nText  in  various environment modes of LaTeX is ignored.  The default modes are array, eqnar‐\nray, equation, longtable, picture, tabular and verbatim.  The -e option can be used to  spec‐\nify  a comma separated environment-list of environments to ignore.  The list replaces the de‐\nfaults so specifying an empty list effectively causes no environments to be ignored.\n\nThe -c option can be used in LaTeX mode to have detex echo the arguments to \\cite, \\ref,  and\n\\pageref macros.  This can be useful when sending the output to a style checker.\n\nDetex  assumes  the  standard  character  classes are being used for TeX.  Detex allows white\nspace between control sequences and magic characters like `{' when  recognizing  things  like\nLaTeX environments.\n\nThe  -r  option tries to naively replace $..$, $$..$$, \\(..\\) and \\[..\\] with nouns and verbs\n(in particular, \"noun\" and \"verbs\") in a way that keeps sentences readable.\n\nIf the -w flag is given, the output is a word list, one `word' (string of two or more letters\nand apostrophes beginning with a letter) per line, and all other characters ignored.  Without",
            "subsections": [
                {
                    "name": "-w",
                    "content": "are preserved where possible so that the lines of output match the input as closely as possi‐\nble.\n\nThe -1 option will prefix each printed line with `filename:linenumber:` indicating where that\nline is coming from in terms of the original (La)TeX document.\n\nThe  TEXINPUTS  environment variable is used to find \\input and \\include files.  Like TeX, it\ninterprets a leading or trailing `:' as the default TEXINPUTS.  It does not support the  `//'\ndirectory expansion magic sequence.\n\nDetex now handles the basic TeX ligatures as a special case, replacing the ligatures with ac‐\nceptable  character substitutes.  This eliminates spelling errors introduced by merely remov‐\ning them.  The ligatures are \\aa, \\ae, \\oe, \\ss, \\o, \\l (and their  upper-case  equivalents).\nThe special \"dotless\" characters \\i and \\j are also replaced with i and j respectively.\n\nNote  that  previous versions of detex would replace control sequences with a space character\nto prevent words from running together.  However, this caused accents in the middle of  words\nto  break  words,  generating  \"spelling errors\" that were not desirable.  Therefore, the new\nversion merely removes these accents.  The old functionality can be essentially duplicated by\nusing the -s option.\n",
                    "flag": "-w"
                }
            ]
        },
        "SEE ALSO": {
            "content": "",
            "subsections": [
                {
                    "name": "tex(1)",
                    "content": ""
                }
            ]
        },
        "DIAGNOSTICS": {
            "content": "Nesting of \\input is allowed but the number of opened files  must  not  exceed  the  system's\nlimit  on the number of simultaneously opened files.  Detex ignores unrecognized option char‐\nacters after printing a warning message.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Originally written by Daniel Trinkle, Computer Science Department, Purdue University.\n\nMaintained by Piotr Kubowicz <https://github.com/pkubowicz/opendetex>.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Detex is not a TeX interpreter (it essentially reads the input with a (f)lex program), so  it\nis  easily confused by some constructs. Most errors result in too much rather than too little\noutput.\n\nRunning LaTeX source without a ``\\begin{document}'' through detex may produce errors.\n\nSuggestions for improvements are (mildly) encouraged.\n\nTeX Live                                  15 September 2022                                 DETEX(1)",
            "subsections": []
        }
    },
    "summary": "detex - a filter to strip TeX commands from a .tex file.",
    "flags": [
        {
            "flag": "-w",
            "long": null,
            "arg": null,
            "description": "are preserved where possible so that the lines of output match the input as closely as possi‐ ble. The -1 option will prefix each printed line with `filename:linenumber:` indicating where that line is coming from in terms of the original (La)TeX document. The TEXINPUTS environment variable is used to find \\input and \\include files. Like TeX, it interprets a leading or trailing `:' as the default TEXINPUTS. It does not support the `//' directory expansion magic sequence. Detex now handles the basic TeX ligatures as a special case, replacing the ligatures with ac‐ ceptable character substitutes. This eliminates spelling errors introduced by merely remov‐ ing them. The ligatures are \\aa, \\ae, \\oe, \\ss, \\o, \\l (and their upper-case equivalents). The special \"dotless\" characters \\i and \\j are also replaced with i and j respectively. Note that previous versions of detex would replace control sequences with a space character to prevent words from running together. However, this caused accents in the middle of words to break words, generating \"spelling errors\" that were not desirable. Therefore, the new version merely removes these accents. The old functionality can be essentially duplicated by using the -s option."
        }
    ],
    "examples": [],
    "see_also": []
}