TEX(1)

๐Ÿ’– TEX(1) โ€” General Commands Manual ๐Ÿ’–

okay bestie, so tex(1) is THE moment. this is the actual TeX typesetter, the blueprint, the blueprint's blueprint. let me tell you everything, no gatekeeping ๐Ÿ’…


โœจ NAME โœจ

tex, initex โ€” text formatting and typesetting ๐Ÿฆ‹

โœจ SYNOPSIS โœจ

tex [options] [&format] [file|\commands]

โœจ DESCRIPTION โœจ

so basically you run the TeX typesetter on file, and it's usually gonna make file.dvi. if the file argument has no extension, .tex gets appended to it โ€” like a little automatic glow-up โœจ. and instead of a filename you can also just hand it a set of TeX commands, but heads up: the first of those has to start with a backslash, no exceptions.

with a &format argument, TeX uses a totally different set of precompiled commands living inside format.fmt. tho ngl, it's usually better to use the -fmt format option instead. iykyk.

TeX formats the interspersed text and commands inside the named files and outputs a typesetter independent file called DVI, which is short for DeVice Independent ๐Ÿ‘‘. all of TeX's capabilities and its whole language are described in The TeXbook. TeX normally vibes with a big body of precompiled macros, and there are several specific formatting systems like LaTeX that need the support of several macro files.

this version of TeX looks at its command line to see what name it was called under, which is so main character of it:

  • if they exist, both initex and virtex are symbolic links to the tex executable.
  • when called as initex (or when you pass the -ini option) it can precompile macros into a .fmt file ๐Ÿ”ฅ
  • when called as virtex it uses the plain format.
  • when called under any other name, TeX uses that name as the name of the format to use. for example, when called as tex, the tex format is used, which is identical to the plain format.

the commands defined by the plain format are documented in The TeXbook. other formats that are often available include latex and amstex ๐Ÿ’œ

the non-option command line arguments to the TeX program get passed to it as the first input line. (tho honestly it's often easier to type extended arguments as the first input line, because UNIX shells tend to gobble up or misinterpret TeX's favorite symbols โ€” like backslashes โ€” unless you quote them. the shell is NOT respectful ๐Ÿ˜ญ.) as described in The TeXbook, that first line should begin with a filename, a \controlsequence, or a &formatname.

the normal usage is to say

tex paper

to start processing paper.tex. the name paper will be the jobname'', and it's used when forming output filenames. if TeX doesn't get a filename in the first line, the jobname is `texput`. when looking for a file, TeX looks for the name with **and** without the default extension (`.tex`) appended, unless the name already contains that extension. if `paper` is the jobname'', a log of error messages โ€” with way more detail than normally shows up on your screen โ€” will appear in paper.log, and the output file will be in paper.dvi. she keeps receipts ๐Ÿซถ

this version of TeX can look at the first line of the file paper.tex to see if it begins with the magic sequence %&. if the first line begins with

%&format -translate-file tcxname

then TeX will use the named format and translation table tcxname to process the source file. either the format name or the -translate-file specification may be omitted, but not both. this overrides the format selection based on the name by which the program is invoked. the -parse-first-line option or the parse_first_line configuration variable controls whether this behaviour is enabled.

the e response to TeX's error prompt causes the system default editor to start up at the current line of the current file. the environment variable TEXEDIT can be used to change the editor used. it may contain a string with "%s" indicating where the filename goes and "%d" indicating where the decimal line number (if any) goes. for example, a TEXEDIT string for emacs can be set with the sh command

TEXEDIT="emacs +%d %s"; export TEXEDIT

a convenient file in the library is null.tex, containing absolutely nothing (iconic, honestly). when TeX can't find a file it thinks you want to input, it keeps asking you for another filename; responding ``null'' gets you out of the loop if you don't want to input anything. you can also type your EOF character (usually control-D) ๐Ÿ’€


โœจ OPTIONS โœจ

