# phpman > man > detex(1)

[DETEX(1)](https://www.chedong.com/phpMan.php/man/DETEX/1/markdown)                               General Commands Manual                              [DETEX(1)](https://www.chedong.com/phpMan.php/man/DETEX/1/markdown)



## NAME
       detex - a filter to strip _TeX_ commands from a .tex file.

## SYNOPSIS
       **detex** [ **-clnstw** ] [ **-e** _environment-list_ ] [ _filename_[.tex] ... ]

## DESCRIPTION
       _Detex_  reads each file in sequence, removes all comments and _TeX_ control sequences and writes
       the remainder on the standard output.  All text in math mode and display mode is removed.  By
       default,  _detex_  follows  \input  commands.  If a file cannot be opened, a warning message is
       printed and the command is ignored.  If the **-n** option is used, no \input or \include commands
       will  be  processed.   This  allows single file processing.  If no input file is given on the
       command line, _detex_ reads from standard input.

       If the magic sequence ``\begin{document}'' appears in the text, _detex_ assumes it  is  dealing
       with  _LaTeX_  source  and _detex_ recognizes additional constructs used in _LaTeX_.  These include
       the \include and \includeonly commands.  The **-l** option can be used to force  _LaTeX_  mode  and
       the **-t** option can be used to force _TeX_ mode regardless of input content.

       Text  in  various environment modes of _LaTeX_ is ignored.  The default modes are array, eqnar‐
       ray, equation, longtable, picture, tabular and verbatim.  The **-e** option can be used to  spec‐
       ify  a comma separated _environment-list_ of environments to ignore.  The list replaces the de‐
       faults so specifying an empty list effectively causes no environments to be ignored.

       The **-c** option can be used in _LaTeX_ mode to have detex echo the arguments to \cite, \ref,  and
       \pageref macros.  This can be useful when sending the output to a style checker.

       _Detex_  assumes  the  standard  character  classes are being used for _TeX_.  _Detex_ allows white
       space between control sequences and magic characters like `{' when  recognizing  things  like
       _LaTeX_ environments.

       The  **-r**  option tries to naively replace $..$, $$..$$, \(..\) and \[..\] with nouns and verbs
       (in particular, "noun" and "verbs") in a way that keeps sentences readable.

       If the **-w** flag is given, the output is a word list, one `word' (string of two or more letters
       and apostrophes beginning with a letter) per line, and all other characters ignored.  Without
### -w
       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 charater substitutes.  This eliminates spelling errors introduced by merely removing
       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.

## SEE ALSO
       [tex(1)](https://www.chedong.com/phpMan.php/man/tex/1/markdown)

## DIAGNOSTICS
       Nesting of \input is allowed but the number of opened files  must  not  exceed  the  system's
       limit  on the number of simultaneously opened files.  _Detex_ ignores unrecognized option char‐
       acters after printing a warning message.

## AUTHOR
       Originally written by Daniel Trinkle, Computer Science Department, Purdue University

       Maintained by Piotr Kubowicz <<https://github.com/pkubowicz/opendetex>>.

## BUGS
       _Detex_ is not a complete _TeX_ interpreter, so it can be confused by some constructs.  Most  er‐
       rors result in too much rather than too little output.

       Running _LaTeX_ source without a ``\begin{document}'' through _detex_ may produce errors.

       Suggestions for improvements are (mildly) encouraged.



Purdue University                           4 March 2021                                    [DETEX(1)](https://www.chedong.com/phpMan.php/man/DETEX/1/markdown)
