LinuxCommandLibrary

tex

Typeset documents using the TeX engine

TLDR

Compile a DVI document

$ tex [source.tex]
copy

Compile a DVI document, specifying an output directory
$ tex -output-directory=[path/to/directory] [source.tex]
copy

Compile a DVI document, exiting on each error
$ tex -halt-on-error [source.tex]
copy

SYNOPSIS

tex [] <filename>

Note: The <.tex> extension is usually omitted when specifying <filename>.

PARAMETERS

<filename>
    The path to the main TeX source file to process. The .tex extension is usually omitted.

-interaction={mode}
    Sets the user interaction mode for errors and missing files. Modes include batchmode, nonstopmode, scrollmode, and errorstopmode (default).

-output-directory=


    Specifies the directory where all output files (.dvi, .log, .aux, etc.) will be placed.

-ini
    Used to create TeX format files (.fmt). This loads tex.ini and saves the compiled format for later use, typically by system administrators.

-fmt=
    Specifies the TeX format file to load, such as plain or latex. Most users invoke wrappers like latex directly.

-jobname=
    Sets the base name for all generated output files, overriding the default name derived from the input filename.

--help
    Displays a brief help message and exits.

--version
    Prints the version information of the TeX executable and exits.

DESCRIPTION

The tex command is the executable for Donald Knuth's powerful and highly stable typesetting system. It reads a source file, typically with a .tex extension, which contains text mixed with TeX commands. Its primary purpose is to produce high-quality documents, particularly those involving complex mathematical formulas or intricate layouts. The output of the tex command is a Device Independent (DVI) file, which can then be converted to other formats like PostScript or PDF using additional utilities. While tex provides the core engine, most users interact with higher-level macro packages such as LaTeX, which simplifies document creation by abstracting away much of TeX's low-level complexity. TeX is renowned for its precision, portability, and free availability, making it a cornerstone in academic and scientific publishing.

CAVEATS

The tex command primarily produces DVI files; a separate conversion step (e.g., using dvips and ps2pdf, or dvipdfm) is required to obtain PDF output. For direct PDF generation, pdflatex is generally preferred. Directly using tex often requires a deeper understanding of TeX's primitive commands, as it lacks the user-friendly macros provided by packages like LaTeX. Its error messages can also be quite cryptic for beginners.

DVI OUTPUT FORMAT

The default output of tex is a Device Independent (DVI) file. This binary format describes the layout of the document but is not directly viewable or printable without a specific DVI viewer or a conversion utility.

TEX FORMATS AND MACRO PACKAGES

While tex is the core engine, it is rarely used directly for document creation. Instead, users typically leverage 'format files' which are precompiled collections of macros. The most popular format is LaTeX, which builds on plain TeX to provide a powerful and user-friendly markup language for structured documents.

HISTORY

TeX was created by Donald E. Knuth, a renowned computer scientist, in the late 1970s. The initial version was released in 1978, driven by Knuth's dissatisfaction with the quality of digital typesetting for his book series, The Art of Computer Programming. Knuth designed TeX to produce aesthetically pleasing and mathematically precise documents. Version 3 (TeX82), released in 1982, introduced significant improvements, including a more robust macro system. TeX's version number incrementally approaches Pi, reflecting Knuth's commitment to stability and very few, controlled changes. It quickly gained popularity in academic and scientific circles due to its high-quality output, stability, and open-source nature, becoming a de facto standard for technical document preparation.

SEE ALSO

latex(1), pdflatex(1), dvips(1), ps2pdf(1), dvipdfm(1), bibtex(1), makeindex(1)

Copied to clipboard