this version of TeX understands the following command line options. buckle up bestie, there's a lot and they're all important:

  • -cnf-line string โ€” parse string as a texmf.cnf configuration line. see the Kpathsea manual.
  • -enc โ€” enable the encTeX extensions. this option is only effective in combination with -ini. for documentation of the encTeX extensions see http://www.olsak.net/enctex.html.
  • -file-line-error โ€” print error messages in the form file:line:error, which is similar to the way many compilers format them.
  • -no-file-line-error โ€” disable printing error messages in the file:line:error style.
  • -file-line-error-style โ€” this is the old name of the -file-line-error option.
  • -fmt format โ€” use format as the name of the format to be used, instead of the name by which TeX was called or a %& line.
  • -halt-on-error โ€” exit with an error code when an error is encountered during processing.
  • -help โ€” print help message and exit.
  • -ini โ€” start in INI mode, which is used to dump formats. INI mode can be used for typesetting, but no format is preloaded, and basic initializations like setting catcodes may be required.
  • -interaction mode โ€” sets the interaction mode. mode can be either batchmode, nonstopmode, scrollmode, and errorstopmode. the meaning of these modes is the same as that of the corresponding \commands.
  • -ipc โ€” send DVI output to a socket as well as the usual output file. whether this option is available is the choice of the installer.
  • -ipc-start โ€” as -ipc, and starts the server at the other end as well. whether this option is available is the choice of the installer.
  • -jobname name โ€” use name for the job name, instead of deriving it from the name of the input file.
  • -kpathsea-debug bitmask โ€” sets path searching debugging flags according to the bitmask. see the Kpathsea manual for details.
  • -mktex fmt โ€” enable mktexfmt, where fmt must be either tex or tfm.
  • -mltex โ€” enable MLTeX extensions. only effective in combination with -ini.
  • -no-mktex fmt โ€” disable mktexfmt, where fmt must be either tex or tfm.
  • -output-comment string โ€” use string for the DVI file comment instead of the date.
  • -output-directory directory โ€” write output files in directory instead of the current directory. look up input files in directory first, then along the normal search path. see also the description of the TEXMFOUTPUT environment variable.
  • -parse-first-line โ€” if the first line of the main input file begins with %&, parse it to look for a dump name or a -translate-file option.
  • -no-parse-first-line โ€” disable parsing of the first line of the main input file.
  • -progname name โ€” pretend to be program name. this affects both the format used and the search paths.
  • -recorder โ€” enable the filename recorder. this leaves a trace of the files opened for input and output in a file with extension .fls.
  • -shell-escape โ€” enable the \write18{command} construct. the command can be any shell command. this construct is normally disallowed for security reasons ๐Ÿšจ
  • -no-shell-escape โ€” disable the \write18{command} construct, even if it is enabled in the texmf.cnf file.
  • -src-specials โ€” insert source specials into the DVI file.
  • -src-specials where โ€” insert source specials in certain places of the DVI file. where is a comma-separated value list: cr, display, hbox, math, par, parent, or vbox.
  • -translate-file tcxname โ€” use the tcxname translation table to set the mapping of input characters and re-mapping of output characters.
  • -default-translate-file tcxname โ€” like -translate-file except that a %& line can overrule this setting.
  • -version โ€” print version information and exit.

โœจ ENVIRONMENT โœจ

see the Kpathsearch library documentation (the Path specifications' node) for precise details of how the environment variables are used. the kpsewhich` utility can be used to query the values of the variables.

one caveat bestie: in most TeX formats, you cannot use ~ in a filename you give directly to TeX, because ~ is an active character, and hence is expanded, not taken as part of the filename. other programs, such as Metafont, do not have this problem.
  • TEXMFOUTPUT โ€” normally, TeX puts its output files in the current directory. if any output file cannot be opened there, it tries to open it in the directory specified in the environment variable TEXMFOUTPUT. there is no default value for that variable. for example, if you say tex paper and the current directory is not writable, if TEXMFOUTPUT has the value /tmp, TeX attempts to create /tmp/paper.log (and /tmp/paper.dvi, if any output is produced.) TEXMFOUTPUT is also checked for input files, as TeX often generates files that need to be subsequently read; for input, no suffixes (such as ``.tex'') are added by default, the input name is simply checked as given.
  • TEXINPUTS โ€” search path for \input and \openin files. this should probably start with .'', so that user files are found before system files. an empty path component will be replaced with the paths defined in the `texmf.cnf` file. for example, set `TEXINPUTS` to `".:/home/user/tex:"` to prepend the current directory and /home/user/tex'' to the standard search path.
  • TEXFORMATS โ€” search path for format files.
  • TEXPOOL โ€” search path for tex internal strings.
  • TEXEDIT โ€” command template for switching to editor. the default, usually vi, is set when TeX is compiled.
  • TFMFONTS โ€” search path for font metric (.tfm) files.

โœจ FILES โœจ

the location of the files mentioned below varies from system to system. use the kpsewhich utility to find their locations ๐ŸŒธ

  • texmf.cnf โ€” configuration file. this contains definitions of search paths as well as other configuration parameters like parse_first_line.
  • tex.pool โ€” text file containing TeX's internal strings.
  • texfonts.map โ€” filename mapping definitions.
  • *.tfm โ€” metric files for TeX's fonts.
  • *.fmt โ€” predigested TeX format (.fmt) files.
  • $TEXMFMAIN/tex/plain/base/plain.tex โ€” the basic macro package described in the TeXbook.

โœจ NOTES โœจ

this manual page is not meant to be exhaustive. the complete documentation for this version of TeX can be found in the info manual Web2C: A TeX implementation.

๐Ÿ’€ BUGS ๐Ÿ’€

Okay bestie, listen. This version of TeX implements a number of optional extensions. And likeโ€ฆ many of these extensions conflict to a greater or lesser extent with the definition of TeX. Which is a whole thing. ๐Ÿ™ˆ When such extensions are enabled, the banner printed when TeX starts is changed to print TeXk instead of TeX. So if you ever see TeXk up top, that's why โ€” she's got her little extensions on, iykyk. โœจ

Also, not to be dramatic, but: this version of TeX fails to trap arithmetic overflow when dimensions are added or subtracted. Cases where this occurs are rare, but when it does the generated DVI file will be invalid. ๐Ÿ’€ So likeโ€ฆ keep an eye on your dimensions, babe. That DVI? Not gonna be okay.


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

  • mf(1) โ€” her sibling, the font queen ๐ŸŽ€
  • Donald E. Knuth, The TeXbook, Addison-Wesley, 1986, ISBN 0-201-13447-0. The holy text, fr fr. ๐Ÿ‘‘
  • Leslie Lamport, LaTeX - A Document Preparation System, Addison-Wesley, 1985, ISBN 0-201-15790-X. The one that made everybody's thesis happen. โœจ
  • K. Berry, Eplain: Expanded plain TeX, https://tug.org/eplain
  • Michael Spivak, The Joy of TeX, 2nd edition, Addison-Wesley, 1990, ISBN 0-8218-2997-1. The title is not lying, it is a joy. ๐Ÿฆ‹
  • TUGboat (the journal of the TeX Users Group). https://tug.org/TUGboat โ€” yes the user group is literally called TUG and the journal is called TUGboat, we love a consistent brand. ๐Ÿšข

๐ŸŒธ TRIVIA ๐ŸŒธ

TeX, pronounced properly, rhymes with blecchhh.'' ๐Ÿ˜ญ That's it. That's the pronunciation. And the proper spelling in typewriter-like fonts is TeX'' and not TEX'' or tex.'' โ€” so bestie, case matters, do not come at her with lowercase. ๐Ÿ’…


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

TeX was created by Donald E. Knuth, who implemented it using his Web system for Pascal programs. Then it got ported to Unix at Stanford by Howard Trickey, and at Cornell by Pavel Curtis. The version now offered with the Unix TeX distribution is that generated by the Web to C system (web2c), originally written by Tomas Rokicki and Tim Morgan. Legends only. ๐Ÿซถ

The encTeX extensions were written by Petr Olsak. ๐Ÿ’œ


And that's the whole page, bestie โ€” this was Web2C 2025, dated 6 August 2019. Go make something beautiful with her. ๐ŸŽ€โœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from