Debian Codegraph @

texk/web2c/doc/web2c.texi

raw
1 \input texinfo
2 @setfilename web2c.info
3 @settitle Web2c: A @TeX{} implementation
4
5 @tex
6 \expandafter\ifx\csname url\endcsname\relax
7 \errhelp{You must update texinfo.tex to at least version 3.8.
8 The latest version is available from ftp://ftp.tug.org/tex/texinfo.tex.}
9 \errmessage{Your texinfo.tex is too old}
10 \csname bye\expandafter\endcsname
11 \fi
12 @end tex
13
14 @set version 2026
15 @set month-year January 2026
16
17 @c Define new indices for commands in auxiliary files, filenames, and options.
18 @defcodeindex cm
19 @defcodeindex fl
20 @defcodeindex op
21
22 @c Put everything in one index (arbitrarily chosen to be the concept index).
23 @syncodeindex cm cp
24 @syncodeindex fl cp
25 @syncodeindex fn cp
26 @syncodeindex ky cp
27 @syncodeindex op cp
28 @syncodeindex pg cp
29 @syncodeindex vr cp
30
31 @dircategory TeX
32 @direntry
33 * Web2c: (web2c). TeX, Metafont, and companion programs.
34 @end direntry
35 @dircategory Individual utilities
36 @direntry
37 * bibtex: (web2c)bibtex invocation. Maintaining bibliographies.
38 * dvicopy: (web2c)dvicopy invocation. Virtual font expansion
39 * dvitomp: (web2c)dvitomp invocation. DVI to MPX (MetaPost pictures).
40 * dvitype: (web2c)dvitype invocation. DVI to human-readable text.
41 * gftodvi: (web2c)gftodvi invocation. Generic font proofsheets.
42 * gftopk: (web2c)gftopk invocation. Generic to packed fonts.
43 * gftype: (web2c)gftype invocation. GF to human-readable text.
44 * mf: (web2c)mf invocation. Creating typeface families.
45 * mft: (web2c)mft invocation. Prettyprinting Metafont source.
46 * mltex: (web2c)MLTeX. Multi-lingual TeX.
47 * mpost: (web2c)mpost invocation. Generating PostScript.
48 * patgen: (web2c)patgen invocation. Creating hyphenation patterns.
49 * pktogf: (web2c)pktogf invocation. Packed to generic fonts.
50 * pktype: (web2c)pktype invocation. PK to human-readable text.
51 * pltotf: (web2c)pltotf invocation. Property list to TFM.
52 * pooltype: (web2c)pooltype invocation. Display WEB pool files.
53 * tangle: (web2c)tangle invocation. WEB to Pascal.
54 * tex: (web2c)tex invocation. Typesetting.
55 * tftopl: (web2c)tftopl invocation. TFM -> property list.
56 * vftovp: (web2c)vftovp invocation. Virtual font -> virtual pl.
57 * vptovf: (web2c)vptovf invocation. Virtual pl -> virtual font.
58 * weave: (web2c)weave invocation. WEB to TeX.
59 @end direntry
60
61 @copying
62 This file documents the installation and use of the programs in Web2c,
63 an implementation of Donald Knuth's TeX system.
64
65 Copyright @copyright{} 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
66 2004, 2005, 2007, 2008, 2009, 2010--2026 Karl Berry & Olaf Weber.
67
68 Permission is granted to make and distribute verbatim copies of this
69 manual provided the copyright notice and this permission notice are
70 preserved on all copies.
71
72 @ignore
73 Permission is granted to process this file through TeX and print the
74 results, provided the printed document carries a copying permission
75 notice identical to this one except for the removal of this paragraph
76 (this paragraph not being relevant to the printed manual).
77 @end ignore
78
79 Permission is granted to copy and distribute modified versions of this
80 manual under the conditions for verbatim copying, provided that the
81 entire resulting derived work is distributed under the terms of a
82 permission notice identical to this one.
83
84 Permission is granted to copy and distribute translations of this manual
85 into another language, under the above conditions for modified versions,
86 except that this permission notice may be stated in a translation
87 @end copying
88
89
90 @titlepage
91 @title Web2c
92 @subtitle for version @value{version}
93 @subtitle @value{month-year}
94 @author Karl Berry
95 @author Olaf Weber
96 @author @url{https://tug.org/web2c}
97
98 @page
99 @vskip 0pt plus 1filll
100 @insertcopying
101 @end titlepage
102
103 @contents
104
105 @ifnottex
106 @node Top
107 @top Web2c
108
109 This document describes how to install and use the programs in the Web2c
110 implementation of the @TeX{} system, especially for Unix systems. It
111 corresponds to Web2c version @value{version}, released in
112 @value{month-year}.
113
114 @menu
115 * Introduction:: A brief introduction.
116 * Installation:: How to compile and install Web2c.
117 * Commonalities:: Option syntax, standard options, memory dumps.
118 * Three programs:: TeX, Metafont, MetaPost have much in common.
119 * TeX:: Typesetting.
120 * Metafont:: Typeface design.
121 * MetaPost:: Technical illustrations.
122 * BibTeX:: Reusable bibliographies.
123 * WEB:: Literate programming.
124 * DVI utilities:: DVI expansion.
125 * Font utilities:: Font format conversion.
126 * Legalisms:: Blah blah blah.
127 * References:: Books and such.
128 * Index:: General index.
129 @end menu
130 @end ifnottex
131
132
133 @node Introduction
134 @chapter Introduction
135
136 @cindex introduction
137
138 This manual corresponds to version @value{version} of Web2c, released in
139 @value{month-year}.
140
141 @cindex Knuth, Donald E.
142 @cindex @TeX{}, Web2c implementation of
143 @cindex Hobby, John
144 @cindex Breitenlohner, Peter
145 @dfn{Web2c} (also spelled Web2C) is the name of a @TeX{}
146 implementation, originally for Unix, but now also running under
147 Windows and other operating systems. By @dfn{@TeX{} implementation},
148 we mean all of the standard programs developed by the Stanford @TeX{}
149 project led by Donald@tie{}E. Knuth: Metafont, DVItype, GFtoDVI,
150 Bib@TeX{}, Tangle, etc., as well as @TeX{} itself. Other programs are
151 also included: DVIcopy, written by Peter Breitenlohner, MetaPost and
152 its utilities (derived from Metafont), by John Hobby, and many more.
153
154 @cindex translation from WEB to C
155 @cindex strategy, overall
156 General strategy: Web2c works, as its name implies, by translating the
157 WEB source in which @TeX{} is written into C source code. Its output is
158 not self-contained, however; it makes extensive use of many macros and
159 functions in a library (the @file{web2c/lib} directory in the sources).
160 Therefore, it will not work without change on an arbitrary WEB program.
161
162 @cindex licensing terms
163 @cindex freedom of Web2c
164 @cindex ice cream
165 Availability: All of Web2c is freely available---``free'' both in the
166 sense of no cost (free ice cream) and of having the source code to
167 modify and/or redistribute (free speech). @xref{unixtex.ftp,,,
168 kpathsea, Kpathsea}, for the practical details of how to obtain Web2c.
169
170 Different parts of the Web2c distribution have different licensing
171 terms, however, reflecting the different circumstances of their
172 creation; consult each source file for exact details. The main
173 practical implication for redistributors of Web2c is that most of the
174 executables are covered by the GNU General Public License or GNU
175 Lesser General Public License, and therefore anyone who gets a binary
176 distribution must also be able to get the sources, as explained by the
177 terms of the GPL (@url{https://gnu.org/licenses/}). The GPL covers the
178 Web2c executables, including @code{tex}, because the Free Software
179 Foundation sponsored the initial development of the Kpathsea library
180 that Web2c uses. The basic source files from Stanford, however, have
181 their own copyright terms or are in the public domain, and are not
182 covered by the GPL.
183
184 @cindex history
185 @cindex Rokicki, Tomas
186 @cindex Trickey, Howard
187 @cindex Curtis, Pavel
188 @cindex Morgan, Tim
189 @cindex Berry, Karl
190 @cindex Weber, Olaf
191 History: Tomas Rokicki originated the @TeX{}-to-C system in 1987,
192 working from the first change files for @TeX{} under Unix, which were
193 done primarily by Howard Trickey and Pavel Curtis. Tim Morgan then
194 took over development and maintenance for a number of years; the name
195 changed to Web-to-C somewhere in there. In 1990, Karl Berry became
196 the maintainer. He made many changes to the original sources, and
197 started using the shorter name Web2c. In 1997, Olaf Weber took over,
198 and then in 2006, Karl started taking care of it again. No
199 significant development or changes have been needed for many years,
200 though dozens of other people have contributed in many ways; their
201 names are listed in the @file{ChangeLog} files.
202
203 @cindex te@TeX{} distribution
204 Originally, Web2c was distributed as its own package, alongside the
205 original web programs from Stanford and other components. It was also
206 the basis for the te@TeX{} distribution (now discontinued). Around
207 2004, the packaging focus shifted entirely to the @TeX{} Live
208 distribution (@url{https://tug.org/texlive/}), though the same Web2c
209 is at the heart of the release.
210
211 @cindex acknowledgements
212 @cindex Martin, Rick
213 @cindex Morris, Bob
214 @cindex Stallman, Richard
215 Other acknowledgements by Karl: The University of Massachusetts at Boston
216 (particularly Rick Martin and Bob Morris) provided computers and ftp
217 access to me for many years. Richard Stallman at the Free Software
218 Foundation employed me while I wrote the original path searching library
219 (for the GNU font utilities). (rms also gave us Emacs, GDB, and GCC,
220 without which I cannot imagine developing Web2c.) And, of course,
221 @TeX{} would not exist in the first place without Donald@tie{}E. Knuth.
222
223 @cindex reading, additional
224 Further reading: @xref{References}.
225
226
227 @include install.texi
228
229
230 @node Commonalities
231 @chapter Commonalities
232
233 @cindex commonalities
234
235 Many aspects of the @TeX{} system are the same among more than one
236 program, so we describe those pieces together, here.
237
238 Another kind of commonality is the extensions to @TeX{} that are
239 available across all the engines; @pxref{TeX extensions}.
240
241 @menu
242 * Option conventions:: -- or -, = or ` ' for values.
243 * Common options:: --help --version --verbose, and TeX/MF/MP options.
244 * Path searching:: Features of the common path searching library.
245 * Output file location:: TEXMFOUTPUT allows output in places other than `.'.
246 @end menu
247
248
249 @node Option conventions
250 @section Option conventions
251
252 @cindex option conventions
253 @cindex conventions for options,
254
255 @findex getopt_long_only
256 To provide a clean and consistent behavior, we chose to have all these
257 programs use the GNU function @code{getopt_long_only} to parse command
258 lines. It is used in a restricted mode where all the options have to
259 come before the rest of the arguments.
260
261 @opindex - @r{starts option names}
262 @opindex -- @r{starts option names}
263 As a result, you can:
264 @itemize @bullet
265 @item
266 use @samp{-} or @samp{--} to start an option name;
267
268 @item
269 use any unambiguous abbreviation for an option name;
270
271 @item
272 separate option names and values with either @samp{=} or one or more
273 spaces;
274
275 @item
276 @flindex - @r{starting a filename}
277 @cindex filenames starting with @samp{-}
278 use filenames that would otherwise look like options by putting them
279 after an option @samp{--}.
280 @end itemize
281
282 By convention, non-option arguments, if specified, generally define the
283 name of an input file, as documented for each program.
284
285 If a particular option with a value is given more than once, it is the
286 last value that counts.
287
288 For example, the following command line specifies the options
289 @samp{foo}, @samp{bar}, and @samp{verbose}; gives the value @samp{baz}
290 to the @samp{abc} option, and the value @samp{xyz} to the @samp{quux}
291 option; and specifies the filename @file{-myfile-}.
292
293 @example
294 -foo --bar -verb -abc=baz -quux karl --quux xyz -- -myfile-
295 @end example
296
297
298 @node Common options
299 @section Common options
300
301 @cindex common options
302 All of these programs accept the standard GNU @samp{--help} and
303 @samp{--version} options, and several programs accept
304 @samp{--verbose}. Rather than writing identical descriptions for
305 every program, they are described here.
306
307 @table @samp
308 @item --help
309 @opindex --help @r{common option}
310 @cindex help, online
311 Print a usage message listing basic usage and all available options to
312 standard output, then exit successfully.
313
314 @item --verbose
315 @opindex --verbose @r{common option}
316 @cindex verbosity, enabling
317 Print progress reports to standard output.
318
319 @item --version
320 @opindex --version @r{common option}
321 @cindex version number, finding
322 Print the version number to standard output, then exit successfully.
323 @end table
324
325 @TeX{}, Metafont, and MetaPost have a number of additional options in
326 common:
327
328 @table @samp
329 @item -cnf-line=@var{str}
330 @opindex -cnf-line
331 Parse @var{str} as if it were a line in the @file{texmf.cnf}
332 configuration file, overriding all other settings. @xref{Path
333 searching options,,,kpathsea,Kpathsea}.
334
335 @item -file-line-error
336 @opindex -file-line-error
337 @itemx -no-file-line-error
338 @opindex -no-file-line-error
339 @opindex -file-line-error-style
340 @cindex changing error messages style
341 Change (or do not change) the way error messages are printed. The
342 alternate style looks like error messages from many compilers and is
343 easier to parse for some editors that invoke @TeX{}. This option used
344 to be called @samp{-file-line-error-style}.
345
346 @item -fmt=@var{dumpname}
347 @itemx -base=@var{dumpname}
348 @itemx -mem=@var{dumpname}
349 @opindex -fmt=@var{dumpname}
350 @opindex -base=@var{dumpname}
351 @opindex -mem=@var{dumpname}
352 @cindex dump file
353 Use @var{dumpname} instead of the program name or a @samp{%&} line to
354 determine the name of the memory dump file read (@samp{fmt} for @TeX{},
355 @samp{base} for Metafont, @samp{mem} for MetaPost). @xref{Memory
356 dumps}. Also sets the program name to @var{dumpname} if no
357 @samp{-progname} option was given.
358
359 @item -halt-on-error
360 @opindex -halt-on-error
361 @cindex stopping at the first error
362 Stop processing and exit when an error occurs, as opposed to the normal
363 process of trying to recover and continue.
364
365 @item -ini
366 @opindex -ini
367 @cindex program names, special
368 @cindex initial form, enabling
369 Enable the ``initial'' form of the program (@pxref{Initial and
370 virgin}). This is implicitly set if the program name is @code{initex}
371 resp.@: @code{inimf}.
372
373 @item -interaction=@var{string}
374 @opindex -interaction=@var{string}
375 @cindex interaction mode
376 Set the interaction mode from the command line. The @var{string} must
377 be one of @samp{batchmode}, @samp{nonstopmode}, @samp{scrollmode}, or
378 @samp{errorstopmode}.
379
380 @item -jobname=@var{string}
381 @opindex -jobname=@var{string}
382 @cindex job name
383 Set the job name to @var{string}, instead of deriving it from the name
384 of the input file.
385
386 @item -kpathsea-debug=@var{number}
387 @opindex -kpathsea-debug=@var{number}
388 @vindex KPATHSEA_DEBUG
389 @cindex debugging flags, specifying
390 @cindex path searching debugging
391 Set path searching debugging flags according to the bits of @var{number}
392 (@pxref{Debugging,,,kpathsea,Kpathsea}). You can also specify this in
393 @code{KPATHSEA_DEBUG} environment variable (for all Web2c programs).
394 (The command line value overrides.) The most useful value is @samp{-1},
395 to get all available output.
396
397 @item -output-directory=@var{dirname}
398 @opindex -output-directory
399 @cindex output directory, specifying
400 Specify the directory @var{dirname} to which output files are written.
401 Also look for input files in @var{dirname} first, before looking along
402 the normal search path. Input files are only looked for as specified;
403 no default extension is added. @xref{Output file location}.
404
405 @item -parse-first-line
406 @opindex -parse-first-line
407 @itemx -no-parse-first-line
408 @opindex -no-parse-first-line
409 @cindex parsing the first line
410 Check or disable checking whether the first line of the main input
411 file starts with @samp{%&}, and parse it if it does. This line can be
412 used specify the format and/or a TCX file.
413
414 @item -progname=@var{string}
415 @opindex -progname=@var{string}
416 @cindex binaries, linking
417 @cindex linking binaries
418 @cindex program names, special
419 Set program (and memory dump) name to @var{string}. This may affect the
420 search paths and other values used (@pxref{Config files,,, kpathsea,
421 Kpathsea}). Using this option is equivalent to making a link named
422 @var{string} to the binary and then invoking the binary under that
423 name. @xref{Memory dumps}.
424
425 @item -recorder
426 @opindex -recorder
427 @cindex file recorder
428 Enable the filename recorder. This makes the program save a list of the
429 opened files into a file with (by default) extension @samp{.fls}. For
430 Aleph, this option is always on, and the file has extension @samp{.ofl}.
431
432 @cindex pid, used in recorder filename
433 Ordinarily, the @samp{.fls} file is written to the same location as
434 the @samp{.log} file, for example, respecting
435 @option{-output-directory} if it is given (@pxref{Output file
436 location}). However, if @TeX{} processing is done on the command line
437 (or in response to the @samp{**} prompt), the @samp{.fls} might be
438 written to the current directory, or include an integer (the current
439 pid), as in @file{texput1234.fls}. You can use @option{-jobname} to
440 explicitly set the basename.
441
442 @item -translate-file=@var{tcxfile}
443 @opindex -translate-file=@var{tcxfile}
444 @cindex translation file for @TeX{}, specifying
445 @flindex .tcx @r{character translation files}
446 @cindex first line of the main input file
447 Use @var{tcxfile} to define which characters are printable and translations
448 between the internal and external character sets. Moreover,
449 @var{tcxfile} can be explicitly declared in the first line of the main
450 input file @samp{%& -translate-file=@var{tcxfile}}.
451 This is the recommended method for portability reasons.
452 @xref{TCX files}.
453
454 @item -8bit
455 @opindex -8bit
456 @cindex 8 bit clean
457 @flindex 8 bit clean output, specifying
458 This option specifies that by default all characters should be
459 considered printable. If @samp{-translate-file} was given as well,
460 then the TCX file may mark characters as non-printable. This is a
461 no-op in engines natively supporting Unicode.
462
463 @end table
464
465
466 @node Path searching
467 @section Path searching
468
469 @cindex path searching
470
471 @flindex texmf.cnf
472 @cindex configuration file reading
473 All of the Web2c programs, including @TeX{}, which do path searching use
474 the Kpathsea routines to do so. The precise names of the environment
475 and configuration file variables which get searched for particular file
476 formatted are therefore documented in the Kpathsea manual
477 (@pxref{Supported file formats,,, kpathsea, Kpathsea}). Reading
478 @file{texmf.cnf} (@pxref{Config files,,, kpathsea, Kpathsea}), invoking
479 @code{mktex@dots{}} scripts (@pxref{mktex scripts,,, kpathsea,
480 Kpathsea}), and so on are all handled by Kpathsea.
481
482 @cindex font aliases
483 @cindex aliases for fonts
484 @flindex texfonts.map
485 The programs which read fonts make use of another Kpathsea feature:
486 @file{texfonts.map}, which allows arbitrary aliases for the actual names
487 of font files; for example, @samp{Times-Roman} for @samp{ptmr8r.tfm}.
488 The distributed (and installed by default) @file{texfonts.map} includes
489 aliases for many widely available PostScript fonts by their PostScript
490 names.
491
492
493 @node Output file location
494 @section Output file location
495
496 @cindex output file location
497 @cindex current directory, used for output
498 @flindex .@r{, used for output}
499 All the programs generally follow the usual convention for output
500 files; namely, they are placed in the directory current when the
501 program is run, regardless of any input file location; or, in a few
502 cases, output is to standard output. The main programs (@TeX{},
503 Metafont, MetaPost) provide several ways to override this, as
504 explained below.
505
506 For example, if you run @samp{tex /tmp/foo}, by default the output
507 will be in @file{./foo.dvi} and @file{./foo.log}, not
508 @file{/tmp/foo.dvi} and @file{/tmp/foo.log}.
509
510 @cindex input from the output directory
511 @cindex reading from the output directory
512 An explicitly-given output location is also checked for input files,
513 as @TeX{} often generates files that need to be subsequently read.
514 For input, the input filename is simply checked as given. No
515 suffixes, such as @samp{.tex}, are added by default, and no exhaustive
516 path searching is done.
517
518 @subheading Override 1: @samp{-output-directory} option
519
520 @opindex -output-directory
521 @cindex output directory, specifying
522 If the @samp{-output-directory} option is specified, all output files
523 that would normally be written in the current directory are written in
524 the specified directory instead. @xref{Common options}.
525
526 @subheading Override 2: @code{TEXMF_OUTPUT_DIRECTORY} environment variable
527
528 @vindex TEXMF_OUTPUT_DIRECTORY
529 @findex \write18@r{, output location for}
530
531 Furthermore, if the @samp{-output-directory} option is specified, its
532 argument is saved in the environment variable
533 @code{TEXMF_OUTPUT_DIRECTORY}. This is for the benefit of any
534 subprograms that might be called via @code{\write18} (@pxref{Shell
535 escapes}), such as @command{kpsewhich} (@pxref{Invoking
536 kpsewhich,,,kpathsea,Kpathsea}). (This feature was added in @TeX{}
537 Live 2024.)
538
539 If the @samp{-output-directory} option is not specified, but the
540 environment variable @code{TEXMF_OUTPUT_DIRECTORY} is set, then the
541 environment variable value is used just as if it had been given to the
542 option.
543
544 Warning: we most strongly recommend always setting
545 @code{TEXMF_OUTPUT_DIRECTORY} temporarily, for a given run. It has
546 great potential for confusion, since with it set, output files will
547 not be in the expected place. To reduce this chance somewhat,
548 @code{TEXMF_OUTPUT_DIRECTORY} must be set in the environment, not a
549 configuration file.
550
551 @subheading Override 3: @code{TEXMFOUTPUT} environment variable
552
553 @vindex TEXMFOUTPUT@r{, used if @samp{.} unwritable}
554 @cindex readonly directory, running @TeX{} in
555 @cindex readonly directory, running @TeX{} in
556
557 Finally, if neither @samp{-output-directory} nor
558 @code{TEXMF_OUTPUT_DIRECTORY} is set, @emph{and} an output file is not
559 writable, then the main programs (@TeX{}, Metafont, MetaPost), plus
560 Bib@TeX{} for this one case, make an exception: if the config file or
561 environment variable value @code{TEXMFOUTPUT} is set (it is not by
562 default), the output file is written to the directory specified.
563 Usually this is because the current directory is not writable, and
564 thus all output files are written to @code{TEXMFOUTPUT}, but
565 technically it works on a file-by-file basis.
566
567 None of these explicitly-given output locations are checked until (and
568 unless) the program needs to write a file. For example, the
569 invocation@* @code{tex --output-directory=/nonesuch \\end}@* won't
570 generate an error until @TeX{} tries to write the log file:@* @samp{!
571 I can't write on file `texput.log'.}.
572
573
574 @node Three programs
575 @chapter Three programs: Metafont, MetaPost, and @TeX{}
576
577 @cindex three programs
578 @cindex @TeX{}, Metafont, and MetaPost
579 @cindex Metafont, MetaPost, and @TeX{}
580 @cindex MetaPost, @TeX{}, and Metafont
581
582 @TeX{}, Metafont, and MetaPost have a number of features in common.
583 Besides the ones here, command-line options and other commonalities
584 are described in the previous section.
585
586 @menu
587 * Runtime options:: The @file{texmf.cnf} configuration file.
588 * Initial and virgin:: Making memory dumps vs. production runs.
589 * Memory dumps:: .fmt/.base files for fast startup.
590 * Editor invocation:: The `e' response at errors.
591 * \input filenames:: Filename delimiters and Kpathsea expansion.
592 @end menu
593
594
595 @node Runtime options
596 @section Runtime options
597
598 @cindex runtime options
599
600 @cindex configuration file values
601 @cindex array sizes
602 @flindex texmf.cnf
603 Besides the configure- and compile-time options described in the
604 installation section (@pxref{Installation}), you can control a number
605 of parameters in the @file{texmf.cnf} runtime file read by Kpathsea
606 (@pxref{Config files,,, kpathsea, Kpathsea}).
607
608 The main purpose of @file{texmf.cnf} is to specify search paths, but
609 array sizes and other options are also set there. Most are rather
610 obscure. Here are a few of the more interesting values:
611
612 @vtable @samp
613 @item main_memory
614 Total words of memory available, for @TeX{}, Metafont, and MetaPost.
615 Must remake the format file after changing.
616
617 @item extra_mem_bot
618 @cindex boxes, memory for
619 @cindex glue, memory for
620 @cindex breakpoints, memory for
621 @cindex PiC@TeX{}, increasing memory for
622 Extra space for ``large'' @TeX{} data structures (default 0): boxes,
623 glue, breakpoints, et al. If you use PiC@TeX{}, you may well want to
624 set this.
625
626 @item expand_depth
627 @cindex recursive expansion limit
628 @cindex expansion limit, recursive
629 @cindex runtime stack overflow
630 @cindex overflow, of runtime stack
631 @cindex segmentation fault
632 @vindex SIGSEGV
633 Limit on recursive expansion calls before @TeX{} aborts (default
634 10000). If a @TeX{} program does an unterminated recursive expansion,
635 @TeX{} will dutifully expand macros until the system's runtime stack
636 overflows, typically with a segmentation fault (SIGSEGV). This
637 parameter was introduced to minimize the chance of that unpleasant
638 (though not dangerous) crash, instead allowing @TeX{} to quit with a
639 more informative message.
640
641 @pindex libsigsegv @r{library}
642 The crash can still happen, though, if the system has an exceptionally
643 small memory allocation for its stack. There is no quantitative way to
644 determine the limit, and it does not seem worth implementing
645 system-dependent heuristics to guess at the number, since it's highly
646 improbable that any real @TeX{} code will ever need more than 10000
647 recursive expansions (it has never happened). For the same reason,
648 using the libsigsegv library (@url{https://gnu.org/s/libsigsegv}) does
649 not seem worth the effort.
650
651 @item texmf_casefold_search
652 @xref{Casefolding search,,, kpathsea, Kpathsea}.
653
654 @end vtable
655
656 @cindex array limit, fixed
657 @cindex swap space, as array limit
658 @cindex reallocation of arrays
659 @cindex dynamic array allocation
660 Ideally all arrays would be dynamically expanded as necessary, so the
661 only limiting factor would be the amount of swap space available, or
662 some configurable limit much larger than can currently be supported.
663
664 Unfortunately, implementing this is extremely difficult, as the fixed
665 size of arrays is assumed in many places throughout the source code.
666 These runtime limits are a practical compromise between the
667 compile-time limits in previous versions, and truly dynamic arrays.
668 (On the other hand, the Web2c Bib@TeX{} implementation does do true
669 dynamic reallocation of some arrays.)
670
671 @cindex modifying @file{texmf.cnf} in @TeX{} Live
672 @cindex location of @file{texmf.cnf} in @TeX{} Live
673 Nowadays there is rarely a reason to modify the values. But if you do
674 wish to modify @file{texmf.cnf}, in @TeX{} Live the best approach is
675 to put your changes, and only your changes at the top of the TL
676 installation tree. That is, if the system @file{texmf.cnf} is
677 installed in
678 @file{/some/path/to/texlive/YYYY/texmf-dist/web2c/texmf.cnf} is put
679 your custom settings in @file{/some/path/to/texlive/YYY/texmf.cnf},
680 where @var{YYYY} is the year of installation (if you use that
681 subdirectory; it's the default). That way, unrelated changes to the
682 system @file{texmf.cnf} can happen with normal updates, without
683 affecting your local values.
684
685
686 @node Initial and virgin
687 @section Initial and virgin
688
689 @cindex executables, shared initial and virgin
690 The @TeX{} and Metafont programs each have two main variants, called
691 @dfn{initial} and @dfn{virgin}. MetaPost no longer makes this
692 distinction.
693
694 The initial form is enabled if:
695 @enumerate
696 @item
697 @opindex -ini
698 the @samp{-ini} option was specified; or
699 @item
700 the program name is @file{initex} resp.@: @file{inimf}; or
701 @item
702 the first line of the main input file is @samp{%&ini};
703 @end enumerate
704 @noindent
705 otherwise, the virgin form is used.
706
707 @cindex virgin programs
708 @cindex production use
709 The @dfn{virgin} form is the one generally invoked for production use.
710 The first thing it does is read a memory dump (@pxref{Determining the
711 memory dump to use}), and then proceeds on with the main job.
712
713 @cindex initial programs
714 @cindex initializations, lengthy
715 The @dfn{initial} form is generally used only to create memory dumps
716 (see the next section). It starts up more slowly than the virgin form,
717 because it must do lengthy initializations that are encapsulated in the
718 memory dump file.
719
720
721 @node Memory dumps
722 @section Memory dumps
723
724 @cindex memory dumps
725
726 @cindex dumping memory
727 @cindex macros, predefining in memory dumps
728 @cindex predefined macros and memory dumps
729 In typical use, @TeX{} and Metafont require a large number of
730 macros to be predefined; therefore, they support @dfn{memory dump}
731 files, which can be read much more efficiently than ordinary source
732 code.
733
734 @menu
735 * Creating memory dumps::
736 * Determining the memory dump to use::
737 * Hardware and memory dumps::
738 @end menu
739
740
741 @node Creating memory dumps
742 @subsection Creating memory dumps
743
744 @cindex memory dumps, creating
745 @cindex creating memory dumps
746 @cindex writing memory dumps
747
748 The programs both create memory dumps in slightly idiosyncratic (thought
749 substantially similar) way, so we describe the details in separate
750 sections (references below). The basic idea is to run the initial
751 version of the program (@pxref{Initial and virgin}), read the source
752 file to define the macros, and then execute the @code{\dump} primitive.
753
754 Also, each program uses a different filename extension for its memory
755 dumps, since although they are completely analogous they are not
756 interchangeable (@TeX{} cannot read a Metafont memory dump, or vice
757 versa).
758
759 Here are the filename extensions with references to examples of
760 creating memory dumps:
761
762 @table @asis
763 @item @TeX{}
764 (@samp{.fmt}) @xref{Initial TeX,,Initial @TeX{}}.
765
766 @item Metafont
767 (@samp{.base}) @xref{Initial Metafont}.
768 @end table
769
770 MetaPost used to have an equivalent memory dump, called @samp{.mem},
771 but no longer uses this; it now reads only source files.
772
773 When making memory dumps, the programs read environment variables and
774 configuration files for path searching and other values as usual. If
775 you are making a new installation and have environment variables
776 pointing to an old one, for example, you will probably run into
777 difficulties.
778
779
780 @node Determining the memory dump to use
781 @subsection Determining the memory dump to use
782
783 @cindex memory dump to use, determining
784 @cindex fmt file, determining
785 @cindex base file, determining
786
787 The virgin form (@pxref{Initial and virgin}) of each program always
788 reads a memory dump before processing normal source input. All three
789 programs determine the memory dump to use in the same way:
790
791 @enumerate
792 @item
793 If the first non-option command-line argument begins with @samp{&}, the
794 program uses the remainder of that argument as the memory dump name.
795 For example, running @samp{tex \&super} reads @file{super.fmt}. The
796 backslash merely protects the @samp{&} against interpretation by the
797 shell; quotes could also be used. @TeX{} must see only the @samp{&}.
798
799 @item
800 @opindex -fmt=@var{fmt}
801 @opindex -base=@var{base}
802 If the @samp{-fmt} resp.@: @samp{-base} option is
803 specified, its value is used.
804
805 @item
806 @opindex -progname=@var{string}
807 If the @samp{-progname} option is specified, its value is used.
808
809 @item
810 @kindex %& @r{magic number}
811 If the first line of the main input file (which must be specified on
812 the command line, not in response to the @samp{**} prompt) is
813 @code{%&@var{dump}}, and @var{dump} is an existing memory dump of the
814 appropriate type, @var{dump} is used.
815
816 The first line of the main input file can also specify which character
817 translation file is to be used: @code{%&-translate-file=@var{tcxfile}}
818 (@pxref{TCX files}).
819
820 These two roles can be combined: @code{%&@var{dump}
821 -translate-file=@var{tcxfile}}. If this is done, the name of the dump
822 must be given first.
823
824 @item
825 @cindex program name, determines memory dump
826 @cindex links to binaries
827 Otherwise, the program uses the program invocation name, most simply
828 @file{tex} resp.@: @file{mf}. For example, if @file{latex} is a link
829 to @file{tex}, and the user runs @samp{latex foo}, @file{latex.fmt}
830 will be used.
831
832 @end enumerate
833
834 @node Hardware and memory dumps
835 @subsection Hardware and memory dumps
836
837 @cindex hardware and memory dumps
838 @cindex memory dumps and hardware
839 @cindex sharing memory dumps
840 @cindex portable memory dumps
841 @cindex fmt files, sharing
842 @cindex base files, sharing
843
844 @cindex LittleEndian machines
845 @cindex BigEndian machines
846 @cindex endian dependencies
847 @cindex machine dependencies
848 @cindex architecture dependencies
849 @cindex dependencies, hardware
850 @cindex 32-bit architecture
851 @cindex 64-bit architecture
852 @cindex @code{long} data type, size of
853 By default, most memory dump files are sharable among architectures of
854 different types; specifically, among machines of different endianness
855 (@pxref{Byte order,,, libc, GNU C Library}) and with different word
856 sizes (4-byte @code{long} vs.@: 8-byte @code{long}). This is a
857 feature of the Web2c implementation, and is not true of all @TeX{}
858 implementations.
859
860 @cindex Lua, and unportable memory dumps
861 However, with the advent of Lua as an embedded scripting language,
862 some dumps have become unportable, namely @code{lualatex},
863 @code{optex}, and @code{context}. These formats precompile Lua code
864 into bytecode, which is architecture-specific for the sake of speed.
865 With @TeX{} Live, if you need to support multiple architectures with
866 the same tree, you can explicitly set @code{TEXMFSYSVAR} to different
867 directories on the different systems. More discussion:
868 @url{https://github.com/latex3/latex2e/issues/775}.
869
870 @pindex tl-check-fmtshare
871 The script @code{tl-check-fmtshare} in the @TeX{} Live source tree
872 (@file{Master/tlpkg/bin}) provides a relatively easy way to test that
873 a @file{.fmt} built on the local host can be loaded by a @TeX{} engine
874 built on some remote host.
875
876 @cindex byte swapping
877 @cindex swapping bytes
878 @opindex --disable-dump-share configure @r{option}
879 If you specify @samp{--disable-dump-share} to @code{configure},
880 however, memory dumps will be endian-dependent. The reason to do this
881 is speed. To achieve endian-independence, the reading of memory dumps
882 on LittleEndian architectures, such as PC's and DEC architectures, is
883 somewhat slowed (all the multibyte values have to be swapped).
884 Usually, this is not noticeable, and the advantage of being able to
885 share memory dumps across all platforms at a site outweighs the speed
886 loss. But if you're trying to squeeze out every possible bit of
887 performance, you may wish to do this.
888
889 @cindex floating-point values
890 @cindex glue ratio representations
891 @TeX{}nically, even without @samp{--disable-dump-share}, sharing of
892 @file{.fmt} files cannot be guaranteed to work. Floating-point values
893 are always written in native format, and hence will generally not be
894 readable across platforms. Fortunately, @TeX{} uses floating point
895 only to represent glue ratios, and none of the common formats (plain,
896 @LaTeX{}, AMS@TeX{}, @dots{}) do any glue setting at
897 @file{.fmt}-creation time. Metafont does not use floating point in
898 any dumped value at all.
899
900 @cindex date and time, in memory dumps
901 @cindex time and date, in memory dumps
902 @cindex memory dumps, contain date and time
903 Different memory dump files will never compare equal byte-for-byte,
904 because the programs dump the current date and time. So don't be
905 alarmed by this difference.
906
907 @cindex Harbison, Samuel P.
908 @cindex Steele Jr., Guy L.
909 If you don't know what endianness your machine is, and you're curious,
910 here is a little C program to tell you. (The @code{configure} script
911 contains a similar program.) This is from the book @cite{C: A Reference
912 Manual}, by Samuel P. Harbison and Guy L. Steele
913 Jr@:. (@pxref{References}).
914
915 @example
916 main ()
917 @{
918 /* Are we little or big endian? From Harbison&Steele. */
919 union
920 @{
921 long l;
922 char c[sizeof (long)];
923 @} u;
924 u.l = 1;
925 if (u.c[0] == 1)
926 printf ("LittleEndian\n");
927 else if (u.c[sizeof (long) - 1] == 1)
928 printf ("BigEndian\n");
929 else
930 printf ("unknownEndian");
931
932 exit (u.c[sizeof (long) - 1] == 1);
933 @}
934 @end example
935
936 You can add @code{printf("long %d\n", sizeof(long));} to see the size
937 of the @code{long} data type.
938
939
940 @node Editor invocation
941 @section Editor invocation
942
943 @cindex editor invoked at error
944 @cindex errors, editor invoked at
945 @opindex e @r{response at error prompt}
946
947 @TeX{}, Metafont, and MetaPost all (by default) stop and ask for user
948 intervention at an error. If the input came from a file, and the user
949 responds with @kbd{e} or @kbd{E}, the program invokes an editor.
950
951 @vindex TEXEDIT
952 @vindex MFEDIT
953 @vindex MPEDIT
954 @opindex --with-editor=@var{cmd}
955 @flindex texmf.cnf @r{for editors}
956 Specifying @samp{--with-editor=@var{cmd}} to @code{configure} sets the
957 default editor command string to @var{cmd}. The environment
958 variables/configuration values @code{TEXEDIT}, @code{MFEDIT}, and
959 @code{MPEDIT} (respectively) override this. If @samp{--with-editor} is
960 not specified, the default is @code{vi +%d %s} on Unix, and an
961 invocation of the @TeX{}works editor on Windows. (See
962 @file{texmf.cnf} for the precise values.)
963
964 In this string, @samp{%d} is replaced by the line number of the error,
965 and @samp{%s} is replaced by the name of the current input file.
966
967
968 @node \input filenames
969 @section @code{\input} filenames
970
971 @cindex input filenames
972 @cindex filename conventions, in input files
973 @findex \input @r{filenames}
974
975 @c Nicer name to use in tex.1 man page.
976 @anchor{Input filenames}
977
978 @TeX{}, Metafont, and MetaPost source programs can all read other source
979 files with the @code{\input} (@TeX{}) and @code{input} (MF and MP)
980 primitives:
981 @example
982 \input @var{name} % in TeX
983 @end example
984
985 @cindex space-terminated filenames
986 @cindex whitespace-terminated filenames
987 @cindex terminator for filenames
988 The file @var{name} can always be terminated with whitespace; for
989 Metafont and MetaPost, the statement terminator @samp{;} also works.
990 (@LaTeX{} and other macro packages provide other interfaces to
991 @code{\input} that allow different notation; here we are concerned only
992 with the primitive operation.)
993
994 As an extension to standard @TeX{} (allowed by Knuth's conditions),
995 Web2c also supports specifying the filename in double quotes
996 (@code{"some name"}) and in a group, i.e., braces (@code{@{some
997 name@}}), which is convenient for filenames containing spaces or other
998 special characters, as described in the sections below.
999
1000 In all cases, space tokens are ignored after the filename is read.
1001
1002 @cindex @code{"} character, ignored in filenames
1003 @cindex double quote character, ignored in filenames
1004 Also, double quote (@code{"}) characters are ignored within the
1005 filename; there is no way to read files whose names contain a @code{"}.
1006
1007 @cindex portable filenames
1008 For maximal portability of your document across systems, use only the
1009 characters @samp{a}--@samp{z}, @samp{0}--@samp{9}, and at most one
1010 @samp{.}. Do not use anything but simple filenames, since directory
1011 separators vary among systems; instead, add the necessary directories
1012 to the appropriate search path.
1013
1014 @menu
1015 * Quotes: \input quoted filename. \input "some name"
1016 * Braces: \input braced filename. \input @{some name@}
1017 * Caveats: \input filename caveats. Tokenization, nulls, Kpathsea expansion.
1018 @end menu
1019
1020
1021 @node \input quoted filename
1022 @subsection @code{\input} quoted filename: @code{\input "some name"}
1023
1024 @cindex @code{\input} quoted filename
1025 @cindex quoted filename for @code{\input}
1026
1027 As of Web2c version 7.5.3 (2004), double-quote characters can be used
1028 to include spaces or other special characters. In typical use, the
1029 @samp{"} characters surround the entire filename:
1030 @example
1031 \input "filename with spaces"
1032 @end example
1033
1034 Technically, the quote characters can be used inside the name, and
1035 can enclose any characters, as in:
1036 @example
1037 \input filename" "with" "spaces
1038 @end example
1039
1040 One more point. In @LaTeX{}, the quotes are needed inside the braces
1041 of its @code{\input} macro, thus:
1042 @example
1043 \input@{a b@} % fails
1044 \input@{"a b"@} % ok
1045 @end example
1046
1047 There is no way to quote the quote character.
1048
1049
1050 @node \input braced filename
1051 @subsection @code{\input} braced filename: @code{\input@{some name@}}
1052
1053 @cindex @code{\input} braced (grouped) filename
1054 @cindex braced filename for @code{\input}
1055 @cindex group-delimited filename for @code{\input}
1056
1057 As of Web2c 2020, @code{\input} filenames in @TeX{} engines (this does
1058 not apply in Metafont and MetaPost) can also be specified within a
1059 @TeX{} group, typically curly braces. For example:
1060 @example
1061 \input@{filename with spaces@}
1062 @end example
1063
1064 As always with @TeX{}, the brace characters are not hardwired; what
1065 counts is the category code: the first token after the @code{\input}
1066 must be of catcode@tie{}1 (begin group), and it is matched with the
1067 next character of catcode@tie{}2 (end group).
1068
1069 Within the group-delimited filename, braces are treated as normal
1070 characters.
1071
1072 As with all forms of filenames, following spaces are ignored (after
1073 the end group), and double quote (@code{"}) characters are ignored
1074 within the filename.
1075
1076
1077 @node \input filename caveats
1078 @subsection @code{\input} filename caveats
1079
1080 @cindex @code{\input} filename caveats
1081 @cindex caveats for @code{\input} filenames
1082 @cindex tokenization, and @code{\input} filenames
1083 @cindex expansion, and @code{\input} filenames
1084 @cindex multiple spaces, and @code{\input} filenames
1085 @cindex tabs, and @code{\input} filenames
1086 The quoting mechanisms just described come into play @emph{after}
1087 @TeX{} has tokenized and expanded the input. So, multiple spaces and
1088 tabs will generally be seen as a single space, active characters such
1089 as @samp{~} are expanded first (generally causing an error), and so
1090 on. More examples below.
1091
1092 @cindex NUL bytes, not allowed in filenames
1093 @cindex eight-bit characters in filenames
1094 @cindex meta characters in filenames
1095 Various C library routines and Unix itself use the null byte
1096 (character code zero, ASCII NUL) to terminate strings. So filenames
1097 in Web2c cannot contain nulls, even though @TeX{} itself does not
1098 treat NUL specially.
1099
1100 @flindex CON@r{, reserved filename on Windows}
1101 @flindex NUL@r{, reserved filename on Windows}
1102 @flindex COM1@r{@code{..0}, reserved filename on Windows}
1103 Windows reserves a long list of alphanumeric filenames,
1104 case-insensitive and with any extension, such as @samp{CON},
1105 @samp{NUL}, @samp{COM1}, @samp{con.tex}, etc.; see Windows systems
1106 documentation for the whole list. Trying to use such names will cause
1107 a system error on Windows.
1108
1109 @kindex ~ @r{expansion in filenames}
1110 @kindex $ @r{expansion in filenames}
1111 Finally, the present Web2c implementation does @samp{~} and @samp{$}
1112 expansion on @var{name}, on all platforms, unlike Knuth's original
1113 program. Thus:
1114
1115 @example
1116 \input ~jsmith/$foo.bar
1117 @end example
1118
1119 @noindent will dereference the environment variable or Kpathsea config file
1120 value @samp{foo} and read that file, extended with @samp{.bar}, in
1121 user @samp{jsmith}'s home directory. You can also use braces in the
1122 variable expansion, as in @samp{$@{foo@}bar}, if you want to follow
1123 the variable name with a letter, numeral, or @samp{_}.
1124
1125 (So, another way to get a program to read a filename containing
1126 whitespace is to define an environment variable and dereference it.)
1127
1128 @findex \string@r{, and @code{\input filenames}}
1129 In all the common @TeX{} formats (plain @TeX{}, @LaTeX{}, Con@TeX{}t,
1130 @dots{}), the characters @samp{~} and @samp{$} have special category
1131 codes, so to use them within a document you have to change their
1132 catcodes or use @code{\string}.
1133
1134
1135 @node TeX
1136 @chapter @TeX{}: Typesetting
1137
1138 @cindex @TeX{}, description of
1139 @cindex typesetting
1140 @cindex mathematical typesetting
1141
1142 @TeX{} is a typesetting system: it was especially designed to handle
1143 complex mathematics, as well as most ordinary text typesetting.
1144
1145 @cindex batch languages
1146 @cindex word processor, not
1147 @TeX{} is a batch language, like C or Pascal, and not an interactive
1148 ``word processor'': you compile a @TeX{} input file into a corresponding
1149 device-independent (DVI) file (and then translate the DVI file to the
1150 commands for a particular output device). This approach has both
1151 considerable disadvantages and considerable advantages. For a complete
1152 description of the @TeX{} language, see @cite{The @TeX{}book}
1153 (@pxref{References}). Many other books on @TeX{}, introductory and
1154 otherwise, are available.
1155
1156 @menu
1157 * tex invocation:: Invoking TeX.
1158 * Initial TeX:: Making format files.
1159 * Formats:: Major TeX macro packages.
1160 * Languages and hyphenation:: TeX supports many human languages.
1161 * Shell escapes:: Running subprograms from TeX.
1162 * IPC and TeX:: DVI output to a socket.
1163 * TeX extensions:: Additional engines with additional features.
1164 @end menu
1165
1166
1167 @node tex invocation
1168 @section @code{tex} invocation
1169
1170 @pindex tex
1171 @cindex @TeX{}, invocation
1172
1173 @TeX{} (usually invoked as @code{tex}) formats the given text and
1174 commands, and outputs a corresponding device-independent representation
1175 of the typeset document. This section merely describes the options
1176 available in the Web2c implementation. For a complete description of
1177 the @TeX{} typesetting language, see @cite{The @TeX{}book}
1178 (@pxref{References}).
1179
1180 @TeX{}, Metafont, and MetaPost process the command line (described
1181 here) and determine their memory dump (fmt) file in the same way
1182 (@pxref{Memory dumps}). Synopses:
1183
1184 @example
1185 tex [@var{option}]@dots{} [@var{texname}[.tex]] [@var{more-input}]
1186 tex [@var{option}]@dots{} \@var{more-input}
1187 tex [@var{option}]@dots{} &@var{fmt} @var{first-line}
1188 @end example
1189
1190 In short, @TeX{} prepends @code{\input } to non-option command line
1191 arguments or the input to the @samp{**} prompt, and then processes the
1192 result as normal @TeX{} input, including expansion.
1193
1194 The most common invocation is @samp{tex somefile}, which reads
1195 @samp{somefile.tex}, normally from the current directory. It is
1196 equivalent to @code{\input somefile}.
1197
1198 In more detail:
1199
1200 @flindex .tex
1201 @cindex @TeX{}, input files found
1202 @TeX{} searches the usual places for the main input file @var{texname}
1203 (@pxref{Supported file formats,,, kpathsea, Kpathsea}), extending
1204 @var{texname} with @file{.tex} if necessary. To see all the
1205 relevant paths, set the environment variable @code{KPATHSEA_DEBUG} to
1206 @samp{-1} before running the program.
1207
1208 After @var{texname} is read, @TeX{} processes any remaining
1209 @var{more-input} on the command line as regular @TeX{} input. Also,
1210 if the first non-option argument begins with a @TeX{} escape character
1211 (usually @code{\}), @TeX{} processes all non-option command-line
1212 arguments as a line of regular @TeX{} input. The backslash or other
1213 escape character usually has to be escaped to avoid being processed by
1214 your shell.
1215
1216 If no arguments or options are specified, @TeX{} prompts for an input
1217 filename with @samp{**}. Whatever input is given in response to
1218 @samp{**} is processed exactly like a command line not starting with
1219 an escape character, i.e., @code{\input} is prepended and then the
1220 entire line is processed as normal @TeX{} intput.
1221
1222 Thus, the text of an input filename, as well as any text following a
1223 filename, is subject to @TeX{}'s normal macro expansion. As a result, a
1224 @samp{~} character is normally not usable within a filename, since by
1225 default @samp{~} is defined (in plain @TeX{}, @LaTeX{}, etc.)@: to be
1226 an active character that expands into several primitive tokens that
1227 can't be part of a filename. As a special case in Web2c, a @samp{~}
1228 @emph{beginning} a filename refers to a user's home directory
1229 (@pxref{\input filename caveats}), but you still have to arrange for
1230 @TeX{} to see a @samp{~} character rather than the expansion of @samp{~}.
1231
1232 To summarize the usual cases (in all these cases, @code{tex} also
1233 reads @file{tex.fmt} before starting any processing):
1234
1235 @itemize
1236 @item @samp{tex foo} executes @samp{\input foo}.
1237
1238 @item @samp{tex foo bar} executes @samp{\input foo bar}, which inputs
1239 @file{foo.tex} and then typesets @samp{bar}.
1240
1241 @item @samp{tex \\end} executes @samp{\end}; here the double backslash
1242 is one common way of escaping the backslash for the shell. @TeX{} only
1243 sees one backslash.
1244
1245 @item @samp{tex} with no arguments prints a @samp{**} prompt.
1246 Entering @samp{foo bar} at the @samp{**} prompt again executes
1247 @samp{\input foo} and typesets @samp{bar}.
1248 @end itemize
1249
1250 @flindex texput
1251 @TeX{} writes its main output, a DVI file, to
1252 @file{@var{basetexname}.dvi}, where @var{basetexname} is the basename
1253 of @var{texname}, or @samp{texput} if no input file was specified.
1254
1255 A DVI file is a device-independent binary representation of your
1256 document. You can translate the DVI file, using independent programs,
1257 to whatever may be needed, such as a PDF file (see dvipdfmx(1)),
1258 a PostScript file (@pxref{Top,,Introduction,dvips,Dvips}), an SVG file
1259 (see dvisvgm(1)), etc. There are also variants of @TeX{} that can
1260 produce PDF files directly, namely pdf@TeX{} and Lua@TeX{} (@pxref{TeX
1261 extensions}).
1262
1263 The program accepts the following options, as well as the standard
1264 @samp{-help} and @samp{-version} (@pxref{Common options}):
1265
1266 @table @samp
1267 @item -enc
1268 @itemx -[no]-file-line-error
1269 @itemx -fmt=@var{fmtname}
1270 @itemx -halt-on-error
1271 @itemx -ini
1272 @itemx -interaction=@var{string}
1273 @itemx -ipc
1274 @itemx -ipc-start
1275 @itemx -jobname=@var{string}
1276 @itemx -kpathsea-debug=@var{number}
1277 @itemx -[no]parse-first-line
1278 @itemx -output-directory
1279 @itemx -progname=@var{string}
1280 @itemx -recorder
1281 @itemx -translate-file=@var{tcxfile}
1282 @itemx -8bit
1283 These options are common to @TeX{}, Metafont, and MetaPost.
1284 @xref{Common options}.
1285
1286 @item -enc
1287 @opindex -enc
1288 @cindex Unicode input
1289 @cindex UTF-8 input
1290 Enable enc@TeX{} extensions, such as @code{\mubyte}. This can be used
1291 to support the Unicode UTF-8 input encoding, although using an engine
1292 with native Unicode support is more common nowadays.
1293 @url{http://www.olsak.net/enctex.html}.
1294
1295 @item -ipc
1296 @itemx -ipc-start
1297 @opindex -ipc
1298 @opindex -ipc-start
1299 @opindex --enable-ipc configure @r{option}
1300 With either option, @TeX{} writes its DVI output to a socket as well as
1301 to the usual @file{.dvi} file. With @samp{-ipc-start}, @TeX{} also
1302 opens a server program at the other end to read the output. @xref{IPC
1303 and TeX,,IPC and @TeX{}}.
1304
1305 These options are available only if the @samp{--enable-ipc} option was
1306 specified to @code{configure} during installation of Web2c.
1307
1308 @item -mktex=@var{filetype}
1309 @itemx -no-mktex=@var{filetype}
1310 @opindex -mktex=@var{filetype}
1311 @opindex -no-mktex=@var{filetype}
1312 Turn on or off the @samp{mktex} script associated with @var{filetype}.
1313 For @TeX{} proper, @var{filetype} can only be @samp{tex} and
1314 @samp{tfm}, but for pdf@TeX{} and Lua@TeX{}, it can also be @samp{pk}.
1315
1316 @item -mltex
1317 @opindex -mltex
1318 @cindex ML@TeX{}, enabling
1319 @cindex program names, special
1320 If we are @code{INITEX} (@pxref{Initial and virgin}), enable ML@TeX{}
1321 extensions such as @code{\charsubdef}. Implicitly set if the program
1322 name is @code{mltex}. @xref{MLTeX,,ML@TeX{}}.
1323
1324 @item -output-comment=@var{string}
1325 @opindex -output-comment=@var{string}
1326 @vindex output_comment @r{for DVI files}
1327 @cindex DVI comment, specifying
1328 @cindex regression testing
1329 Use @var{string} as the DVI file comment. Ordinarily, this comment
1330 records the date and time of the @TeX{} run, but if you are doing
1331 regression testing, you may not want the DVI file to have this spurious
1332 difference. This is also taken from the environment variable and
1333 config file value @samp{output_comment}.
1334
1335 @item -shell-escape
1336 @opindex -shell-escape
1337 @itemx -no-shell-escape
1338 @opindex -no-shell-escape
1339 @itemx -shell-restricted
1340 @opindex -shell-restricted
1341 Enable, or disable, or enable with restrictions the
1342 @code{\write18@{@var{shell-command}@}} feature for external execution of
1343 shell commands. @xref{Shell escapes}.
1344
1345 @item -enable-write18
1346 @opindex -enable-write18
1347 @itemx -disable-write18
1348 @opindex -disable-write18
1349 Synonyms for @option{-shell-escape} and @option{-no-shell-escape}, for
1350 compatibility with MiK@TeX{}. (MiK@TeX{} also accepts both pairs of
1351 options.) @xref{Shell escapes}.
1352
1353 @item -src-specials
1354 @itemx -src-specials=@var{string}
1355 @cindex generating source specials
1356 This option makes @TeX{} output specific source information using
1357 @samp{\special} commands in the DVI file. These @samp{\special} track
1358 the current filename and line number.
1359
1360 Using the first form of this option, the @samp{\special} commands are
1361 inserted automatically.
1362
1363 In the second form of the option, @var{string} is
1364 a comma separated list of the following values: @samp{cr},
1365 @samp{display}, @samp{hbox}, @samp{math}, @samp{par}, @samp{parend},
1366 @samp{vbox}. You can use this list to specify where you want @TeX{} to
1367 output such commands. For example, @samp{-src-specials=cr,math} will
1368 output source information every line and every math formula.
1369
1370 These commands can be used with the appropriate DVI viewer and text
1371 editor to switch from the current position in the editor to the same
1372 position in the viewer and back from the viewer
1373 to the editor.
1374
1375 This option works by inserting @samp{\special} commands into the token
1376 stream, and thus in principle these additional tokens can be recovered
1377 or seen by the tricky-enough macros. If you run across a case, let us
1378 know, because this counts as a bug. However, such bugs are very hard
1379 to fix, requiring significant changes to @TeX{}, so please don't count
1380 on it.
1381
1382 Redefining @samp{\special} will not affect the functioning of this
1383 option. The commands inserted into the token stream are
1384 hard-coded to always use the @samp{\special} primitive.
1385
1386 @TeX{} does not pass the @code{TRIP} test when this option is enabled.
1387
1388 @end table
1389
1390 Other input and output that can happen:
1391
1392 @itemize
1393 @item
1394 @pindex mktextfm@r{, disabling}
1395 @findex \font @r{and dynamic generation}
1396 @TeX{} also reads TFM files for any fonts you load in your document with
1397 the @code{\font} primitive. By default, it runs an external program
1398 named @file{mktextfm} to create any nonexistent TFM files. You can
1399 disable this at configure-time or runtime (@pxref{mktex
1400 configuration,,, kpathsea, Kpathsea}).
1401
1402 @item
1403 @findex \openout @r{and security}
1404 @cindex security, and @code{\openout}
1405 @cindex output files, written by @TeX{} programs
1406 @cindex Trojan horses and @TeX{} programs
1407 @cindex dot files, written by @TeX{} programs
1408 @cindex security, and output files
1409 @TeX{} can write output files, via the @code{\openout} primitive. This
1410 raises the possibility of a Trojan horse attack: an unwitting user
1411 could run a @TeX{} program that overwrites, say,
1412 @file{$HOME/.ssh/authorized_keys}. (MetaPost has a @code{write}
1413 primitive with similar implications.)
1414
1415 To alleviate this and similar problems, the functions
1416 @code{kpathsea_out_name_ok} and @code{kpathsea_in_name_ok} from the
1417 Kpathsea library (@pxref{Calling sequence,,, kpathsea, Kpathsea}) are
1418 used to determine if a given filename is acceptable to be opened for
1419 output or input, depending on the setting of the configuration
1420 variables @code{openout_any} and @code{openin_any}: @samp{a} (for
1421 ``any'', the default for @code{openin_any}), @samp{r} (for
1422 ``restricted''), or @samp{p} (for ``paranoid'', the default for
1423 @code{openout_any}).
1424
1425 In any case, all @code{\openout} filenames are recorded in the log file,
1426 except those opened on the first line of input, which is processed before
1427 the log file has been opened.
1428
1429 @end itemize
1430
1431 @node Initial TeX
1432 @section Initial @TeX{}
1433
1434 @cindex initial @TeX{}
1435 @cindex @TeX{}, initial
1436
1437 @flindex .fmt
1438 @cindex fmt files
1439 The @dfn{initial} form of @TeX{} is invoked by @samp{tex -ini}. It
1440 does lengthy initializations avoided by the ``virgin'' (@code{vir})
1441 form, so as to be capable of dumping @samp{.fmt} files (@pxref{Memory
1442 dumps}). For a detailed comparison of virgin and initial forms,
1443 @pxref{Initial and virgin}.
1444
1445 For a list of options and other information, @pxref{tex invocation}.
1446
1447 @flindex plain.fmt
1448 @flindex tex.fmt
1449 @cindex format files
1450 Unlike Metafont and MetaPost, many format files are commonly used with
1451 @TeX{}. The standard one implementing the features described in
1452 @cite{The @TeX{}book} is @samp{plain.fmt}, also known as
1453 @samp{tex.fmt} (again, @pxref{Memory dumps}). It is created by
1454 default during installation, but you can also do so by hand if
1455 necessary:
1456
1457 @example
1458 tex -ini '\input plain \dump'
1459 @end example
1460
1461 @noindent
1462 (The quotes prevent interpretation of the backslashes from the shell.)
1463 Then put the resulting @file{plain.fmt} where @TeX{} will find it, and
1464 link @file{tex.fmt} to it. Any existing @file{tex.fmt} can be found
1465 with the invocation:
1466
1467 @example
1468 kpsewhich --all --engine=/ tex.fmt
1469 @end example
1470
1471 @xref{Formats}, for more details on @TeX{} formats.
1472
1473 @node Formats
1474 @section Formats
1475
1476 @cindex formats for @TeX{}
1477 @cindex @TeX{}, format packages for
1478 @cindex macro packages, major @TeX{}
1479
1480 @TeX{} @dfn{formats} are large collections of macros, often dumped
1481 into a @file{.fmt} file (@pxref{Memory dumps}) by @code{tex -ini}
1482 (@pxref{Initial TeX}). A number of formats are in reasonably
1483 widespread use. The formats are generally selected, installed, and
1484 updated as part of a larger @TeX{} distribution, such as @TeX{} Live
1485 (@url{https://tug.org/texlive}).
1486
1487 @table @t
1488 @item latex
1489 @cindex @LaTeX{}
1490 The most widely used format, called @LaTeX{}, based on @LaTeX{}2e and
1491 also incorporating @LaTeX{}3; new versions are released approximately
1492 every six months, with patches issued as needed. The old release was
1493 called `@LaTeX{} 2.09', and is no longer maintained or supported,
1494 though compatibility for 2.09 documents is retained. @LaTeX{}
1495 attempts to provide generic markup instructions, such as
1496 ``emphasize'', instead of specific typesetting instructions, such as
1497 ``use the 10@dmn{pt} Computer Modern italic font''. The @LaTeX{} home
1498 page: @url{https://www.latex-project.org}.
1499
1500 @item latex-dev
1501 @cindex @command{latex-dev}
1502 @cindex @LaTeX{} testing
1503 @cindex testing @LaTeX{}
1504 A set of formats and executables made so that anyone interested can
1505 easily help test upcoming @LaTeX{} releases. They correspond to new
1506 formats which have been tested by the @LaTeX{} team for stability and
1507 usability. Testing by as many users as possible is desired and
1508 requested. Simply changing the regular engine name (e.g.,
1509 @command{pdflatex}), to have a @t{-dev} suffix
1510 (@command{pdflatex-dev}) in your invocations is all that should be
1511 needed. No changes to source documents should be required.
1512
1513 @item context
1514 @cindex Con@TeX{}t
1515 Con@TeX{}t is an independent macro package which also supports a
1516 document structuring approach. It can also create interactive PDF
1517 files and has an integrated MetaPost library for graphics, among many
1518 other advanced features. It uses its own engine, LuaMeta@TeX{},
1519 developed in tandem. The Con@TeX{}t home page:
1520 @url{http://www.pragma-ade.com}.
1521
1522 @item eplain
1523 @cindex Eplain
1524 @cindex expanded plain format
1525 An ``expanded plain'' format that provides various common features
1526 (e.g., symbolic cross-referencing, tables of contents, indexing,
1527 citations using Bib@TeX{}), for those authors who prefer to handle
1528 their own high-level formatting. The Eplain home page:
1529 @url{https://tug.org/eplain}.
1530
1531 @item texinfo
1532 @cindex Texinfo
1533 @cindex Info format
1534 @cindex Free Software Foundation documentation system
1535 The documentation system developed and maintained by the Free Software
1536 Foundation for their software manuals. It can be automatically
1537 converted into HTML, plain text, a machine-readable online format
1538 called Info, etc. The Texinfo home page:
1539 @url{https://www.gnu.org/software/texinfo}.
1540
1541 @item amstex
1542 @cindex AMS@TeX{}
1543 @cindex American Mathematical Society, typesetting system
1544 @cindex Mathematical Reviews
1545 This was the official typesetting system of the American Mathematical
1546 Society; nowadays, the AMS recommends authors use @LaTeX{}; the AMS
1547 provides a number of @LaTeX{} packages important for math typesetting.
1548 The AMS's @TeX{} page:
1549 @url{https://www.ams.org/tex}.
1550
1551 @item slitex
1552 @cindex Sli@TeX{}
1553 @cindex slides, producing
1554 @flindex beamer@r{, package}
1555 @flindex slides@r{, package}
1556 @flindex ltx-talk@r{, package}
1557 An obsolete @LaTeX{} 2.09 format for making slides. In core
1558 @LaTeX{}2e, it is replaced by the @samp{slides} document class. As of
1559 2025, the @samp{ltx-talk} class is also provided for typesetting
1560 presentations, including accessibility support:
1561 @url{https://ctan.org/pkg/ltx-talk}. The @samp{beamer} package is
1562 perhaps the most commonly used method for making slides nowadays:
1563 @url{https://ctan.org/pkg/beamer}.
1564
1565 @end table
1566
1567
1568 @node Languages and hyphenation
1569 @section Languages and hyphenation
1570
1571 @cindex language support in @TeX{}
1572 @cindex human languages, supported in @TeX{}
1573 @cindex hyphenation and languages
1574
1575 @TeX{} supports most natural languages. See also @ref{TeX extensions,,
1576 @TeX{} extensions}.
1577
1578 @menu
1579 * MLTeX:: Multi-lingual TeX.
1580 * TCX files:: Support for different character sets & fonts.
1581 * patgen invocation:: Creating hyphenation patterns.
1582 @end menu
1583
1584
1585 @node MLTeX
1586 @subsection ML@TeX{}: Multi-lingual @TeX{}
1587
1588 @pindex mltex
1589 @cindex Multi-lingual @TeX{}
1590
1591 @cindex Ferguson, Michael
1592 @cindex Raichle, Bernd
1593 @cindex accents, hyphenating words with
1594 @cindex glyph substitutions
1595 @cindex substitutions of font glyphs
1596 Multi-lingual @TeX{} (@code{mltex}) is an extension of @TeX{} originally
1597 written by Michael Ferguson and now updated and maintained by Bernd
1598 Raichle. With the advent of Unicode, it has become obsolete, though
1599 it is still supported in Web2c in the event of bugs or compilation
1600 bugs.
1601
1602 ML@TeX{} allows the use of non-existing glyphs in a font by declaring
1603 glyph substitutions. These are restricted to substitutions of an
1604 accented character glyph, which need not be defined in the current
1605 font, by its appropriate @code{\accent} construction using a base and
1606 accent character glyph, which do have to exist in the current font.
1607 This substitution is automatically done behind the scenes, if
1608 necessary, and thus ML@TeX{} additionally supports hyphenation of
1609 words containing an accented character glyph for fonts missing this
1610 glyph (e.g., Computer Modern). Standard @TeX{} suppresses hyphenation
1611 in this case.
1612
1613 ML@TeX{} works at @file{.fmt}-creation time: the basic idea is to
1614 specify the @samp{-mltex} option to @TeX{} when you @code{\dump} a
1615 format. Then, when you subsequently invoke @TeX{} and read that
1616 @code{.fmt} file, the ML@TeX{} features described below will be enabled.
1617
1618 Generally, you use special macro files to create an ML@TeX{} @code{.fmt}
1619 file.
1620
1621 The sections below describe the two new primitives that ML@TeX{} defines.
1622 Aside from these, ML@TeX{} is completely compatible with standard @TeX{}.
1623
1624 @menu
1625 * \charsubdef:: Character substitution definitions.
1626 * \tracingcharsubdef:: Tracing substitutions.
1627 @end menu
1628
1629
1630 @node \charsubdef
1631 @subsubsection @code{\charsubdef}: Character substitutions
1632
1633 @findex \charsubdef @r{and ML@TeX{}}
1634
1635 The most important primitive ML@TeX{} adds is @code{\charsubdef}, used
1636 in a way reminiscent of @code{\chardef}:
1637 @example
1638 \charsubdef @var{composite} [=] @var{accent} @var{base}
1639 @end example
1640
1641 Each of @var{composite}, @var{accent}, and @var{base} are font glyph
1642 numbers, expressed in the usual @TeX{} syntax: @t{`\e} symbolically,
1643 @t{'145} for octal, @t{"65} for hex, @t{101} for decimal.
1644
1645 ML@TeX{}'s @code{\charsubdef} declares how to construct an accented
1646 character glyph (not necessarily existing in the current font) using two
1647 character glyphs (that do exist). Thus it defines whether a character
1648 glyph code, either typed as a single character or using the @code{\char}
1649 primitive, will be mapped to a font glyph or to an @code{\accent} glyph
1650 construction.
1651
1652 For example, if you assume glyph code 138
1653 @cindex e-circumflex
1654 (decimal) for an e-circumflex
1655 @tex
1656 (\^e)
1657 @end tex
1658 and you are using the Computer Modern fonts, which have the circumflex
1659 accent in position 18 and lowercase `e' in the usual ASCII position 101
1660 decimal, you would use @code{\charsubdef} as follows:
1661
1662 @example
1663 \charsubdef 138 = 18 101
1664 @end example
1665
1666 For the plain @TeX{} format to make use of this substitution, you have
1667 to redefine the circumflex accent macro @code{\^} in such a way that if
1668 its argument is character `e' the expansion @code{\char138 } is used
1669 instead of @code{\accent18 e}. Similar @code{\charsubdef} declaration
1670 and macro redefinitions have to be done for all other accented
1671 characters.
1672
1673 To disable a previous @code{\charsubdef @var{c}}, redefine @var{c}
1674 as a pair of zeros. For example:
1675 @example
1676 \charsubdef '321 = 0 0 % disable N tilde
1677 @end example
1678 @cindex N tilde
1679 @noindent
1680 (Octal @t{'321} is the ISO Latin-1 value for the Spanish N tilde.)
1681
1682 @code{\charsubdef} commands should only be given once. Although in
1683 principle you can use @code{\charsubdef} at any time, the result is
1684 unspecified. If @code{\charsubdef} declarations are changed, usually
1685 either incorrect character dimensions will be used or ML@TeX{} will
1686 output missing character warnings. (The substitution of a
1687 @code{\charsubdef} is used by @TeX{} when appending the character node
1688 to the current horizontal list, to compute the width of a horizontal box
1689 when the box gets packed, and when building the @code{\accent}
1690 construction at @code{\shipout}-time. In summary, the substitution is
1691 accessed often, so changing it is not desirable, nor generally useful.)
1692
1693
1694 @node \tracingcharsubdef
1695 @subsubsection @code{\tracingcharsubdef}: Substitution diagnostics
1696
1697 @findex \tracingcharsubdef @r{and ML@TeX{}}
1698 @cindex redefined character substitutions
1699 To help diagnose problems with @samp{\charsubdef}, ML@TeX{} provides a
1700 new primitive parameter, @code{\tracingcharsubdef}. If positive, every
1701 use of @code{\charsubdef} will be reported. This can help track down
1702 when a character is redefined.
1703
1704 @findex \tracinglostchars @r{and ML@TeX{}}
1705 In addition, if the @TeX{} parameter @code{\tracinglostchars} is 100
1706 or more, the character substitutions performed at @code{\shipout}-time
1707 will be recorded.
1708
1709
1710 @node TCX files
1711 @subsection TCX files: Character translations
1712
1713 @flindex TCX @r{character translation files}
1714 @flindex .tcx @r{character translation files}
1715 @cindex character translation files
1716
1717 @cindex international characters
1718 @cindex 8-bit characters
1719 @cindex accented character
1720 TCX (@TeX{} character translation) files help @TeX{} support direct
1721 input of 8-bit international characters if fonts containing those
1722 characters are being used. Specifically, they map an input (keyboard)
1723 character code to the internal @TeX{} character code (a superset of
1724 ASCII).
1725
1726 Of the various proposals for handling more than one input encoding,
1727 TCX files were chosen because they follow Knuth's original ideas for
1728 the use of the @samp{xchr} and @samp{xord} tables. He ventured that
1729 these would be changed in the WEB source in order to adjust the actual
1730 version to a given environment. It turns out, however, that
1731 recompiling the WEB sources is not as simple a task as Knuth may have
1732 imagined; therefore, TCX files, providing the possibility of changing
1733 of the conversion tables on on-the-fly, have been implemented instead.
1734
1735 This approach limits the portability of @TeX{} documents, as some
1736 implementations do not support it (or use a different method for
1737 input-internal reencoding). It may also be problematic to determine
1738 the encoding to use for a @TeX{} document of unknown provenance; in
1739 the worst case, failure to do so correctly may result in subtle errors
1740 in the typeset output. But we feel the benefits outweigh these
1741 disadvantages.
1742
1743 This is entirely independent of the ML@TeX{} extension (@pxref{MLTeX}):
1744 whereas a TCX file defines how an input keyboard character is mapped to
1745 @TeX{}'s internal code, ML@TeX{} defines substitutions for a
1746 non-existing character glyph in a font with a @code{\accent}
1747 construction made out of two separate character glyphs. TCX files
1748 involve no new primitives; it is not possible to specify
1749 that an input (keyboard) character maps to more than one character.
1750
1751 @vindex WEB2C@r{, search path for TCX files}
1752 Information on specifying TCX files:
1753
1754 @itemize @bullet
1755 @item
1756 The best way to specify a TCX file is to list it explicitly in the
1757 first line of the main document:
1758 @example
1759 %& -translate-file=@var{tcxfile}
1760 @end example
1761
1762 @item
1763 You can also specify a TCX file to be used on a particular @TeX{} run
1764 with the command-line option @samp{-translate-file=@var{tcxfile}}.
1765
1766 @item
1767 TCX files are searched for along the @code{WEB2C} path.
1768
1769 @item
1770 Initial @TeX{} (@pxref{Initial TeX,,Initial @TeX{}}) ignores TCX files.
1771 @end itemize
1772
1773 @flindex il1-t1.tcx
1774 @flindex il2-t1.tcx
1775 @flindex empty.tcx
1776 @cindex Cork encoding and ISO input
1777 @cindex T1 encoding and ISO input
1778 The Web2c distribution comes with a number of TCX files. Two
1779 important ones are @file{il1-t1.tcx} and @file{il2-t1.tcx}, which
1780 support ISO Latin 1 and ISO Latin 2, respectively, with Cork-encoded
1781 fonts (a.k.a.@ the @LaTeX{} T1 encoding). TCX files for Czech,
1782 Polish, and Slovak are also provided.
1783
1784 One other notable TCX file is @file{empty.tcx}, which is, well,
1785 empty. Its purpose is to reset Web2C's behavior to the default (only
1786 visible ASCII being printable, as described below) when a format was
1787 dumped with another TCX being active---which is in fact the case for
1788 everything but plain @TeX{} in the TeX Live and other distributions.
1789 Thus:
1790
1791 @example
1792 latex somefile8.tex
1793 @result{} terminal etc. output with 8-bit chars
1794 latex --translate-file=empty.tcx somefile8.tex
1795 @result{} terminal etc. output with ^^ notation
1796 @end example
1797
1798 @cindex syntax of TCX files
1799 Syntax of TCX files:
1800 @enumerate
1801 @item
1802 @cindex blank lines, in TCX files
1803 Line-oriented. Blank lines are ignored.
1804
1805 @item
1806 @cindex whitespace, in TCX files
1807 Whitespace is ignored except as a separator.
1808
1809 @item
1810 @cindex comments, in TCX files
1811 Comments start with @samp{%} and continue to the end of the line.
1812
1813 @item
1814 Otherwise, a line consists of one or two character codes, optionally
1815 followed by 0 or 1. The last number indicates whether @var{dest} is
1816 considered printable.
1817 @example
1818 @var{src} [@var{dest} [@var{prnt}]]
1819 @end example
1820
1821 @item
1822 @cindex character codes, in TCX files
1823 @cindex octal character codes, in TCX files
1824 @cindex hex character codes, in TCX files
1825 @cindex decimal character codes, in TCX files
1826 Each character code may be specified in octal with a leading @samp{0},
1827 hexadecimal with a leading @samp{0x}, or decimal otherwise. Values must
1828 be between 0 and 255, inclusive (decimal).
1829
1830 @item
1831 If the @var{dest} code is not specified, it is taken to be the same as
1832 @var{src}.
1833
1834 @item
1835 If the same @var{src} code is specified more than once, it is the last
1836 definition that counts.
1837 @end enumerate
1838
1839 @cindex printable characters, specifying
1840 @kindex ^^ @r{notation, avoiding}
1841 Finally, here's what happens: when @TeX{} sees an input character with
1842 code @var{src}, it 1) changes @var{src} to @var{dest}; and 2) makes the
1843 @var{dest} code ``printable'', i.e., printed as-is in diagnostics and the
1844 log file rather than in @samp{^^} notation.
1845
1846 By default, no characters are translated, and character codes between 32
1847 and 126 inclusive (decimal) are printable.
1848
1849 Specifying translations for the printable ASCII characters (codes
1850 32--127) will yield unpredictable results. Additionally you shouldn't
1851 make the following characters printable: @code{^^I} (TAB), @code{^^J}
1852 (line feed), @code{^^M} (carriage return), and @code{^^?} (delete),
1853 since @TeX{} uses them in various ways.
1854
1855 @cindex font character code, translating
1856 @cindex keyboard character code, translating
1857 Thus, the idea is to specify the input (keyboard) character code for
1858 @var{src}, and the output (font) character code for @var{dest}.
1859
1860 @cindex interaction between TCX files and @samp{-8bit}.
1861 By default, only the printable ASCII characters are considered printable
1862 by @TeX{}. If you specify the @samp{-8bit} option, all characters are
1863 considered printable by default. If you specify both the @samp{-8bit}
1864 option and a TCX file, then the TCX can set specific characters to be
1865 non-printable.
1866
1867 Both the specified TCX encoding and whether characters are printable
1868 are saved in the dump files (like @file{tex.fmt}). So by giving these
1869 options in combination with @samp{-ini}, you control the defaults seen
1870 by anyone who uses the resulting dump file.
1871
1872 When loading a dump, if the @samp{-8bit} option was given, then all
1873 characters become printable by default.
1874
1875 When loading a dump, if a TCX file was specified, then the TCX data from
1876 the dump is ignored and the data from the file used instead.
1877
1878
1879 @node patgen invocation
1880 @subsection Patgen: Creating hyphenation patterns
1881
1882 @pindex patgen
1883 @cindex hyphenation patterns, creating
1884 @cindex languages, hyphenation rules for
1885
1886 Patgen creates hyphenation patterns from dictionary files for use with
1887 @TeX{}. Synopsis:
1888
1889 @example
1890 patgen @var{dictionary} @var{patterns} @var{output} @var{translate}
1891 @end example
1892
1893 Each argument is a filename. No path searching is done. The output is
1894 written to the file @var{output}.
1895
1896 @c @table @var
1897 @c @item dictionary
1898 @c @cindex dictionary file
1899 @c @findex \lefthyphemmin
1900 @c @findex \righthyphenmin
1901 @c The first line contains the values of @code{\lefthyphenmin} and
1902 @c @code{\righthyphenmin} in columns 1--2 and 3--4. Columns 5, 6, and 7 may
1903 @c optionally contain replacements for the default characters @samp{.},
1904 @c @samp{-}, and @samp{*} respectively used in the word lists.
1905 @c
1906 @c Subsequent lines are either comments (if they start with two identical
1907 @c characters, e.g., @samp{%%}), or contain the external representation of
1908 @c the lower case version of a letter, followed by an arbitrary number of
1909 @c upper case versions, preceded and separated by a delimiter and followed
1910 @c by two consecutive delimiters. The delimiter may be any character not
1911 @c occurring in either version.
1912
1913 In addition, Patgen prompts interactively for other values.
1914
1915 For more information, see @cite{Word hy-phen-a-tion by com-put-er} by
1916 Frank Liang (@pxref{References}), and also the @file{patgen.web} source file.
1917
1918 The only options are @samp{-help} and @samp{-version} (@pxref{Common
1919 options}).
1920
1921
1922 @node Shell escapes
1923 @section Shell escapes
1924
1925 @cindex shell commands in @TeX{}
1926 @cindex security, and shell escapes
1927 @cindex restricted shell escapes
1928 @cindex system command
1929 @vindex shell_escape @r{enabling in @TeX{}}
1930 @findex \immediate\write18
1931 @findex \write18 @r{shell escape extension}
1932 @findex system @r{C library function}
1933 @flindex texmf.cnf @r{for shell escapes}
1934
1935 @TeX{} can execute @dfn{shell escapes}, that is, arbitrary shell
1936 commands. Although tremendously useful, this also has obvious
1937 security implications. Therefore, as of @TeX{} Live 2009, a
1938 @dfn{restricted} mode for shell escapes is the default mode of
1939 operation, which allows executing only certain commands, as specified
1940 in the @file{texmf.cnf} configuration file.
1941
1942 @itemize @bullet
1943 @item
1944 Unrestricted shell escapes are allowed if the option
1945 @option{--shell-escape} is specified, or if the environment variable
1946 or config file value @code{shell_escape} is set to @samp{t} or
1947 @samp{y} and @samp{1}.
1948
1949 @item
1950 Restricted shell escapes are allowed if @code{shell_escape} is set to
1951 @samp{p}. This is the default.
1952
1953 @item
1954 Shell escapes are completely disabled if @option{--no-shell-escape} is
1955 specified, or if @code{shell_escape} is set to anything else.
1956 @end itemize
1957
1958 When enabled, the @TeX{} construct to execute a system command is
1959 @code{\write18@{@var{shell-command}@}}; for example:
1960
1961 @example
1962 \write18@{echo "hello, world"@}
1963 @end example
1964
1965 @findex \output @r{routine, and @code{\write}}
1966 From @TeX{}'s point of view, this is a normal @code{\write} command,
1967 and is therefore subject to the usual @TeX{} expansions. Also, the
1968 system call either happens during the @samp{\output} routine or right
1969 away, according to the absence or presence of the @code{\immediate}
1970 prefix, as usual for @code{\write}.
1971
1972 @cindex exit status, of shell escape
1973 The @var{shell-command} string is passed to the command shell (via the
1974 C library function @code{system}). The output of @var{shell-command}
1975 is not diverted anywhere, so it will not appear in the log file, or
1976 anywhere but the terminal output. The exit status of the system call
1977 is also not available to @TeX{}.
1978
1979 In unrestricted mode, the argument is simply passed straight to
1980 @code{system} unaltered.
1981
1982 In restricted mode, ASCII double quote characters (@verb{|"|}) should
1983 always be used in the argument to @code{\write18} where quoting of
1984 arguments is needed, as in the example above. This is to achieve some
1985 measure of system independence. On Unix systems, these are replaced
1986 with single quote (@verb{|'|}) characters to avoid insecure further
1987 expansion (from, e.g., @verb{|`...`|}). Care is also taken on Windows
1988 to avoid additional expansions. Mismatched quotation marks in the
1989 command string result in a diagnostic message in the log file, and no
1990 execution is performed.
1991
1992 @findex shell_escape_commands
1993 After quotation processing, if the first word (delimited by a space or
1994 tab) of the command is in the list specified by the
1995 @code{shell_escape_commands} configuration value, the command is
1996 executed. Otherwise it is not. In any case, a message is written to
1997 the log file.
1998
1999 The @code{shell_escape_commands} value is a comma-separated list of
2000 words. Whitespace is significant, and typically should not be
2001 present. The default definition in @file{texmf.cnf} looks like this,
2002 with more commands included:
2003
2004 @example
2005 shell_escape_commands = bibtex,kpsewhich,repstopdf,...
2006 @end example
2007
2008 @cindex pipes, reading and writing
2009 @findex \openin@r{, and pipes}
2010 @findex \input@r{, and pipes}
2011 @findex \openout@r{, and pipes}
2012 @findex \pdfshellescape
2013 pdf@TeX{} and Lua@TeX{} support reading (via @code{\input} and
2014 @code{\openin}) and writing (via @code{\openout}) from pipes if the
2015 first character is @samp{|}. The following command is then treated
2016 exactly the same as the argument to @code{\write18}. In these
2017 engines, the primitive variable @code{\pdfshellescape} is set to 0 if
2018 shell escapes are disabled, 1 if they are enabled, and 2 if they are
2019 enabled with restrictions.
2020
2021 @cindex web environments, and security
2022 The purpose of this feature is to make it possible for @TeX{}
2023 documents to perform useful external actions in the common case of an
2024 individual user running a known document on his or her own machine.
2025 In environments such as CGI scripts or wikis where the input has to be
2026 considered untrustworthy, shell escapes should be completely disabled.
2027
2028 Programs intended to be called from @TeX{} in restricted should
2029 implement the ``paranoid'' safety measures regarding output files that
2030 @TeX{} itself does. @xref{Calling sequence,,, kpathsea, Kpathsea}.
2031
2032 @node IPC and TeX
2033 @section IPC and @TeX{}
2034
2035 @cindex IPC
2036 @cindex sockets
2037 (If anyone uses this feature and needs documentation, write
2038 @email{tex-k@@tug.org}.)
2039
2040 This functionality is available only if the @samp{--enable-ipc} option
2041 was specified to @code{configure} during installation of Web2c
2042 (@pxref{Installation}).
2043
2044 @vindex IPC_DEBUG
2045 If you define @code{IPC_DEBUG} before compilation (e.g., with @samp{make
2046 XCFLAGS=-DIPC_DEBUG}), @TeX{} will print messages to standard error
2047 about its socket operations. This may be helpful if you are, well,
2048 debugging.
2049
2050
2051 @node TeX extensions
2052 @section Extended @TeX{} engines
2053
2054 @cindex extensions to @TeX{}
2055 @cindex @TeX{}, extensions to
2056
2057 The base @TeX{} program has been extended in many ways.
2058
2059 @cindex cross-engine functionality
2060 There has been a substantial effort to make a set of extended
2061 functionality available across all actively-updated engines, so that
2062 formats, notably @LaTeX{}, can rely on it. A list of this common
2063 extended functionality is in a @cite{@LaTeX{} News} article,
2064 @url{https://www.latex-project.org/news/latex2e-news/ltnews31.pdf}.
2065 For engines in @TeX{} Live, the detailed documentation for these
2066 primitives is mostly in the pdf@TeX{} manual
2067 (@url{https://pdftex.org}).
2068
2069 In addition, each engine (naturally) has its own particular features,
2070 described in its own manual. Here's a partial list of the engines.
2071
2072 @table @asis
2073 @item e-@TeX{}
2074 @cindex e-@TeX{}
2075 @cindex primitives, new
2076 Adds many new primitives, including right-to-left typesetting and more
2077 registers. Now frozen. More info: @url{https://ctan.org/pkg/etex}.
2078
2079 @item Aleph
2080 @cindex Aleph
2081 @cindex Omega
2082 @cindex Unicode
2083 This adds Unicode support, right-to-left typesetting, and more, based
2084 on the Omega engine, with the e-@TeX{} and other extensions. Aleph is
2085 maintained only for serious bug fixes and does not include the common
2086 functionality mentioned above. More info:
2087 @url{https://ctan.org/pkg/aleph}, @url{https://ctan.org/pkg/omega}.
2088
2089 @item pdf@TeX{}
2090 @cindex pdf@TeX{}
2091 @cindex PDF
2092 @cindex micro-typography
2093 @cindex hypertext
2094 @pindex etex @r{is pdf@TeX{}}
2095 Can produce PDF as well as DVI files. It also incorporates the
2096 e-@TeX{} extensions, new primitives for hypertext and
2097 micro-typography, reading/writing from pipes, and much more. In
2098 @TeX{} Live, the command @command{etex} invokes pdf@TeX{} to make all
2099 these additions available with DVI output. Home page:
2100 @url{https://pdftex.org}.
2101
2102 @item Lua@TeX{}
2103 @cindex Lua@TeX{}
2104 @cindex Lua
2105 @cindex UTF-8 input, native
2106 @cindex OpenType support
2107 @cindex TrueType support
2108 @cindex system fonts, using
2109 Embeds the Lua programming language (@url{http://lua.org}) and opens
2110 up the @TeX{} typesetting engine to control from Lua, starting from
2111 the pdf@TeX{} capabilities as a base. Also natively supports UTF-8
2112 input, the OpenType and TrueType font formats, and use of system
2113 fonts. Home page: @url{https://luatex.org}.
2114
2115 @item Xe@TeX{}
2116 @cindex Xe@TeX{}
2117 @cindex Unicode input, native
2118 Combines support for Unicode input, the OpenType and TrueType font
2119 formats, and use of system fonts with the capabilities of pdf@TeX{},
2120 with the exception of the font expansion part of micro-typography.
2121 Home page: @url{https://tug.org/xetex}.
2122
2123 @item hi@TeX{}
2124 @cindex hi@TeX{}
2125 @cindex HINT (Hint Is Not @TeX{})
2126 Outputs its own HINT format, which is designed for reading
2127 technical documents on mobile devices. More info:
2128 @url{https://ctan.org/pkg/hitex}.
2129
2130 @item p@TeX{}
2131 @itemx up@TeX{}
2132 @cindex p@TeX{}
2133 @cindex up@TeX{}
2134 With additional support for Japanese; p@TeX{} was the original engine,
2135 and up@TeX{} has native Unicode support and thus is more useful for
2136 Chinese and Korean. More info: @url{https://ctan.org/pkg/ptex},
2137 @url{https://ctan.org/pkg/uptex}.
2138
2139 @item ep@TeX{}
2140 @itemx eup@TeX{}
2141 @cindex ep@TeX{}
2142 @cindex eup@TeX{}
2143 Further extends p@TeX{} and up@TeX{} with the e-@TeX{} extensions.
2144 More info: @url{https://ctan.org/pkg/eptex},
2145 @url{https://ctan.org/pkg/euptex}.
2146
2147 @end table
2148
2149
2150 @node Metafont
2151 @chapter Metafont: Creating typeface families
2152
2153 @cindex Metafont
2154 @cindex typeface families
2155 @cindex geometric designs
2156 @cindex shapes
2157 @cindex font design
2158
2159 Metafont is a system for producing shapes; it was designed for producing
2160 complete typeface families, but it can also produce geometric designs,
2161 dingbats, etc. And it has considerable mathematical and
2162 equation-solving capabilities which can be useful entirely on their own.
2163
2164 Metafont is a batch language, like C or Pascal: you compile a Metafont
2165 program into a corresponding font, rather than interactively drawing
2166 lines or curves. This approach has both considerable disadvantages
2167 (people unfamiliar with conventional programming languages will be
2168 unlikely to find it usable) and considerable advantages (you can make
2169 your design intentions specific and parameterizable). For a complete
2170 description of the Metafont language, see @cite{The METAFONTbook}
2171 (@pxref{References}).
2172
2173 @menu
2174 * mf invocation:: Invoking Metafont.
2175 * Initial Metafont:: Making bases.
2176 * Modes:: Device definitions for Metafont.
2177 * Online Metafont graphics:: Seeing MF output online.
2178 * gftodvi invocation:: Making proofsheets for fonts.
2179 * mft invocation:: Prettyprinting Metafont sources.
2180 @end menu
2181
2182
2183 @node mf invocation
2184 @section @code{mf} invocation
2185
2186 @pindex mf
2187 @cindex Metafont invocation
2188
2189 Metafont (usually invoked as @code{mf}) reads character definitions
2190 specified in the Metafont programming language, and outputs the
2191 corresponding font. This section merely describes the options available
2192 in the Web2c implementation. For a complete description of the Metafont
2193 language, see @cite{The Metafontbook} (@pxref{References}).
2194
2195 Metafont processes its command line and determines its memory dump
2196 (base) file in a way exactly analogous to MetaPost and @TeX{}
2197 (@pxref{tex invocation}, and @pxref{Memory dumps}). Synopses:
2198
2199 @example
2200 mf [@var{option}]@dots{} [@var{mfname}[.mf]] [@var{mf-commands}]
2201 mf [@var{option}]@dots{} \@var{first-line}
2202 mf [@var{option}]@dots{} &@var{base} @var{args}
2203 @end example
2204
2205 Most commonly, a Metafont invocation looks like this:
2206 @example
2207 mf '\mode:=@var{mode}; mag:=@var{magnification}; input @var{mfname}'
2208 @end example
2209 @noindent
2210 (The single quotes avoid unwanted interpretation by the shell.)
2211
2212 @flindex .mf
2213 @cindex Metafont input files
2214 @cindex EC fonts
2215 @pindex mktexmf@r{, disabling}
2216 Metafont searches the usual places for the main input file @var{mfname}
2217 (@pxref{Supported file formats,,, kpathsea, Kpathsea}), extending
2218 @var{mfname} with @file{.mf} if necessary. To see all the relevant
2219 paths, set the environment variable @code{KPATHSEA_DEBUG} to @samp{-1}
2220 before running the program. By default, Metafont runs an external
2221 program named @file{mktexmf} to create any nonexistent Metafont source
2222 files you input. You can disable this at configure-time or runtime
2223 (@pxref{mktex configuration,,, kpathsea, Kpathsea}). This is mostly
2224 for the sake of the EC fonts, which can be generated at any size.
2225
2226 @flindex .@var{nnn}gf @r{generic fonts}
2227 @flindex mfput
2228 @cindex GF output
2229 @cindex GF files, output by Metafont
2230 @cindex PK files, not output by Metafont
2231 Metafont writes the main GF output to the file
2232 @file{@var{basemfname}.@var{nnn}gf}, where @var{nnn} is the font
2233 resolution in pixels per inch, and @var{basemfname} is the basename of
2234 @var{mfname}, or @samp{mfput} if no input file was specified. A GF file
2235 contains bitmaps of the actual character shapes. Usually GF files are
2236 converted immediately to PK files with GFtoPK (@pxref{gftopk
2237 invocation}), since PK files contain equivalent information, but are
2238 more compact. (Metafont output in GF format rather than PK for only
2239 historical reasons.)
2240
2241 @flindex .tfm @r{output}
2242 @cindex TFM files, output by Metafont
2243 Metafont also usually writes a metric file in TFM format to
2244 @file{@var{basemfname}.tfm}. A TFM file contains character dimensions,
2245 kerns, and ligatures, and spacing parameters. @TeX{} reads only this
2246 @t{.tfm} file, not the GF file.
2247
2248 @cindex mode needed to run Metafont
2249 @findex proof @r{mode}
2250 @flindex 2602gf
2251 @flindex .2602gf
2252 The @var{mode} in the example command above is a name referring to a
2253 device definition (@pxref{Modes}); for example, @code{localfont} or
2254 @code{ljfour}. These device definitions must generally be precompiled
2255 into the base file. If you leave this out, the default is @code{proof}
2256 mode, as stated in @cite{The Metafontbook}, in which Metafont outputs at
2257 a resolution of 2602@dmn{dpi}; this is usually not what you want. The
2258 remedy is simply to assign a different mode---@code{localfont}, for
2259 example.
2260
2261 The @var{magnification} assignment in the example command above is a
2262 magnification factor; for example, if the device is 600@dmn{dpi} and you
2263 specify @code{mag:=2}, Metafont will produce output at 1200@dmn{dpi}.
2264 Very often, the @var{magnification} is an expression such as
2265 @code{magstep(.5)}, corresponding to a @TeX{} ``magstep'', which are
2266 factors of
2267 @tex
2268 1.2$\sqrt{2}$.
2269 @end tex
2270 @ifinfo
2271 1.2 * sqrt(2).
2272 @end ifinfo
2273
2274 After running Metafont, you can use the font in a @TeX{} document as
2275 usual. For example:
2276 @example
2277 \font\myfont = newfont
2278 \myfont Now I am typesetting in my new font (minimum hamburgers).
2279 @end example
2280
2281 The program accepts the following options, as well as the standard
2282 @samp{-help} and @samp{-version} (@pxref{Common options}):
2283 @table @samp
2284 @item -[no]-file-line-error
2285 @itemx -fmt=@var{fmtname}
2286 @itemx -halt-on-error
2287 @itemx -ini
2288 @itemx -interaction=@var{string}
2289 @itemx -jobname=@var{string}
2290 @itemx -kpathsea-debug=@var{number}
2291 @itemx -[no]parse-first-line
2292 @itemx -output-directory
2293 @itemx -progname=@var{string}
2294 @itemx -recorder
2295 @itemx -translate-file=@var{tcxfile}
2296 @itemx -8bit
2297 These options are common to @TeX{}, Metafont, and MetaPost.
2298 @xref{Common options}.
2299
2300 @item -mktex=@var{filetype}
2301 @itemx -no-mktex=@var{filetype}
2302 @opindex -mktex=@var{filetype}
2303 @opindex -no-mktex=@var{filetype}
2304 Turn on or off the @samp{mktex} script associated with @var{filetype}.
2305 The only value that makes sense for @var{filetype} is @samp{mf}.
2306 @end table
2307
2308
2309 @node Initial Metafont
2310 @section Initial Metafont
2311
2312 @cindex initial Metafont
2313 @cindex Metafont, initial
2314
2315 @flindex .base
2316 @cindex base files
2317 @code{inimf} is the ``initial'' form of Metafont, which does lengthy
2318 initializations avoided by the ``virgin'' (@code{vir}) form, so as to
2319 be capable of dumping @samp{.base} files (@pxref{Memory dumps}). For
2320 a detailed comparison of virgin and initial forms, see @ref{Initial
2321 and virgin}.
2322
2323 For a list of options and other information, see @ref{mf invocation}.
2324
2325 @flindex plain.base
2326 @flindex mf.base
2327 The only memory dump file commonly used with Metafont is the default
2328 @samp{plain.base}, also known as @samp{mf.base} (again, @pxref{Memory
2329 dumps}). It is created by default during installation, but you can also
2330 do so by hand if necessary:
2331 @example
2332 mf -ini '\input plain; input modes; dump'
2333 @end example
2334 @noindent
2335 (The quotes prevent interpretation of the backslashes from the shell.)
2336 Then install the resulting @file{plain.base} where Metafont will find
2337 it, and link @file{mf.base} to it.
2338
2339 For an explanation of the additional @file{modes.mf} file,
2340 see @ref{Modes}. This file has no counterpart in @TeX{} or MetaPost.
2341
2342 @flindex cmmf.base @r{not recommended}
2343 @flindex cm.base
2344 @flindex cmbase.mf
2345 @cindex Computer Modern macros
2346 @cindex base files, plain only
2347 In the past, it was sometimes useful to create a base file
2348 @file{cmmf.base} (a.k.a.@: @file{cm.base}), with the Computer Modern
2349 macros also included in the base file. Nowadays, however, the
2350 additional time required to read @file{cmbase.mf} is exceedingly small,
2351 usually not enough to be worth the administrative hassle of updating the
2352 @file{cmmf.base} file when you install a new version of @file{modes.mf}.
2353 @cindex type design, personal
2354 People developing a typeface with Metafont may find it worthwhile to
2355 create their own base file.
2356
2357
2358 @node Modes
2359 @section Modes: Device definitions for Metafont
2360
2361 @cindex modes file needed for Metafont
2362 @cindex base files, need mode definitions
2363 @cindex device definitions, for Metafont
2364 @cindex printer characteristics, for Metafont
2365 Running Metafont and creating Metafont base files requires information
2366 that @TeX{} and MetaPost do not: @dfn{mode} definitions which specify
2367 device characteristics, so Metafont can properly rasterize the shapes.
2368
2369 @flindex modes.mf @r{recommended modes file}
2370 When making a base file, a file containing modes for locally-available
2371 devices should be input after @file{plain.mf}. One commonly used file
2372 is @file{modes.mf} (@url{https://ctan.org/pkg/modes}); it includes all
2373 known definitions.
2374
2375 @cindex small Metafont memory and modes
2376 @findex mode_def
2377 @findex mode_setup
2378 If, however, for some reason you have decreased the memory available in
2379 your Metafont, you may need to copy @file{modes.mf} and remove the
2380 definitions irrelevant to you (probably most of them) instead of using
2381 it directly. (Or, if you're a Metafont hacker, maybe you can suggest a
2382 way to redefine @code{mode_def} and/or @code{mode_setup}; right now, the
2383 amount of memory used is approximately four times the total length of
2384 the @code{mode_def} names, and that's a lot.)
2385
2386 If you have a device not included in @file{modes.mf}, please see
2387 comments in that file for how to create the new definition, and please
2388 send the definition to @email{tex-fonts@@math.utah.edu} to get it included
2389 in the next release of @file{modes.mf}.
2390
2391 @findex smode @r{and dynamic Metafont mode definition}
2392 @cindex dynamic Metafont mode definitions with @code{smode}
2393 Usually, when you run Metafont you must supply the name of a mode that
2394 was dumped in the base file. But you can also define the mode
2395 characteristics dynamically, by invoking Metafont with an assignment to
2396 @code{smode} instead of @code{mode}, like this:
2397 @example
2398 mf '\smode:="newmode.mf"; mag:=@var{magnification}; input @var{mfname}'
2399 @end example
2400 @noindent
2401 This is most useful when you are working on the definition of a new
2402 mode.
2403
2404 The @var{magnification} and @var{mfname} arguments are explained in
2405 @ref{mf invocation}. In the file @file{newmode.mf}, you should have the
2406 following (with no @code{mode_def} or @code{enddef}), if you are using
2407 @file{modes.mf} conventions:
2408 @example
2409 mode_param (pixels_per_inch, @var{dpi});
2410 mode_param (blacker, @var{b});
2411 mode_param (fillin, @var{f});
2412 mode_param (o_correction, @var{o});
2413 mode_common_setup_;
2414 @end example
2415 @noindent
2416 (Of course, you should use real numbers for @var{dpi}, @var{b}, @var{f},
2417 and @var{o}.)
2418
2419 For more information on the use of @code{smode}, or if you are not using
2420 @file{modes.mf}, see page 269 of @cite{The Metafontbook}.
2421
2422
2423 @node Online Metafont graphics
2424 @section Online Metafont graphics
2425
2426 @cindex online Metafont graphics
2427 @cindex Metafont graphics
2428
2429 The Web2c implementation of Metafont can do online graphics with a
2430 number of devices. (See @cite{The Metafontbook} for more information
2431 about how to draw on your screen.) The default graphics support is
2432 determined at compile time.
2433
2434 The two Kpathsea configuration variables @code{screen_width} and
2435 @code{screen_depth} define the width and height of the window used by
2436 Metafont. They can be set in the environment or a Kpathsea
2437 configuration file (@pxref{path sources,,, Kpathsea, kpathsea}). They
2438 default to 1664 and 1200, respectively.
2439
2440 @vindex MFTERM
2441 @vindex TERM
2442 Metafont examines the @code{MFTERM} environment variable or config file
2443 value at runtime, or the @code{TERM} environment variable if
2444 @code{MFTERM} is not set, to determine the device support to use.
2445 Some devices are system-specific and not always available.
2446
2447 @vindex DISPLAY
2448 @cindex X server, and Metafont
2449 If @code{MFTERM} is not set, but the @code{DISPLAY} environment
2450 variable is set (to a valid X server specification like @samp{:0}),
2451 the Metafont window support for X is used, assuming it was detected
2452 and included at compile time.
2453
2454 Here is a table of the possibilities, showing the @code{MFTERM} value
2455 and the corresponding @code{configure} option(s) in parentheses.
2456
2457 @vtable @code
2458 @item amiga
2459 @opindex --enable-amigawin
2460 (@samp{--enable-amigawin}) Amiga systems.
2461
2462 @item epsf
2463 @cindex Herberts, Mathias
2464 @opindex --enable-epsfwin
2465 (@samp{--enable-epsfwin}) Pseudo-window server for Encapsulated
2466 PostScript (see @file{web2c/window/epsf.c}). This device produces an
2467 EPS file containing the graphics which would be displayed online on
2468 other devices. The name of the EPS file defaults to metafont.eps but
2469 can be changed by setting the MFEPSF environment variable to the new
2470 filename. Contributed by Mathias Herberts.
2471
2472 @item hp2627
2473 @opindex --enable-hp2627win
2474 (@samp{--enable-hp2627win}) HP2627a color graphics terminals.
2475
2476 @item mftalk
2477 @opindex --enable-mftalkwin
2478 (@samp{--enable-mftalkwin}) Generic window server (see
2479 @file{web2c/window/mftalk.c}). @c insignificantly overfull, so:
2480 @tex
2481 \hfuzz=1.7pt\par
2482 @end tex
2483
2484 @item next
2485 @opindex --enable-next
2486 @pindex DrawingServant
2487 (@samp{--enable-nextwin}) NeXT window system. This requires a separate
2488 program, called @code{DrawingServant}, available separately. See the
2489 @file{web2c/window/next.c}.
2490
2491 @item regis
2492 @opindex --enable-regiswin
2493 @cindex Regis graphics support
2494 (@samp{--enable-regiswin}) Regis terminals.
2495
2496 @item sun
2497 @cindex SunView
2498 @cindex Suntools
2499 @opindex --enable-suntoolswin
2500 @flindex sun-gfx.c
2501 (@samp{--enable-suntoolswin}) The old Suntools (not any flavor of X)
2502 window system. (You can get the even older SunWindows @code{gfx} system
2503 with @file{sun-gfx.c}.)
2504
2505 @item tek
2506 @cindex Tektronix
2507 @opindex --enable-tektronixwin
2508 (@samp{--enable-tektronixwin}) Tektronix terminals.
2509
2510 @item uniterm
2511 @cindex Poole, Simon
2512 @cindex Tektronix 4014
2513 @opindex --enable-unitermwin
2514 (@samp{--enable-unitermwin}) Uniterm, Simon Poole's emulator of a smart
2515 Tektronix 4014 terminal. This may work with regular Tektronix terminals
2516 as well; it's faster than the driver @samp{--enable-tektronixwin} selects.
2517
2518 @item win32win
2519 Microsoft Windows.
2520
2521 @pindex Xt
2522 @pindex Xlib
2523 @item xterm
2524 @opindex --with-x
2525 @samp{--with-x} The X window system (version 11).
2526
2527 @opindex --with-mf-x-toolkit
2528 @cindex toolkits, X
2529 @cindex X toolkits and Metafont
2530 @cindex Xt support
2531 @cindex Xlib support
2532 There are two variants of the X11 support, one that works with the Xt
2533 toolkit (@file{X11-Xt.c}), and another that works directly with Xlib
2534 (@file{X11-Xlib.c}). If @code{--with-mf-x-toolkit} is specified when
2535 building Metafont, the Xt version is used, else Xlib.
2536
2537 @opindex --disable-mf-nowin
2538 @cindex non-windows-capable Metafont
2539 @cindex Metafont without online graphics
2540 Specify @samp{--disable-mf-nowin} in order not to build a separate
2541 non-windows-capable Metafont executable @code{mf-nowin}.
2542
2543 @cindex X resources
2544 @cindex X class name for Metafont
2545 @cindex class name for Metafont
2546 @cindex geometry for Metafont
2547 @cindex Metafont geometry
2548 @flindex .Xdefaults
2549 @flindex .Xresources
2550 @opindex -geometry@r{, supported with Xt}
2551 You cannot specify any of the usual X options (e.g., @samp{-geometry})
2552 on the Metafont command line, but you can specify X resources in your
2553 @file{~/.Xdefaults} or @file{~/.Xresources} file. The class name is
2554 @code{Metafont}. If you're using the Xt support, all the usual X toolkit
2555 resources are supported. If you're using the Xlib support, only the
2556 @code{geometry} resource is supported.
2557
2558 @vindex DISPLAY
2559 You specify the X display to which Metafont connects in the
2560 @code{DISPLAY} environment variable, as usual.
2561
2562 @end vtable
2563
2564 @cindex Metafont online support, new devices
2565 @cindex new graphics support for Metafont
2566 @flindex texmfmp.c
2567 Writing support for a new device is straightforward. Aside from defining
2568 the basic drawing routines that Metafont uses (see @file{mf.web}), you
2569 only have to add another entry to the tables on the last page of
2570 @file{web2c/lib/texmfmp.c}. Or you can write an independent program and
2571 use MFtalk (see @file{web2c/window/mftalk.c}).
2572
2573
2574 @node gftodvi invocation
2575 @section GFtoDVI: Character proofs of fonts
2576
2577 @pindex gftodvi
2578 @cindex character proofs of fonts
2579 @cindex font proofs
2580 @cindex proof sheets, of fonts
2581
2582 GFtoDVI makes @dfn{proof sheets} from a GF bitmap file as output by, for
2583 example, Metafont (@pxref{Metafont}). This is an indispensable aid for
2584 font designers or Metafont hackers. Synopsis:
2585
2586 @example
2587 gftodvi [@var{option}]@dots{} @var{gfname}[gf]
2588 @end example
2589
2590 The font @var{gfname} is searched for in the usual places (@pxref{Glyph
2591 lookup,,, kpathsea, Kpathsea}). To see all the relevant paths, set the
2592 environment variable @code{KPATHSEA_DEBUG} to @samp{-1} before running
2593 the program.
2594
2595 The suffix @samp{gf} is supplied if not already present. This suffix is
2596 not an extension, no @samp{.} precedes it; for instance, @file{cmr10.600gf}.
2597
2598 The output filename is the basename of @var{gfname} extended with
2599 @file{.dvi}, e.g., @samp{gftodvi /wherever/foo.600gf} creates
2600 @file{./foo.dvi}.
2601
2602 The characters from @var{gfname} appear one per page in the DVI output,
2603 with labels, titles, and annotations, as specified in Appendix H
2604 (Hardcopy Proofs) of @cite{The Metafontbook}.
2605
2606 GFtoDVI uses several fonts besides @var{gfname} itself:
2607
2608 @itemize @bullet
2609 @item
2610 @cindex gray font
2611 @dfn{gray font} (default @file{gray}): for the pixels that make
2612 up the character. Simply using black is not right, since then labels,
2613 key points, and other information could not be shown.
2614
2615 @item
2616 @cindex title font
2617 @dfn{title font} (default @file{cmr8}): for the header information at
2618 the top of each output page.
2619
2620 @item
2621 @cindex label font
2622 @dfn{label font} (default @file{cmtt10}): for the labels on key points
2623 of the figure.
2624
2625 @item
2626 @cindex slant font
2627 @dfn{slant font} (no default): for diagonal lines, which are otherwise
2628 simulated using horizontal and vertical rules.
2629 @end itemize
2630
2631 To change the default fonts, you must use @code{special} commands in
2632 your Metafont source file, typically via commands like @code{slantfont
2633 slantlj4}. There is no default slant font since no one printer is
2634 suitable as a default. You can make your own by copying one of the
2635 existing files, such as
2636 @file{.../fonts/source/public/misc/slantlj4.mf} and then running
2637 @command{mf} on it.
2638
2639 For testing purposes, you may it useful to run @code{mf-nowin rtest}
2640 (hit RETURN when it stops) to get a @file{gf} file of a thorn glyph.
2641 Or use @command{mf} instead of @command{mf-nowin} to have the glyph(s)
2642 displayed on the screen. After that, @code{gftodvi rtest.2602gf}
2643 should produce @file{rtest.dvi}, which you process as usual.
2644
2645 The program accepts the following option, as well as the standard
2646 @samp{-verbose}, @samp{-help}, and @samp{-version} (@pxref{Common
2647 options}):
2648
2649 @table @samp
2650 @item -overflow-label-offset=@var{points}
2651 @opindex -overflow-label-offset=@var{points}
2652 @cindex overflow label offset
2653 @cindex offset for overflow labels
2654 Typeset the so-called overflow labels, if any, @var{points} @TeX{}
2655 points from the right edge of the character bounding box. The default
2656 is a little over two inches (ten million scaled points, to be precise).
2657 Overflow equations are used to locate coordinates when their actual
2658 position is too crowded with other information.
2659 @end table
2660
2661
2662 @node mft invocation
2663 @section MFT: Prettyprinting Metafont source
2664
2665 @pindex mft
2666 @cindex Metafont or MetaPost source, prettyprinting
2667 @cindex prettyprinting Metafont or MetaPost source
2668 @cindex @TeX{}, creating from Metafont or MetaPost
2669
2670 @flindex mftmac.tex
2671 MFT translates a Metafont or MetaPost program into a @TeX{} document
2672 suitable for typesetting. Synopsis:
2673
2674 @example
2675 mft [@var{option}]@dots{} @var{sourcename}[.mf|.mp]
2676 @end example
2677
2678 MFT searches the usual places for @var{sourcename} (@pxref{Supported file
2679 formats,,, kpathsea, Kpathsea}). To see all the relevant paths, set the
2680 environment variable @code{KPATHSEA_DEBUG} to @samp{-1} before running
2681 the program. The output goes to the basename of @var{sourcename} extended
2682 with @file{.tex}, e.g., @samp{mft /wherever/foo.mf} creates
2683 @file{./foo.tex}.
2684
2685 The output uses the @TeX{} macros defined in the file
2686 @file{mftmac.tex} (for Metafont) or @file{mptmac.tex} (for MetaPost).
2687
2688 Line breaks in the input are carried over into the output; moreover,
2689 blank spaces at the beginning of a line are converted to quads of
2690 indentation in the output. Thus, you have full control over the
2691 indentation and line breaks. Each line of input is translated
2692 independently of the others.
2693
2694 Further control is allowed via comments:
2695 @cindex comments, MFT control
2696 @itemize @bullet
2697 @item
2698 Metafont/MetaPost comments following a single @samp{%} should be valid
2699 @TeX{} input. But Metafont/MetaPost source material can be included
2700 within vertical bars in a comment; this will be translated by MFT as
2701 if it were regular code. For example, a Metafont comment like @samp{%
2702 |x2r| is the tip of the bowl} will be translated into the @TeX{}
2703 @samp{% $x_@{2r@}$ is the @dots{}}, i.e., the @samp{x2r} is treated as
2704 an identifier.
2705
2706 @item
2707 @samp{%%} indicates that the remainder of an input line should be copied
2708 verbatim to the output. This is typically used to introduce additional
2709 @TeX{} material at the beginning or an MFT job, e.g. code to modify the
2710 standard layout or the formatting macros defined in @file{mftmac.tex},
2711 or to add a line saying @samp{%%\bye} at the end of the job. (MFT
2712 doesn't add this automatically in order to allow processing several
2713 files produces by MFT in the same @TeX{} job.)
2714
2715 @item
2716 @samp{%%% @var{token1} @var{other-tokens}}
2717 introduces a change in MFT's formatting rules; all the @var{other-tokens}
2718 will henceforth be translated according to the current conventions for
2719 @var{token1}. The tokens must be symbolic (i.e., not
2720 numeric or string tokens). For example, the input line
2721 @example
2722 %%% addto fill draw filldraw
2723 @end example
2724 @noindent
2725 says to format the @samp{fill}, @samp{draw}, and @samp{filldraw}
2726 operations of plain Metafont just like the primitive token @samp{addto},
2727 i.e., in boldface type. Without such reformatting commands, MFT would
2728 treat @samp{fill} like an ordinary tag or variable name. In fact, you
2729 need a @samp{%%%} command even to get parentheses to act like
2730 delimiters.
2731
2732 @item
2733 @samp{%%%%} introduces an MFT comment, i.e., MFT ignores the remainder
2734 of such a line.
2735
2736 @item
2737 Five or more @samp{%} signs should not be used.
2738 @end itemize
2739
2740 @cindex Knuth, Donald E.
2741 (The above description was based on that in @file{mft.web}, written by
2742 Donald Knuth.)
2743
2744 The program accepts the following options, as well as the standard
2745 @samp{-help} and @samp{-version} (@pxref{Common options}):
2746 @table @samp
2747 @item -change=@var{chfile}[.ch]
2748 @opindex -change=@var{chfile}
2749 @cindex change files, and MFT
2750 Apply the change file @var{chfile} as with Tangle and Weave
2751 (@pxref{WEB}).
2752
2753 @item -metapost
2754 @opindex -metapost
2755 Force interpretation of the input as MetaPost; this is the default of
2756 the filename extension is @samp{.mp}.
2757
2758 @item -style=@var{mftfile}[.mft]
2759 @opindex -style=@var{mftfile}
2760 @cindex style files
2761 @flindex plain.mft
2762 Read @var{mftfile} before anything else; a MFT style file typically
2763 contains only MFT directives as described above. The default style
2764 file is @file{plain.mft} (for Metafont) or @file{mplain.mft} (for
2765 MetaPost). MFT files are searched along the @code{MFTINPUTS} path
2766 (@pxref{Supported file formats,,, kpathsea, Kpathsea}).
2767
2768 @flindex cmbase.mft
2769 @flindex e.mft
2770 @cindex @cite{Computer Modern Typefaces}, production of
2771 Other examples of MFT style files are @file{cmbase.mft}, which defines
2772 formatting rules for the macros defined in @file{cm.base}, and
2773 @file{e.mft}, which was used in the production of Knuth's Volume@w{ }E,
2774 @cite{Computer Modern Typefaces}.
2775
2776 @cindex MetaPost source, prettyprinting
2777 Using an appropriate MFT style file, it is also possible to configure
2778 MFT for typesetting MetaPost sources. However, MFT does not search
2779 the usual places for MetaPost input files.
2780 @end table
2781
2782 If you use eight-bit characters in the input file, they are
2783 passed on verbatim to the @TeX{} output file; it is up to you to
2784 configure @TeX{} to print these properly.
2785
2786
2787 @node MetaPost
2788 @chapter MetaPost: Generating PostScript
2789
2790 @cindex MetaPost
2791 @cindex PostScript meets Metafont
2792 @cindex Metafont meets PostScript
2793 @cindex technical illustrations, creating
2794 MetaPost is a picture-drawing language similar to Metafont
2795 (@pxref{Metafont}), but instead of outputting bitmaps in a ``font'', it
2796 outputs PostScript commands. It's primarily intended for creating
2797 technical illustrations, but can also be used to create PostScript or
2798 OpenType fonts (@url{https://ctan.org/pkg/metatype1}).
2799
2800 @pindex troff@r{, supported in MetaPost}
2801 MetaPost also provides for arbitrary integration of text and graphics in
2802 a natural way, using any typesetter (@TeX{} and Troff are both
2803 supported) and a number of other subsidiary programs, described below.
2804
2805 @menu
2806 * mpost invocation:: Invoking MetaPost.
2807 * Initial MetaPost:: Making mems.
2808 * dvitomp invocation:: DVI-to-MPX translation.
2809 @end menu
2810
2811
2812 @node mpost invocation
2813 @section @code{mpost} invocation
2814
2815 @pindex mpost
2816 @cindex MetaPost invocation
2817
2818 @flindex mpman.pdf
2819 MetaPost (installed as @code{mpost}) reads a series of pictures
2820 specified in the MetaPost programming language, and outputs
2821 corresponding PostScript code. This section merely describes the
2822 options available in the Web2c implementation. For a complete
2823 description of the MetaPost language, see AT&T technical report
2824 CSTR-162, generally available in @file{@var{texmf}/doc/metapost/},
2825 where @var{texmf} is the root of @TeX{} directory structure.
2826 The MetaPost home page: @url{https://tug.org/metapost}.
2827
2828 @flindex mpgraph.pdf
2829 Also, a standard MetaPost package for drawing graphs is documented in
2830 AT&T technical report CSTR-164, available as the file @file{mpgraph.ps},
2831 generally stored alongside @file{mpman.ps}.
2832
2833 MetaPost processes its command line in a way analogous to Metafont and
2834 @TeX{} (@pxref{tex invocation,,@code{tex} invocation}).
2835 Synopses:
2836
2837 @example
2838 mpost [@var{option}]@dots{} [@var{mpname}[.mp]] [@var{mp-commands}]
2839 mpost [@var{option}]@dots{} \@var{first-line}
2840 mpost [@var{option}]@dots{} &@var{mem} @var{args}
2841 @end example
2842
2843 @flindex .mp
2844 @cindex MetaPost input files
2845 MetaPost searches the usual places for the main input file @var{mpname}
2846 (@pxref{Supported file formats,,, kpathsea, Kpathsea}), extending
2847 @var{mpname} with @file{.mp} if necessary. To see all the relevant
2848 paths, set the environment variable @code{KPATHSEA_DEBUG} to @samp{-1}
2849 before running the program.
2850
2851 @findex beginfig
2852 @flindex .@var{nnn} @r{PostScript figures}
2853 @flindex .tfm @r{output}
2854 @flindex mpout
2855 @cindex TFM files, output by MetaPost
2856 @cindex PostScript output
2857 MetaPost writes its PostScript output to a series of files
2858 @file{@var{basempname}.@var{nnn}} (or perhaps
2859 @file{@var{basempname}.ps}, very occasionally
2860 @file{@var{basempname}.tfm}), where @var{nnn} are the figure numbers
2861 specified in the input, typically to the @code{beginfig} macro, and
2862 @var{basempname} is the basename of @var{mpname}, or @samp{mpout} if no
2863 input file was specified. MetaPost uses the @samp{.ps} extension when
2864 the figure number is out of range, e.g., if you say @code{beginfig(-1)}.
2865
2866 You can use the output files as figures in a @TeX{} document just as
2867 with any other PostScript figures. For example, with this @TeX{} command:
2868 @example
2869 \special@{psfile="@var{filename}"@}
2870 @end example
2871 @noindent
2872 or by using @file{epsf.tex} (@pxref{EPSF macros,,, dvips, Dvips}).
2873
2874 @findex btex @r{for MetaPost labels}
2875 @findex etex @r{for MetaPost labels}
2876 The MetaPost construct
2877 @example
2878 btex @dots{} @var{tex-input} @dots{} etex
2879 @end example
2880 @noindent
2881 generates a MetaPost picture expression corresponding to
2882 @var{tex-input}.
2883
2884 The construct
2885 @example
2886 verbatimtex @dots{} @var{tex-input} @dots{} etex
2887 @end example
2888 @noindent
2889 simply passes the @var{tex-input} through to
2890 @TeX{}. For example, if you are using @LaTeX{}, your MetaPost input file
2891 must start with a @code{verbatimtex} block that gives the necessary
2892 @code{\documentclass} (or @code{\documentstyle})
2893 @code{\begin@{document@}} command. You will also need to set the
2894 environment variable @code{TEX} to @samp{latex}.
2895
2896 @var{tex-input} need not be specifically @TeX{} input; it could also be
2897 Troff. In that case, you will need the @samp{-m pictures} Troff macro
2898 package (unfortunately absent from many Troff implementations), or an
2899 equivalent such as the @samp{-m pspic} macros from GNU groff described
2900 in grops(1).
2901
2902 @cindex PostScript fonts, and Troff
2903 @cindex Troff, and MetaPost
2904 @cindex Computer Modern fonts, and Troff
2905 Naturally, you must use fonts that are supported by the typesetter;
2906 specifically, you'll probably want to use standard PostScript fonts with
2907 Troff. And only the @TeX{} system understands Computer Modern or other
2908 Metafont fonts; you can also use PostScript fonts with @TeX{}, of course.
2909
2910 @flindex mproof.tex
2911 @cindex downloading of fonts for MetaPost labels
2912 @cindex font downloading for MetaPost labels
2913 MetaPost-generated PostScript figures which do use Computer Modern fonts
2914 for labels cannot be directly previewed or printed. Instead, you must
2915 include them in a @TeX{} document and run the resulting DVI file through
2916 Dvips to arrange for the downloading of the required fonts (@pxref{Fonts
2917 in figures,,, dvips, Dvips}). To help with this, the MetaPost
2918 distribution provides a small @TeX{} file @file{mproof.tex} which is
2919 typically called as:
2920 @example
2921 tex mproof @var{mp-output-files}... ; dvips mproof -o
2922 @end example
2923 @noindent
2924 The resulting file @file{mproof.ps} can then be printed or previewed.
2925
2926 @vindex prologues@r{, and EPSF output}
2927 @flindex psfonts.map@r{, read by MetaPost}
2928 To generate EPSF files, set the internal MetaPost variable
2929 @code{prologues} positive. To make the output files self-contained, use
2930 only standard PostScript fonts. MetaPost reads the same
2931 @file{psfonts.map} file as Dvips, to determine PostScript fonts that
2932 need to be downloaded (@pxref{psfonts.map,,, dvips, Dvips}).
2933
2934 @cindex PDF, and @code{.mps} files
2935 @cindex @code{.mps} files and PDF
2936 It is possible for pdf@TeX{} to read MetaPost output directly; this is
2937 in contrast to general EPSF files, which have to be converted for use
2938 with PDF output. The easiest way is to name the MetaPost output files
2939 with the @code{.mps} extension. Then the @LaTeX{}
2940 @code{\includegraphics} command, for example, will be able to read
2941 them, even when outputting PDF.
2942
2943 @cindex security, and @code{write}
2944 MetaPost can write output files, via the @code{write} primitive; this
2945 opens a security hole. @xref{tex invocation}.
2946
2947 The program accepts the following options, as well as the standard
2948 @samp{-help} and @samp{-version} (@pxref{Common options}):
2949 @table @samp
2950 @item -[no]-file-line-error
2951 @itemx -halt-on-error
2952 @itemx -ini
2953 @itemx -interaction=@var{string}
2954 @itemx -jobname=@var{string}
2955 @itemx -kpathsea-debug=@var{number}
2956 @itemx -[no]parse-first-line
2957 @itemx -output-directory
2958 @itemx -progname=@var{string}
2959 @itemx -recorder
2960 @itemx -translate-file=@var{tcxfile}
2961 @itemx -8bit
2962 These options are common to @TeX{}, Metafont, and MetaPost.
2963 @xref{Common options}.
2964
2965 @item -debug
2966 @opindex -debug
2967 Print debugging information and leave temporary files in place.
2968
2969 @item -mem=@var{MPFILE}
2970 @opindex -mem
2971 Preload @var{MPFILE} instead of via the program name of @code{%&} line.
2972 This is a MetaPost source file; MetaPost no longer has binary mem files.
2973
2974 @item -numbersystem=@var{string}
2975 @opindex -numbersystem
2976 Set number system mode where @var{string} is one of:
2977 @code{scaled double binary interval decimal}.
2978
2979 @item -restricted
2980 @opindex -restricted
2981 Be secure: disable the @code{tex}, @code{makempx} and editor commands.
2982
2983 @item -s @var{internal}=@var{value}
2984 @opindex -s
2985 Set @var{INTERNAL} to @var{VALUE}, a string or integer.
2986
2987 @item -T
2988 @itemx -troff
2989 @opindex -T
2990 @opindex -troff
2991 @vindex prologues
2992 Set the @code{prologues} internal variable to @code{1}.
2993
2994 @item -tex=@var{texprogram}
2995 @opindex -tex=@var{texprogram}
2996 When this option is given, the program @var{texprogram} is used to
2997 typeset the labels.
2998
2999 @end table
3000
3001
3002 @node Initial MetaPost
3003 @section Initial MetaPost
3004
3005 @cindex initial MetaPost
3006 @cindex MetaPost, initial
3007
3008 As of MetaPost 1.504 (@TeX{} Live 2011), MetaPost no longer dumps
3009 @file{.mem} files (@pxref{Memory dumps}) and does not distinguish
3010 virgin and initial forms (@pxref{Initial and virgin}). Instead, the
3011 ``initial'' file name is read in its source form---that is,
3012 @file{mpost.mp} when the program is invoked as @command{mpost}. This
3013 is considered to be ``preloading'' the source.
3014
3015 For a list of options and other information, see @ref{mpost invocation}.
3016
3017 @cindex Metafont, compatibility in MetaPost
3018 @cindex plain Metafont, compatibility in MetaPost
3019 @cindex MetaPost and plain Metafont compatibility
3020 @flindex mfplain
3021 MetaPost provides a format with all the features of plain Metafont,
3022 called @file{mfplain}. You can use that in the same way; just run
3023 @command{mfplain} instead of @command{mpost}. This lets you directly
3024 process Metafont source files with MetaPost, producing character
3025 proofs (one file for each character) similar to those produced with
3026 Metafont in proof mode and GFtoDVI (@pxref{gftodvi invocation}).
3027
3028
3029 @node dvitomp invocation
3030 @section DVItoMP: DVI to MPX conversion
3031
3032 @pindex dvitomp
3033 @cindex DVI files, converting to MPX
3034 @cindex MPX files, converting from DVI files
3035
3036 DVItoMP converts DVI files into low-level MetaPost commands in a
3037 so-called MPX file. Synopsis:
3038
3039 @example
3040 dvitomp @var{dvifile}[.dvi] [@var{mpxfile}[.mpx]]
3041 @end example
3042
3043 @noindent
3044 If @var{mpxfile} is not specified, the output goes to the basename of
3045 @var{dvifile} extended with @file{.mpx}, e.g., @samp{dvitomp
3046 /wherever/foo.dvi} creates @file{./foo.mpx}.
3047
3048 @cindex color, in DVItoMP
3049 DVItoMP supports Dvips-style color specials, such as @samp{color push
3050 @var{name}} and @samp{color pop}, outputting them as @code{withcolor}
3051 MetaPost commands.
3052
3053 The only options are @samp{-help} and @samp{-version} (@pxref{Common
3054 options}).
3055
3056
3057 @node BibTeX
3058 @chapter Bib@TeX{}: Bibliographies
3059
3060 @cindex bibliographies, creating
3061 @cindex Bib@TeX{}
3062
3063 Bib@TeX{} automates much of the job of typesetting bibliographies, and
3064 makes bibliography entries reusable in many different contexts.
3065
3066 @menu
3067 * bibtex invocation::
3068 * Basic BibTeX style files:: The standard and semi-standard styles.
3069 @end menu
3070
3071
3072 @node bibtex invocation
3073 @section Bib@TeX{} invocation
3074
3075 @pindex bibtex
3076
3077 @flindex .bbl @r{bibliography files}
3078 @flindex .aux @r{cross-reference files}
3079 @flindex .bib @r{bibliography databases}
3080 Bib@TeX{} creates a printable bibliography (@file{.bbl}) file from
3081 references in a @file{.aux} file, generally written by @TeX{} or
3082 @LaTeX{}. The @file{.bbl} file is then incorporated on a subsequent
3083 run. The basic bibliographic information comes from @file{.bib} files,
3084 and a Bib@TeX{} style (@file{.bst}) file controls the precise contents
3085 of the @file{.bbl} file. Synopsis:
3086
3087 @example
3088 bibtex [@var{option}]@dots{} @var{auxfile}[.aux]
3089 @end example
3090
3091 @flindex .blg @r{Bib@TeX{} log file}
3092 @cindex log file, Bib@TeX{}
3093 @noindent
3094 The output goes to the basename of @var{auxfile} extended with
3095 @file{.bbl}; for example, @samp{bibtex /wherever/foo.aux} creates
3096 @file{./foo.bbl}. Bib@TeX{} also writes a log file to the basename of
3097 @var{auxfile} extended with @samp{.blg}.
3098
3099 @findex \bibliography
3100 @findex \bibliographystyle
3101 @vindex TEXBIB@r{, search path for bib files}
3102 @vindex BIBINPUTS@r{, search path for bib files}
3103 @vindex BSTINPUTS@r{, search path for bst files}
3104 The names of the @file{.bib} and @file{.bst} files are specified in the
3105 @file{.aux} file as well, via the @file{\bibliography} and
3106 @file{\bibliographystyle} (La)@TeX{} macros. Bib@TeX{} searches for
3107 @file{.bib} files using the @code{BIBINPUTS} and @code{TEXBIB} paths,
3108 and for @file{.bst} files using @code{BSTINPUTS} (@pxref{Supported file
3109 formats,,,kpathsea,Kpathsea}). It does no path searching for
3110 @file{.aux} files.
3111
3112 The program accepts the following options, as well as the standard
3113 @samp{-help} and @samp{-version} (@pxref{Common options}):
3114 @table @samp
3115 @item -terse
3116 @opindex -terse
3117 @cindex terse output
3118 @cindex verbose Bib@TeX{} output, suppressing
3119 Suppress the program banner and progress reports normally output.
3120
3121 @item -min-crossrefs=@var{n}
3122 @opindex -min-crossrefs=@var{n}
3123 @cindex cross-referenced bibliography items
3124 @cindex bibliography items, cross-referenced
3125 If at least @var{n} (2 by default) bibliography entries refer to another
3126 entry @var{e} via their @code{crossref} field, include @var{e} in the
3127 @t{.bbl} file, even if it was not explicitly referenced in the @t{.aux}
3128 file. For example, @var{e} might be a conference proceedings as a whole,
3129 with the cross-referencing entries being individual articles published
3130 in the proceedings.
3131
3132 If you want to avoid these automatic inclusions altogether, make
3133 @var{n} a sufficiently large number, and be sure to remove any
3134 previous @t{.aux} and @t{.bbl} files. Otherwise the option may
3135 appear to have no effect, since Bib@TeX{} will have added the citation
3136 for @var{e} to the @t{.aux}, and nothing will remove it.
3137
3138 @end table
3139
3140 See also:
3141 @table @file
3142 @item btxdoc.tex
3143 @flindex btxdoc.tex
3144 Basic @LaTeX{}able documentation for general Bib@TeX{} users.
3145
3146 @item btxhak.tex
3147 @flindex btxhak.tex
3148 @cindex style design, for Bib@TeX{}
3149 @LaTeX{}able documentation for style designers.
3150
3151 @item btxdoc.bib
3152 @flindex btxdoc.bib
3153 Bib@TeX{} database file for the two above documents.
3154
3155 @item xampl.bib
3156 @flindex xampl.bib
3157 Example database file with all the standard entry types.
3158
3159 @item @url{ftp://ftp.math.utah.edu/pub/tex/bib/}
3160 @flindex ftp.math.utah.edu
3161 @cindex Bib@TeX{} collection
3162 @cindex TUGboat bibliography
3163 @cindex @TeX{}, bibliographies for
3164 A very large @file{.bib} and @file{.bst} collection, including
3165 references for all the standard @TeX{} books and a complete bibliography
3166 for TUGboat.
3167 @end table
3168
3169
3170 @node Basic BibTeX style files
3171 @section Basic Bib@TeX{} style files
3172
3173 @cindex basic Bib@TeX{} style files
3174 @cindex Bib@TeX{} style files
3175
3176 Here are descriptions of the four standard and four semi-standard basic
3177 Bib@TeX{} styles. @file{@var{CTAN:}/biblio/bibtex} contains these and
3178 many more (for CTAN info, @pxref{unixtex.ftp,,, kpathsea, Kpathsea}).
3179
3180 @table @code
3181 @item plain
3182 @flindex plain.bst
3183 Sorts entries alphabetically, with numeric labels. Generally formatted
3184 according to van Leunen's @cite{A Handbook for Scholars}. The other
3185 style files listed here are based on @code{plain}.
3186
3187 @item abbrv
3188 @flindex abbrv.bst
3189 First names, month names, and journal names are abbreviated.
3190
3191 @item acm
3192 @flindex acm.bst
3193 Names are printed in small caps.
3194
3195 @item alpha
3196 @flindex alpha.bst
3197 Alphanumeric labels, e.g., @samp{Knu66}.
3198
3199 @item apalike
3200 @flindex apalike.bst
3201 No labels at all; instead, the year appears in parentheses after the author.
3202 Use this in conjunction with @file{apalike.tex} (plain @TeX{}) or
3203 @file{apalike.sty} (@LaTeX{}), which also changes the citations in the
3204 text to be @samp{(@var{author}, @var{year})}.
3205
3206 @item ieeetr
3207 @flindex ieeetr.bst
3208 Numeric labels, entries in citation order, @sc{ieee} abbreviations,
3209 article titles in quotes.
3210
3211 @item siam
3212 @flindex siam.bst
3213 Numeric labels, alphabetic order, @cite{Math.@: Reviews}
3214 abbreviations, names in small caps.
3215
3216 @item unsrt
3217 @flindex unsrt.bst
3218 Lists entries in citation order, i.e., unsorted.
3219
3220 @item btxbst.doc
3221 The template file and documentation for the standard styles.
3222
3223 @end table
3224
3225
3226 @node WEB
3227 @chapter WEB: Literate programming
3228
3229 @cindex WEB
3230 @cindex literate programming
3231
3232 @dfn{WEB} languages allow you to write a single source file that can
3233 produce both a compilable program and a well-formatted document
3234 describing the program in as much detail as you wish to prepare.
3235 Writing in this kind of dual-purpose language is called @dfn{literate
3236 programming}. (The Usenet newsgroup @file{comp.programming.literate}
3237 is devoted to this subject.)
3238
3239 @flindex webman.tex
3240 @cindex Spiderweb
3241 @cindex Cweb
3242 @cindex CWEB
3243 @cindex Awk, WEB for
3244 @cindex Ada, WEB for
3245 @cindex Troff, WEB for
3246 WEB-like languages have been implemented with many pairs of base
3247 languages: Cweb provides C and Troff (@pxref{References}); CWEB provides
3248 C and @TeX{} (@file{@var{CTAN:}/web/c_cpp/cweb}); Spiderweb provides C,
3249 C++, Awk, Ada, many others, and @TeX{}
3250 (@file{@var{CTAN:}/web/spiderweb}); and, of course, the original WEB
3251 provides Pascal and @TeX{}, the implementation languages for the
3252 original @TeX{}, Metafont, MetaPost, and related programs to come from
3253 the @TeX{} project at Stanford.
3254
3255 Knuth's original WEB language is documented in the file
3256 @file{webman.tex}, available as a formatted pdf in the
3257 @code{knuth-pdf} page (@url{https://ctan.org/pkg/knuth-pdf}).
3258
3259 @menu
3260 * tangle invocation::
3261 * weave invocation::
3262 * pooltype invocation::
3263 @end menu
3264
3265
3266 @node tangle invocation
3267 @section Tangle: Translate WEB to Pascal
3268
3269 @pindex tangle
3270 @cindex Pascal, creating from WEB
3271 @cindex WEB programs, compiling
3272
3273 Tangle creates a compilable Pascal program from a WEB source file
3274 (@pxref{WEB}). Synopsis:
3275
3276 @example
3277 tangle [@var{option}]@dots{} @var{webfile}[.web] [@var{changefile}[.ch]]
3278 @end example
3279
3280 @cindex change files, and Tangle
3281 @noindent
3282 The Pascal output is written to the basename of @var{webfile} extended
3283 with @samp{.p}; for example, @samp{tangle /wherever/foo.web} creates
3284 @file{./foo.p}. Tangle applies @var{changefile} to @var{webfile} before
3285 writing the output; by default, there is no change file.
3286
3287 @cindex pool file, writing
3288 @cindex string pool, writing
3289 If the program makes use of the WEB string facility, Tangle writes the
3290 string pool to the basename of @var{webfile} extended with @samp{.pool}.
3291
3292 The Pascal output is packed into lines of 72 characters or less, with
3293 the only concession to readability being the termination of lines at
3294 semicolons when this can be done conveniently.
3295
3296 The program accepts the following options, as well as the standard
3297 @samp{--help} and @samp{--version} (@pxref{Common options}):
3298
3299 @table @samp
3300 @item -length=@var{number}
3301 @opindex -length=@var{number}
3302 @cindex identifier length
3303 The number of characters that are considered significant in an
3304 identifier. Whether underline characters are counted depends on the
3305 @samp{-underline} option. The default value is 32, the original tangle
3306 used 7, but this proved too restrictive for use by Web2c.
3307
3308 @item -lowercase
3309 @itemx -mixedcase
3310 @itemx -uppercase
3311 @opindex -lowercase
3312 @opindex -mixedcase
3313 @opindex -uppercase
3314 @cindex identifier case
3315 These options specify the case of identifiers in the output of tangle.
3316 If @samp{-uppercase} (@samp{-lowercase}) is specified, tangle will
3317 convert all identifiers to uppercase (lowercase). The default is
3318 @samp{-mixedcase}, which specifies that the case will not be changed.
3319
3320 @item -underline
3321 @opindex -underline
3322 @cindex identifiers with underlines
3323 When this option is given, tangle does not strip underline characters
3324 from identifiers.
3325
3326 @item -loose
3327 @itemx -strict
3328 @opindex -loose
3329 @opindex -strict
3330 @cindex identifier collisions
3331 These options specify how strict tangle must be when checking
3332 identifiers for equality. The default is @samp{-loose}, which means
3333 that tangle will follow the rules set by the case-smashing and underline
3334 options above. If @samp{-strict} is set, then identifiers will always
3335 be stripped of underlines and converted to uppercase before checking
3336 whether they collide.
3337
3338 @end table
3339
3340 @node weave invocation
3341 @section Weave: Translate WEB to @TeX{}
3342
3343 @pindex weave
3344 @cindex @TeX{}, creating from WEB
3345 @cindex WEB programs, typesetting
3346 @cindex prettyprinting WEB programs
3347
3348 Weave creates a @TeX{} document from a WEB source file (@pxref{WEB}),
3349 assuming various macros defined in @file{webmac.tex}. It takes care of
3350 typographic details such as page layout, indentation, and italicizing
3351 identifiers. It also automatically gathers and outputs extensive
3352 cross-reference information. Synopsis:
3353
3354 @example
3355 weave [@var{option}]@dots{} @var{webfile}[.web] [@var{changefile}[.ch]]
3356 @end example
3357
3358 @cindex change files, and Weave
3359 @noindent
3360 The output is to the basename of @var{webfile} extended with
3361 @samp{.tex}; for example, @samp{weave /wherever/foo.web} creates
3362 @file{./foo.tex}. Weave applies @var{changefile} to @var{webfile}
3363 before writing the output; by default, there is no change file.
3364
3365 The Web2c version of Weave accepts 8-bit characters as themselves.
3366 This can cause trouble with various internal WEB control codes, and
3367 should not be relied on.
3368
3369 The program accepts the following option, as well as the standard
3370 @samp{-verbose}, @samp{-help} and @samp{-version} (@pxref{Common
3371 options}):
3372 @table @samp
3373 @item -x
3374 @opindex -x
3375 @cindex cross-references, omitting
3376 @flindex CONTENTS.tex
3377 @flindex webmac.tex
3378 Omit the cross-reference information: the index, the list of WEB module
3379 names, and the table of contents (an empty @file{CONTENTS.tex} file will
3380 still be written when the Weave output file is processed by @TeX{} using
3381 the default @file{webmac.tex}, though).
3382 @end table
3383
3384 Conventionally, WEB programmers should define the @TeX{} @code{\title}
3385 macro at the beginning of the source file. Also, to get output of only
3386 changed modules, one can say @code{\let\maybe=\iffalse} (usually as the
3387 first change in the change file).
3388
3389
3390 @node pooltype invocation
3391 @section Pooltype: Display WEB pool files
3392
3393 @pindex pooltype
3394 @cindex type programs, pool
3395 @cindex string numbers, displaying
3396 @cindex WEB pool files, displaying
3397
3398 Pooltype shows the so-called @dfn{string number} of each string in a WEB
3399 pool file (@pxref{WEB}), as output by Tangle (@pxref{tangle
3400 invocation}), including the first 256 strings corresponding to the
3401 possible input characters. Pooltype primarily serves as an example of
3402 WEB conventions to implementors of the @TeX{} system. Synopsis:
3403
3404 @example
3405 pooltype [@var{option}]@dots{} @var{poolfile}[.pool]
3406 @end example
3407
3408 @noindent
3409 No path searching is done for @var{poolfile}. Output is to standard
3410 output.
3411
3412 The only options are @samp{--help} and @samp{--version} (@pxref{Common
3413 options}).
3414
3415 As an example of the output, here is the (edited) output for @file{tex.pool}:
3416 @example
3417 0: "^^@@"
3418 1: "^^A"
3419 @dots{}
3420 255: "^^ff"
3421 256: "pool size"
3422 @dots{}
3423 1314: "Using character substitution: "
3424 (23617 characters in all.)
3425 @end example
3426
3427 @cindex representation of strings
3428 @cindex string representation
3429 In Metafont and MetaPost, the first 256 characters are represented as
3430 single bytes (i.e., themselves), not in the @samp{^^} notation. Thus,
3431 Pooltype shows the results after conversion for output.
3432
3433
3434 @node DVI utilities
3435 @chapter DVI utilities
3436
3437 @cindex DVI utilities
3438
3439 @TeX{} outputs a file in @dfn{DVI} (DeVice Independent) format as a
3440 compact representation of the original document. DVI files can be
3441 translated to meet the requirements of a real physical device, such as
3442 PostScript printers (@pxref{Top,, Introduction, dvips, Dvips}), PCL
3443 printers (see dvilj(1)), and X displays (see xdvi(1)). In fact, DVI
3444 translators are available for virtually all common devices: see
3445 @file{@var{CTAN:}/dviware} (for CTAN info, @pxref{unixtex.ftp,,,
3446 kpathsea, Kpathsea}).
3447
3448 @flindex dvitype.web
3449 @cindex DVI format definition
3450 For the precise definition of the DVI file format, see (for example) the
3451 source file @file{web2c/dvitype.web}.
3452
3453 The DVI-processing programs in the Web2c distribution are not device
3454 drivers; they perform generic utility functions.
3455
3456 @menu
3457 * dvicopy invocation:: Expand virtual fonts.
3458 * dvitype invocation:: DVI to human-readable text.
3459 @end menu
3460
3461 @node dvicopy invocation
3462 @section DVIcopy: Canonicalize virtual font references
3463
3464 @pindex dvicopy
3465 @cindex virtual fonts, expanding
3466
3467 DVIcopy reads a DVI file, expands any references to virtual fonts
3468 (@pxref{Virtual fonts,,, dvips, Dvips}) to base fonts, and writes the
3469 resulting DVI file. Thus you can use virtual fonts even if your DVI
3470 processor does not support them, by passing the documents through
3471 DVIcopy first. Synopsis:
3472
3473 @example
3474 dvicopy [@var{option}]@dots{} [@var{indvi}[.dvi] [@var{outdvi}[.dvi]]]
3475 @end example
3476
3477 DVIcopy reads standard input if @var{indvi} is not specified, and writes
3478 standard output if @var{outdvi} is not specified.
3479
3480 The program accepts the following options, as well as the standard
3481 @samp{-help} and @samp{-version} (@pxref{Common options}):
3482 @table @samp
3483 @item -magnification=@var{integer}
3484 @opindex -magnification=@var{integer}
3485 @cindex magnification
3486 @findex \mag
3487 Override existing magnification in @var{indvi} with @var{integer}; 1000
3488 specifies no magnification. This is equivalent to setting @TeX{}'s
3489 @code{\mag} parameter.
3490
3491 @item -max-pages=@var{n}
3492 @opindex -max-pages=@var{n}
3493 Process @var{n} pages; default is one million.
3494
3495 @item -page-start=@var{page-spec}
3496 @opindex -page-start=@var{page-spec}
3497 @cindex starting page
3498 @cindex page, starting
3499 @findex \count@var{n}
3500 Start at the first page matching @var{page-spec}, which is one or more
3501 (signed) integers separated by periods, corresponding to @TeX{}'s
3502 @code{\count0@dots{}9} parameters at @code{\shipout} time; @samp{*}
3503 matches anything. Examples: @samp{3}, @samp{1.*.-4}.
3504 @end table
3505
3506
3507 @node dvitype invocation
3508 @section DVItype: Plain text transliteration of DVI files
3509
3510 @pindex dvitype @r{DVI validation}
3511 @cindex conversion, DVI to plain text
3512 @cindex plain text, converting DVI to
3513 @cindex human-readable text, converting DVI to
3514 @cindex type programs, DVI
3515 @cindex validation, of DVI files
3516
3517 DVItype translates a DeVice Independent (DVI) file (as output by @TeX{},
3518 for example) to a plain text file that humans can read. It also serves
3519 as a DVI-validating program, i.e., if DVItype can read a file, it's
3520 correct. Synopsis:
3521
3522 @example
3523 dvitype [@var{option}]@dots{} @var{dvifile}[.dvi]
3524 @end example
3525
3526 @noindent
3527 DVItype does not read any bitmap files, but it does read TFM files for
3528 fonts referenced in @var{dvifile}. The usual places are searched
3529 (@pxref{Supported file formats,,, kpathsea, Kpathsea}). To see all the
3530 relevant paths, set the environment variable @code{KPATHSEA_DEBUG} to
3531 @samp{-1} before running the program.
3532
3533 Output goes to standard output.
3534
3535 The program accepts the following options, as well as the standard
3536 @samp{-help} and @samp{-version} (@pxref{Common options}):
3537 @table @samp
3538 @item -dpi=@var{real}
3539 @opindex -dpi=@var{real}
3540 Do pixel movement calculations at @var{real} pixels per inch; default
3541 300.0.
3542
3543 @item -magnification=@var{integer}
3544 @opindex -magnification=@var{integer}
3545 @cindex magnification
3546 @findex \mag
3547 Override existing magnification in @var{indvi} with @var{integer}; 1000
3548 specifies no magnification. This is equivalent to setting @TeX{}'s
3549 @code{\mag} parameter.
3550
3551 @item -max-pages=@var{n}
3552 @opindex -max-pages=@var{n}
3553 Process @var{n} pages; default is one million.
3554
3555 @item -output-level=@var{n}
3556 @opindex -output-level=@var{n}
3557 Verbosity level of output, from 0 to 4 (default 4):
3558 @itemize @bullet
3559 @item 0: Global document information only.
3560 @item 1: Most DVI commands included, and typeset characters summarized.
3561 @item 2: Character and movement commands explicitly included.
3562 @item 3: DVI stack and current position calculations included.
3563 @item 4: Same information as level 3, but DVItype does random positioning
3564 in the file, reading the DVI postamble first.
3565 @end itemize
3566
3567 @item -page-start=@var{page-spec}
3568 @opindex -page-start=@var{page-spec}
3569 @cindex starting page
3570 @cindex page, starting
3571 @findex \count@var{n}
3572 Start at the first page matching @var{page-spec}, which is one or more
3573 (signed) integers separated by periods, corresponding to @TeX{}'s
3574 @code{\count0@dots{}9} parameters at @code{\shipout} time; @samp{*}
3575 matches anything. Examples: @samp{1}, @samp{5.*.-9}.
3576
3577 @item -show-opcodes
3578 @opindex -show-opcodes
3579 @cindex opcodes, showing DVI
3580 @cindex DVI opcodes, showing
3581 @cindex debugging DVI utilities
3582 Show numeric opcode values (in decimal) for DVI commands, in braces
3583 after the command name. This can help in debugging DVI utilities. We
3584 use decimal because in the DVI format documentation (in
3585 @file{dvitype.web}, among others) the opcodes are shown in decimal.
3586 @end table
3587
3588 @menu
3589 * dvitype output example::
3590 @end menu
3591
3592
3593 @node dvitype output example
3594 @subsection DVItype output example
3595
3596 @cindex dvitype output example
3597 As an example of the output from DVItype (see section above), here is
3598 its (abridged) translation of the @file{story.dvi} resulting from
3599 running the example in @cite{The @TeX{}book}, with
3600 @samp{-output-level=4} and @samp{-show-opcodes} on.
3601
3602 @example
3603 @dots{}
3604 Options selected:
3605 Starting page = *
3606 Maximum number of pages = 1000000
3607 Output level = 4 (the works)
3608 Resolution = 300.00000000 pixels per inch
3609 numerator/denominator=25400000/473628672
3610 magnification=1000; 0.00006334 pixels per DVI unit
3611 ' TeX output 1992.05.17:0844'
3612 Postamble starts at byte 564.
3613 maxv=43725786, maxh=30785863, maxstackdepth=3, totalpages=1
3614 Font 33: cmsl10---loaded at size 655360 DVI units
3615 Font 23: cmbx10---loaded at size 655360 DVI units
3616 Font 0: cmr10---loaded at size 655360 DVI units
3617
3618 42: beginning of page 1
3619 87: push @{141@}
3620 level 0:(h=0,v=0,w=0,x=0,y=0,z=0,hh=0,vv=0)
3621 88: down3 -917504 @{159@} v:=0-917504=-917504, vv:=-58
3622 92: pop @{142@}
3623 @dots{}
3624 104: putrule @{137@} height 26214, width 30785863 (2x1950 pixels)
3625 113: down3 5185936 @{159@} v:=655360+5185936=5841296, vv:=370
3626 117: push @{141@}
3627 level 1:(h=0,v=5841296,w=0,x=0,y=0,z=0,hh=0,vv=370)
3628 118: right4 12265425 @{146@} h:=0+12265425=12265425, hh:=777
3629 [ ]
3630 123: fntdef1 23 @{243@}: cmbx10
3631 145: fntnum23 @{194@} current font is cmbx10
3632 146: setchar65 h:=12265425+569796=12835221, hh:=813
3633 147: w3 251220 @{150@} h:=12835221+251220=13086441, hh:=829
3634 151: setchar83 h:=13086441+418700=13505141, hh:=856
3635 @dots{}
3636 164: setchar82 h:=17448202+565245=18013447, hh:=1142
3637 165: x0 -62805 @{152@} h:=18013447-62805=17950642, hh:=1138
3638 166: setchar89 h:=17950642+569796=18520438, hh:=1174
3639 [A SHORT STORY]
3640 167: pop @{142@}
3641 level 1:(h=0,v=5841296,w=0,x=0,y=0,z=0,hh=0,vv=370)
3642 @dots{}
3643 550: pop @{142@}
3644 level 0:(h=0,v=42152922,w=0,x=0,y=0,z=0,hh=0,vv=2670)
3645 551: down3 1572864 @{159@} v:=42152922+1572864=43725786, vv:=2770
3646 555: push @{141@}
3647 level 0:(h=0,v=43725786,w=0,x=0,y=0,z=0,hh=0,vv=2770)
3648 556: right4 15229091 @{146@} h:=0+15229091=15229091, hh:=965
3649 561: setchar49 h:=15229091+327681=15556772, hh:=986
3650 [ 1]
3651 562: pop @{142@}
3652 level 0:(h=0,v=43725786,w=0,x=0,y=0,z=0,hh=0,vv=2770)
3653 563: eop @{140@}
3654 @end example
3655
3656 Explanation:
3657
3658 @itemize @bullet
3659 @item
3660 The DVItype options are recorded at the beginning, followed by
3661 global information about the document, including fonts used.
3662
3663 @item
3664 Each DVI command is preceded by its byte position in the file
3665 (@samp{42:}, @samp{87:}, @dots{}), and (because of the
3666 @samp{-show-opcodes}) followed by its decimal opcode value in braces
3667 (@samp{@{141@}}, @samp{@{142@}}, @dots{}).
3668
3669 @item
3670 The @samp{level} lines record information about the DVI stack; @samp{h}
3671 and @samp{v} define the current position in DVI units, while @samp{hh}
3672 and @samp{vv} are the same in pixels.
3673
3674 @item
3675 Text sequences are summarized in brackets, as in @samp{[A SHORT
3676 STORY]} and the @samp{[ 1]}.
3677 @end itemize
3678
3679
3680 @node Font utilities
3681 @chapter Font utilities
3682
3683 @cindex font utilities
3684
3685 The Web2c programs described here convert between various @TeX{}-related
3686 font formats; the first section below briefly describes the
3687 formats. GFtoPK is the only one that is routinely used, as Metafont
3688 outputs GF format, but it's most efficient for device drivers to use PK.
3689
3690 @flindex pktype.web
3691 @flindex gftype.web
3692 @cindex PK format definition
3693 @cindex GF format definition
3694 The precise definitions of the PK, GF, TFM, PL, VF, and VPL formats
3695 mentioned below are in the source files that read them;
3696 @file{pktype.web}, @file{gftype.web}, @file{tftopl.web}, etc.
3697
3698 @menu
3699 * Font file formats:: Explanations of GF, PK, TFM, VF, ...
3700 * gftopk invocation:: GF -> PK (compact)
3701 * pktogf invocation:: PK -> GF (expand).
3702 * pktype invocation:: PK -> human-readable text.
3703 * gftype invocation:: GF -> human-readable text.
3704 * tftopl invocation:: TFM -> PL (for editing TFM).
3705 * pltotf invocation:: PL -> TFM (make editing results usable).
3706 * vftovp invocation:: VF -> VPL (tftopl for virtual fonts).
3707 * vptovf invocation:: VPL -> VF (pltotf for virtual fonts).
3708 * Font utilities available elsewhere:: Type 1, BDF, editors, etc.
3709 @end menu
3710
3711
3712 @node Font file formats
3713 @section Font file formats
3714
3715 @cindex font file formats
3716 @cindex file formats for fonts
3717
3718 For another perspective on this, @pxref{Font concepts,,, dvips,
3719 Dvips}.
3720
3721 Font files come in several varieties, with suffixes like:
3722 @example
3723 .tfm .*pk .*gf .*pxl@r{ (obsolete)} .pl .mf .vf .vpl
3724 @end example
3725 @noindent
3726 Each represents a file format.
3727
3728 @cindex TFM files, explained
3729 A TFM (@TeX{} font metric) file is a compact binary file that contains
3730 information about each character in a font, about combinations of
3731 characters within that font, and about the font as a whole. The font
3732 metric information contained in TFM files is device-independent units is
3733 used by @TeX{} to do typesetting. Unlike the bitmap (raster) fonts
3734 described below, TFM font files contain no information about the shapes
3735 of characters. They describe rectangular areas and combinations
3736 thereof, but not what will eventually be printed in those areas.
3737
3738 @cindex scaling of fonts
3739 @cindex optical font scaling
3740 @cindex geometric font scaling
3741 @cindex PostScript, and font scaling
3742 Since @TeX{} does scaling calculations, one TFM file serves for all
3743 magnifications of a given typeface. On the other hand, the best printed
3744 results are obtained when magnified (or reduced fonts) are not produced
3745 geometrically (as done by PostScript, for example) but rather optically,
3746 with each size a separate design (as done with Computer Modern and the
3747 EC fonts, for example); then a separate TFM file is needed for each
3748 size.
3749
3750 @cindex DVI files, explained
3751 At any rate, @TeX{} produces a DVI (DeVice Independent) file from your
3752 source document. In order to print DVI files on real devices, you need
3753 font files defining digitized character shapes and other data. Then
3754 previewers and printer-driver programs can translate your DVI files into
3755 something usable by your monitor or printer. Bitmap fonts come with
3756 suffixes such as @samp{.600pk} or @samp{.600gf} or @samp{.3000pxl}, where
3757 the @samp{600} is the horizontal dots-per-inch resolution at which the
3758 font was produced, and the @samp{pk} or @samp{gf} or @samp{pxl}
3759 indicates the font format. Outline fonts in PostScript Type 1 format
3760 have suffixes such as @samp{.pfa} or @samp{.pfb}.
3761
3762 @cindex PXL files, explained
3763 @cindex PK files, explained
3764 @cindex GF files, explained
3765 Fonts in pk (packed) format are in the tightly packed raster format that
3766 is pretty much the standard today. They take up less space than fonts
3767 in the gf (generic font) format that Metafont generates, and far less
3768 space than fonts in pxl format. Fonts in pxl format take up gross
3769 amounts of disk space and permit only 128 characters. They are
3770 obsolete.
3771
3772 @cindex PL files, explained
3773 Font files with the @samp{.pl} (property list) suffix are the plain text
3774 (human-readable) analog of the binary @samp{.tfm} files.
3775 The TFtoPL and PLtoTF programs convert between the two formats
3776 (@pxref{tftopl invocation} and @ref{pltotf invocation}).
3777
3778 Font files with the @samp{.mf} suffix are in Metafont source format.
3779 These are the files used by Metafont to generate rastered fonts for
3780 specific typefaces at specific magnifications for the specific
3781 resolution and type of mapping used by your device.
3782
3783 @flindex virtual-fonts.knuth
3784 @flindex virtualfonts.txt
3785 The suffix @samp{.vf} identifies ``virtual font'' files, for which
3786 @samp{.vpl} is the human-readable analog. See @xref{vftovp invocation},
3787 and @ref{vptovf invocation}. For further discussion of virtual fonts,
3788 see @file{@var{CTAN:}/doc/virtual-fonts.knuth},
3789 @file{@var{CTAN:}/help/virtualfonts.txt}, and @ref{Virtual fonts,,,
3790 dvips, Dvips}.
3791
3792 @cindex MacKay, Pierre
3793 @cindex Tachikawa, Elizabeth
3794 (This section is based on documentation in the original Unix @TeX{}
3795 distribution by Pierre MacKay and Elizabeth Tachikawa.)
3796
3797
3798 @node gftopk invocation
3799 @section GFtoPK: Generic to packed font conversion
3800
3801 @pindex gftopk
3802 @cindex conversion, GF to PK
3803 @cindex PK, converting GF to
3804 @cindex GF, converting to PK
3805
3806 GFtoPK converts a generic font (GF) file output by, for example,
3807 Metafont (@pxref{mf invocation}) to a packed font (PK) file. PK files
3808 are considerably smaller than the corresponding gf files, so they are
3809 generally the bitmap font format of choice. Some DVI-processing
3810 programs, notably Dvips, only support PK files and not GF files.
3811 Synopsis:
3812
3813 @example
3814 gftopk [@var{option}]@dots{} @var{gfname}.@var{dpi}[gf] [@var{pkfile}]
3815 @end example
3816
3817 @noindent
3818 The font @var{gfname} is searched for in the usual places (@pxref{Glyph
3819 lookup,,, kpathsea, Kpathsea}). To see all the relevant paths, set the
3820 environment variable @code{KPATHSEA_DEBUG} to @samp{-1} before running
3821 the program.
3822
3823 The suffix @samp{gf} is supplied if not already present. This suffix is
3824 not an extension; no @samp{.} precedes it: for instance,
3825 @file{cmr10.600gf}.
3826
3827 If @var{pkfile} is not specified, the output is written to the basename
3828 of @samp{@var{gfname}.@var{dpi}pk}, e.g., @samp{gftopk
3829 /wherever/cmr10.600gf} creates @file{./cmr10.600pk}.
3830
3831 The only options are @samp{--verbose}, @samp{--help}, and
3832 @samp{--version} (@pxref{Common options}).
3833
3834
3835 @node pktogf invocation
3836 @section PKtoGF: Packed to generic font conversion
3837
3838 @pindex pktogf
3839 @cindex conversion, PK to GF
3840 @cindex GF, converting PK to
3841 @cindex PK, converting to GF
3842
3843 PKtoGF converts a packed font (PK) file to a generic font (GF) file.
3844 Since PK format is much more compact than GF format, the most likely
3845 reason to do this is to run GFtype (@pxref{gftype invocation}) on the
3846 result, so you can see the bitmap images. Also, a few old utility
3847 programs do not support PK format. Synopsis:
3848
3849 @example
3850 pktogf [@var{option}]@dots{} @var{pkname}.@var{dpi}[pk] [@var{gffile}]
3851 @end example
3852
3853 @noindent
3854 The font @var{pkname} is searched for in the usual places (@pxref{Glyph
3855 lookup,,, kpathsea, Kpathsea}). To see all the relevant paths, set the
3856 environment variable @code{KPATHSEA_DEBUG} to @samp{-1} before running
3857 the program.
3858
3859 The suffix @samp{pk} is supplied if not already present. This suffix is
3860 not an extension; no @samp{.} precedes it: for instance,
3861 @file{cmr10.600pk}.
3862
3863 If @var{gffile} is not specified, the output is written to the basename
3864 of @samp{@var{pkname}.@var{dpi}gf}, e.g., @samp{pktogf
3865 /wherever/cmr10.600pk} creates @file{./cmr10.600gf}.
3866
3867 The only options are @samp{--verbose}, @samp{--help}, and
3868 @samp{--version} (@pxref{Common options}).
3869
3870
3871 @node pktype invocation
3872 @section PKtype: Plain text transliteration of packed fonts
3873
3874 @pindex pktype @r{PK validation}
3875 @cindex conversion, PK to plain text
3876 @cindex plain text, converting PK to
3877 @cindex human-readable text, converting PK to
3878 @cindex type programs, PK
3879 @cindex validation, of PK files
3880
3881 PKtype translates a packed font (PK) bitmap file (as output by GFtoPK,
3882 for example) to a plain text file that humans can read. It also serves
3883 as a PK-validating program, i.e., if PKtype can read a file, it's
3884 correct. Synopsis:
3885
3886 @example
3887 pktype @var{pkname}.@var{dpi}[pk]
3888 @end example
3889
3890 The font @var{pkname} is searched for in the usual places (@pxref{Glyph
3891 lookup,,, kpathsea, Kpathsea}). To see all the relevant paths, set the
3892 environment variable @code{KPATHSEA_DEBUG} to @samp{-1} before running
3893 the program.
3894
3895 The suffix @samp{pk} is supplied if not already present. This suffix is
3896 not an extension; no @samp{.} precedes it: for instance, @file{cmr10.600pk}.
3897
3898 The translation is written to standard output.
3899
3900 The only options are @samp{-help} and @samp{-version}
3901 (@pxref{Common options}).
3902
3903 As an example of the output, here is the (abridged) translation of the
3904 letter `K' in @samp{cmr10}, as rendered at 600@dmn{dpi} with the mode
3905 @samp{ljfour} from @file{modes.mf} (@url{https://ctan.org/pkg/modes}).
3906
3907 @smallexample
3908 955: Flag byte = 184 Character = 75 Packet length = 174
3909 Dynamic packing variable = 11
3910 TFM width = 815562 dx = 4259840
3911 Height = 57 Width = 57 X-offset = -3 Y-offset = 56
3912 [2]23(16)17(8)9(25)11(13)7(27)7(16)7(28)4(18)7(28)2(20)7(27)@dots{}
3913 @dots{}
3914 (14)9(24)12(5)[2]23(13)21
3915 @end smallexample
3916
3917 @noindent
3918 Explanation:
3919
3920 @table @samp
3921 @item 955
3922 @cindex byte position
3923 The byte position in the file where this character starts.
3924
3925 @item Flag byte
3926 @itemx Dynamic packing variable
3927 @cindex flag byte
3928 @cindex dynamic packing variable
3929 Related to the packing for this character; see the source code.
3930
3931 @item Character
3932 @cindex character codes, in PKtype output
3933 The character code, in decimal.
3934
3935 @item Packet length
3936 @cindex packet length
3937 The total length of this character definition, in bytes.
3938
3939 @item TFM width
3940 @cindex TFM width of characters
3941 @cindex device-independent width
3942 @cindex width, device-independent
3943 The device-independent (TFM) width of this character. It is 2^24
3944 times the ratio of the true width to the font's design size.
3945
3946 @item dx
3947 @cindex horizontal escapement
3948 @cindex escapement, horizontal
3949 @cindex scaled pixels
3950 @cindex dx @r{horizontal escapement}
3951 The device-dependent width, in @dfn{scaled pixels}, i.e., units of
3952 horizontal pixels times 2^16.
3953
3954 @item Height
3955 @itemx Width
3956 @cindex height, in pixels
3957 @cindex pixel height
3958 @cindex pixel width
3959 @cindex width, in pixels
3960 The bitmap height and width, in pixels.
3961
3962 @item X-offset
3963 @itemx Y-offset
3964 @cindex x offset
3965 @cindex y offset
3966 @cindex origin
3967 @cindex reference pixel
3968 @cindex side bearings
3969 @cindex left side bearing
3970 @cindex right side bearing
3971 Horizontal and vertical offset from the upper left pixel to the
3972 reference (origin) pixel for this character, in pixels (right and down
3973 are positive). The @dfn{reference pixel} is the pixel that occupies the
3974 unit square in Metafont; the Metafont reference point is the lower left
3975 hand corner of this pixel. Put another way, the x-offset is the negative
3976 of the left side bearing; the right side bearing is the horizontal
3977 escapement minus the bitmap width plus the x-offset.
3978
3979 @item [2]23(16)@dots{}
3980 @cindex run length encoded bitmaps
3981 @cindex repeated rows
3982 Finally, run lengths of black pixels alternate with parenthesized run
3983 lengths of white pixels, and brackets indicate a repeated row.
3984 @end table
3985
3986
3987 @node gftype invocation
3988 @section GFtype: Plain text transliteration of generic fonts
3989
3990 @pindex gftype @r{GF validation}
3991 @cindex conversion, GF to plain text
3992 @cindex plain text, converting GF to
3993 @cindex human-readable text, converting GF to
3994 @cindex type programs, GF
3995 @cindex validation, of GF files
3996
3997 GFtype translates a generic font (GF) bitmap file (as output by
3998 Metafont, for example) to a plain text file that humans can read. It
3999 also serves as a GF-validating program, i.e., if GFtype can read a file,
4000 it's correct. Synopsis:
4001
4002 @example
4003 gftype [@var{option}]@dots{} @var{gfname}.@var{dpi}[gf]
4004 @end example
4005
4006 The font @var{gfname} is searched for in the usual places (@pxref{Glyph
4007 lookup,,, kpathsea, Kpathsea}). To see all the relevant paths, set the
4008 environment variable @code{KPATHSEA_DEBUG} to @samp{-1} before running
4009 the program.
4010
4011 The suffix @samp{gf} is supplied if not already present. This suffix is
4012 not an extension; no @samp{.} precedes it: for instance, @file{cmr10.600gf}.
4013
4014 The translation is written to standard output.
4015
4016 The program accepts the following options, as well as the standard
4017 @samp{-help} and @samp{-version} (@pxref{Common options}):
4018 @table @samp
4019 @item -images
4020 @opindex -images
4021 Show the characters' bitmaps using asterisks and spaces.
4022
4023 @item -mnemonics
4024 @opindex -mnemonics
4025 Translate all commands in the GF file.
4026 @end table
4027
4028 As an example of the output, here is the (abridged) translation of the
4029 letter `K' in @samp{cmr10}, as rendered at 600@dmn{dpi} with the mode
4030 @samp{ljfour} from @file{modes.mf} (@url{https://ctan.org/pkg/modes}),
4031 with both @samp{-mnemonics} and @samp{-images} enabled.
4032
4033 GFtype outputs the information about a character in two places: a main
4034 definition and a one-line summary at the end. We show both. Here is the
4035 main definition:
4036
4037 @example
4038 2033: beginning of char 75: 3<=m<=60 0<=n<=56
4039 (initially n=56) paint (0)24(12)20
4040 2043: newrow 0 (n=55) paint 24(12)20
4041 2047: newrow 0 (n=54) paint 24(12)20
4042 2051: newrow 0 (n=53) paint 24(12)20
4043 2055: newrow 7 (n=52) paint 10(21)13
4044 2059: newrow 8 (n=51) paint 8(23)9
4045 @dots{}
4046 2249: newrow 8 (n=5) paint 8(23)11
4047 2253: newrow 7 (n=4) paint 10(22)12
4048 2257: newrow 0 (n=3) paint 24(11)22
4049 2261: newrow 0 (n=2) paint 24(11)22
4050 2265: newrow 0 (n=1) paint 24(11)22
4051 2269: newrow 0 (n=0) paint 24(11)22
4052 2273: eoc
4053 @group
4054 .<--This pixel's lower left corner is at (3,57) in METAFONT coordinates
4055 ************************ ********************
4056 ************************ ********************
4057 ************************ ********************
4058 ************************ ********************
4059 ********** *************
4060 ******** *********
4061 @dots{}
4062 ******** ***********
4063 ********** ************
4064 ************************ **********************
4065 ************************ **********************
4066 ************************ **********************
4067 ************************ **********************
4068 .<--This pixel's upper left corner is at (3,0) in METAFONT coordinates
4069 @end group
4070 @end example
4071
4072 @noindent
4073 Explanation:
4074
4075 @table @samp
4076 @item 2033
4077 @itemx 2043
4078 @itemx @dots{}
4079 @cindex byte position
4080 The byte position in the file where each GF command starts.
4081
4082 @item beginning of char 75
4083 @cindex character codes, in GFtype output
4084 The character code, in decimal.
4085
4086 @item 3<=m<=60 0<=n<=56
4087 @cindex left side bearing
4088 @cindex right side bearing
4089 @cindex side bearings
4090 The character's bitmap lies between 3 and 60 (inclusive) horizontally,
4091 and between 0 and 56 (inclusive) vertically. (@math{m} is a column
4092 position and @math{n} is a row position.) Thus, 3 is the left side
4093 bearing. The right side bearing is the horizontal escapement (given
4094 below) minus the maximum @math{m}.
4095
4096 @item (initially n=56) paint (0)24(12)20
4097 @cindex run length encoded bitmaps
4098 The first row of pixels: 0 white pixels, 24 black pixels, 12 white
4099 pixels, etc.
4100
4101 @item newrow 0 (n=55) paint 24(12)20
4102 @findex newrow @r{GF command}
4103 The second row of pixels, with zero leading white pixels on the row.
4104
4105 @item eoc
4106 @findex eoc @r{GF command}
4107 The end of the main character definition.
4108
4109 @end table
4110
4111 Here is the GF postamble information that GFtype outputs at the end:
4112
4113 @example
4114 Character 75: dx 4259840 (65), width 815562 (64.57289), loc 2033
4115 @end example
4116
4117 Explanation:
4118
4119 @table @samp
4120 @item dx
4121 @cindex horizontal escapement
4122 @cindex escapement, horizontal
4123 @cindex vertical escapement
4124 @cindex escapement, vertical
4125 @cindex scaled pixels
4126 @cindex dx @r{horizontal escapement}
4127 @cindex dy @r{vertical escapement}
4128 The device-dependent width, in @dfn{scaled pixels}, i.e., units of
4129 horizontal pixels times 2^16. The @samp{(65)} is simply the same number
4130 rounded. If the vertical escapement is nonzero, it would appear here as
4131 a @samp{dy} value.
4132
4133 @item width
4134 @cindex TFM width of characters
4135 @cindex device-independent width
4136 @cindex width, device-independent
4137 The device-independent (TFM) width of this character. It is 2^24
4138 times the ratio of the true width to the font's design size. The
4139 @samp{64.57289} is the same number converted to pixels.
4140
4141 @item loc
4142 The byte position in the file where this character starts.
4143
4144 @end table
4145
4146
4147 @node tftopl invocation
4148 @section TFtoPL: @TeX{} font metric to property list conversion
4149
4150 @pindex tftopl
4151 @cindex conversion, TFM to property list
4152 @cindex validation, of TFM files
4153 @cindex property list, converting TFM to
4154 @cindex human-readable text, converting TFM to
4155 @cindex plain text, converting TFM to
4156
4157 TFtoPL translates a @TeX{} font metric (TFM, @pxref{Metric
4158 files,,,dvips,Dvips}) file (as output by Metafont, for example) to
4159 @dfn{property list format} (a list of parenthesized items describing the
4160 font) that humans can edit or read. This program is mostly used by
4161 people debugging @TeX{} implementations, writing font utilities, etc.
4162 Synopsis:
4163
4164 @example
4165 tftopl [@var{option}]@dots{} @var{tfmname}[.tfm] [@var{plfile}[.pl]]
4166 @end example
4167
4168 The font @var{tfmname} (extended with @samp{.tfm} if necessary) is
4169 searched for in the usual places (@pxref{Supported file formats,,,
4170 kpathsea, Kpathsea}). To see all the relevant paths, set the
4171 environment variable @code{KPATHSEA_DEBUG} to @samp{-1} before running
4172 the program.
4173
4174 If @var{plfile} (which is extended with @samp{.pl} if necessary) is not
4175 specified, the property list file is written to standard output. The
4176 property list file can be converted back to TFM format by the companion
4177 program TFtoPL (see the next section).
4178
4179 The program accepts the following option, as well as the standard
4180 @samp{-verbose}, @samp{-help} and @samp{-version} (@pxref{Common
4181 options}):
4182 @table @samp
4183 @item -charcode-format=@var{type}
4184 @opindex -charcode-format=@var{type}
4185 Output character codes in the PL file according to @var{type}: either
4186 @samp{octal} or @samp{ascii}. Default is @samp{ascii} for letters and
4187 digits, octal for all other characters. Exception: if the font's coding
4188 scheme starts with @samp{TeX math sy} or @samp{TeX math ex}, all
4189 character codes are output in octal.
4190
4191 In @samp{ascii} format, character codes that correspond to graphic
4192 characters, except for left and right parentheses, are output as a
4193 @samp{C} followed by the single character: @samp{C K}, for example. In
4194 octal format, character codes are output as the letter @samp{O} followed
4195 by octal digits, as in @samp{O 113} for @samp{K}.
4196
4197 @samp{octal} format is useful for symbol and other non-alphabetic fonts,
4198 where using ASCII characters for the character codes is merely
4199 confusing.
4200 @end table
4201
4202 @cindex property list format
4203 As an example of the output, here is the (abridged) property list
4204 translation of @file{cmr10.tfm}:
4205
4206 @example
4207 (FAMILY CMR)
4208 (FACE O 352)
4209 (CODINGSCHEME TEX TEXT)
4210 (DESIGNSIZE R 10.0)
4211 (COMMENT DESIGNSIZE IS IN POINTS)
4212 (COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)
4213 (CHECKSUM O 11374260171)
4214 (FONTDIMEN
4215 (SLANT R 0.0)
4216 (SPACE R 0.333334)
4217 (STRETCH R 0.166667)
4218 (SHRINK R 0.111112)
4219 (XHEIGHT R 0.430555)
4220 (QUAD R 1.000003)
4221 (EXTRASPACE R 0.111112)
4222 )
4223 (LIGTABLE
4224 @dots{}
4225 (LABEL C f)
4226 (LIG C i O 14)
4227 (LIG C f O 13)
4228 (LIG C l O 15)
4229 (KRN O 47 R 0.077779)
4230 (KRN O 77 R 0.077779)
4231 (KRN O 41 R 0.077779)
4232 (KRN O 51 R 0.077779)
4233 (KRN O 135 R 0.077779)
4234 (STOP)
4235 @dots{}
4236 )
4237 @dots{}
4238 (CHARACTER C f
4239 (CHARWD R 0.305557)
4240 (CHARHT R 0.694445)
4241 (CHARIC R 0.077779)
4242 (COMMENT
4243 (LIG C i O 14)
4244 (LIG C f O 13)
4245 (LIG C l O 15)
4246 (KRN O 47 R 0.077779)
4247 (KRN O 77 R 0.077779)
4248 @dots{}
4249 )
4250 )
4251 @dots{}
4252 @end example
4253
4254 As you can see, the general format is a list of parenthesized
4255 @dfn{properties}, nested where necessary.
4256
4257 @itemize @bullet
4258 @item
4259 @findex FAMILY @r{property}
4260 @findex FACE @r{property}
4261 @findex headerbyte @r{information}
4262 The first few items (@code{FAMILY}, @code{FACE}, and so on) are
4263 the so-called @dfn{headerbyte} information from Metafont, giving general
4264 information about the font.
4265
4266 @item
4267 @findex FAMILY @r{property}
4268 @findex \fontdimen
4269 The @code{FONTDIMEN} property defines the @TeX{} @code{\fontdimen}
4270 values.
4271
4272 @item
4273 @findex LIGTABLE @r{property}
4274 @findex LABEL @r{property}
4275 @findex LIG @r{property}
4276 @findex KRN @r{property}
4277 @cindex ligature table, in TFM files
4278 @cindex kerning table, in TFM files
4279 @cindex design-size units
4280 The @code{LIGTABLE} property defines the ligature and kerning table.
4281 @code{LIG} properties define ligatures: in the example above, an
4282 @samp{f} (in the @samp{LABEL}) followed by an @samp{i} is a ligature,
4283 i.e., a typesetting program like @TeX{} replaces those two consecutive
4284 characters by the character at position octal '014 in the current
4285 font---presumably the `fi' ligature. @code{KRN} properties define
4286 kerns: if an @samp{f} is followed by character octal '047 (an
4287 apostrophe), @TeX{} inserts a small amount of space between them:
4288 0.077779 times the design size the font was loaded at (about
4289 three-quarters of a printer's point by default in this case, or .001
4290 inches).
4291
4292 @item
4293 @findex CHARACTER @r{property}
4294 @findex CHARWD @r{property}
4295 @findex CHARHT @r{property}
4296 @findex CHARDP @r{property}
4297 @findex CHARIC @r{property}
4298 The @code{CHARACTER} property defines the dimensions of a character: its
4299 width, height, depth, and italic correction, also in design-size units,
4300 as explained in the previous item. For our example `f', the depth is
4301 zero, so that property is omitted. TFtoPL also inserts any kerns and
4302 ligatures for this character as a comment.
4303
4304 @end itemize
4305
4306
4307 @node pltotf invocation
4308 @section PLtoTF: Property list to @TeX{} font metric conversion
4309
4310 @pindex pltotf
4311 @cindex conversion, property list to TFM
4312 @cindex TFM files, converting property lists to
4313 @cindex machine-readable, converting property lists to
4314
4315 PLtoTF translates a property list file (as output by TFtoPL, for
4316 example) to @TeX{} font metric (TFM, @pxref{Metric files,,,dvips,Dvips})
4317 format. It's much easier for both programs and humans to create the
4318 (plain text) property list files and let PLtoTF take care of creating
4319 the binary TFM equivalent than to output TFM files directly. Synopsis:
4320
4321 @example
4322 pltotf [@var{option}]@dots{} @var{plfile}[.pl] [@var{tfmfile}[.tfm]]
4323 @end example
4324
4325 If @var{tfmfile} (extended with @samp{.tfm} if necessary) is
4326 not specified, the TFM file is written to the basename of
4327 @samp{@var{plfile}.tfm}, e.g., @samp{pltotf /wherever/cmr10.pl} creates
4328 @file{./cmr10.tfm}. (Since TFM files are binary, writing to standard
4329 output by default is undesirable.)
4330
4331 The only options are @samp{-verbose}, @samp{-help}, and
4332 @samp{-version} (@pxref{Common options}).
4333
4334 For an example of property list format, see the previous section.
4335
4336
4337 @node vftovp invocation
4338 @section VFtoVP: Virtual font to virtual property lists
4339
4340 @pindex vftovp
4341 @cindex conversion, VF to VPL
4342 @cindex validation, of VF files
4343 @cindex property list, converting VF to virtual
4344 @cindex human-readable text, converting VF to
4345 @cindex plain text, converting VF to
4346
4347 VFtoVP translates a virtual font metric (VF, @pxref{Virtual
4348 fonts,,,dvips,Dvips}) file and its accompanying @TeX{} font metric (TFM,
4349 @pxref{Metric files,,,dvips,Dvips}) file (as output by VPtoVF, for
4350 example) to @dfn{virtual property list format} (a list of parenthesized
4351 items describing the virtual font) that humans can edit or read. This
4352 program is mostly used by people debugging virtual font utilities.
4353 Synopsis:
4354
4355 @example
4356 vftovp [@var{option}]@dots{} @var{vfname}[.vf] [@var{tfmname}[.tfm] @c
4357 [@var{vplfile}[.vpl]]]
4358 @end example
4359
4360 The fonts @var{vfname} and @var{tfmname} (extended with @samp{.vf} and
4361 @samp{.tfm} if necessary) are searched for in the usual places
4362 (@pxref{Supported file formats,,, kpathsea, Kpathsea}). To see all the
4363 relevant paths, set the environment variable @code{KPATHSEA_DEBUG} to
4364 @samp{-1} before running the program. If @var{tfmname} is not
4365 specified, @var{vfname} (without a trailing @samp{.vf}) is used.
4366
4367 If @var{vplfile} (extended with @samp{.vpl} if necessary) is
4368 not specified, the property list file is written to standard output.
4369 The property list file can be converted back to VF and TFM format by the
4370 companion program VFtoVP (see the next section).
4371
4372 The program accepts the following option, as well as the standard
4373 @samp{-verbose}, @samp{-help} and @samp{-version} (@pxref{Common
4374 options}):
4375 @table @samp
4376 @item -charcode-format=@var{type}
4377 @opindex -charcode-format=@var{type}
4378 Output character codes in the PL file according to @var{type}: either
4379 @samp{octal} or @samp{ascii}. Default is @samp{ascii} for letters and
4380 digits, octal for all other characters. Exception: if the font's coding
4381 scheme starts with @samp{TeX math sy} or @samp{TeX math ex}, all
4382 character codes are output in octal.
4383
4384 In @samp{ascii} format, character codes that correspond to graphic
4385 characters, except for left and right parentheses, are output as a
4386 @samp{C} followed by the single character: @samp{C K}, for example. In
4387 octal format, character codes are output as the letter @samp{O} followed
4388 by octal digits, as in @samp{O 113} for @samp{K}.
4389
4390 @samp{octal} format is useful for symbol and other non-alphabetic fonts,
4391 where using ASCII characters for the character codes is merely
4392 confusing.
4393 @end table
4394
4395
4396 @node vptovf invocation
4397 @section VPtoVF: Virtual property lists to virtual font
4398
4399 @pindex vptovf
4400 @cindex conversion, property list to VF
4401 @cindex VF files, converting property lists to
4402 @cindex machine-readable, converting property lists to
4403
4404 VPtoVF translates a virtual property list file (as output by VFtoVP, for
4405 example) to virtual font (VF, @pxref{Virtual fonts,,,dvips,Dvips}) and
4406 @TeX{} font metric (TFM, @pxref{Metric files,,,dvips,Dvips}) files.
4407 It's much easier for both programs and humans to create the (plain text)
4408 property list files and let VPtoVF take care of creating the binary VF
4409 and TFM equivalents than to output them directly. Synopsis:
4410
4411 @example
4412 vptovf [@var{option}]@dots{} @var{vplfile}[.vpl] [@var{vffile}[.vf] @c
4413 [@var{tfmfile}[.tfm]]]
4414 @end example
4415
4416 If @var{vffile} (extended with @samp{.vf} if necessary) is not
4417 specified, the VF output is written to the basename of
4418 @samp{@var{vplfile}.vf}; similarly for @var{tfmfile}. For example,
4419 @samp{vptovf /wherever/ptmr.vpl} creates @file{./ptmr.vf} and
4420 @file{./ptmr.tfm}.
4421
4422 The only options are @samp{-verbose}, @samp{-help}, and @samp{-version}
4423 (@pxref{Common options}).
4424
4425
4426 @node Font utilities available elsewhere
4427 @section Font utilities available elsewhere
4428
4429 @cindex font utilities, non-Web2c
4430
4431 The Web2c complement of font utilities merely implements a few basic
4432 conversions. Many other more sophisticated font utilities exist; most
4433 are in @file{@var{CTAN:}/fonts/utilities} (for CTAN info,
4434 @pxref{unixtex.ftp,,, kpathsea, Kpathsea}). Here are some of the most
4435 commonly-requested items:
4436
4437 @itemize @bullet
4438 @item
4439 @cindex AFM to TFM conversion
4440 @pindex afm2tfm
4441 @pindex afmtopl
4442 AFM (Adobe font metric) to TFM conversion: @pxref{Invoking afm2tfm,,,
4443 dvips, Dvips}, and @file{@var{CTAN:}/fonts/utilities/afmtopl}.
4444
4445 @item
4446 @cindex X bitmap fonts
4447 @cindex BDF and GF conversion
4448 BDF (the X bitmap format) conversion:
4449 @url{ftp://ftp.tug.org/tex/bdf.tar.gz}.
4450
4451 @item
4452 @pindex metatype1
4453 @cindex Latin Modern
4454 Creating fonts using MetaPost: MetaType1:
4455 @url{https://ctan.org/pkg/metatype1}. This was used to create the
4456 Latin Modern font family (@url{https://ctan.org/pkg/lm}), which
4457 extends Computer Modern to a larger repertoire of scripts.
4458
4459 @item
4460 @cindex editing of bitmap fonts
4461 @pindex xbfe@r{, bitmap font editor}
4462 @pindex xfed@r{, bitmap font editor}
4463 @pindex xfedor@r{, bitmap font editor}
4464 @pindex gftopxl
4465 @pindex chtopx
4466 @pindex pxtoch
4467 Editing of bitmap fonts: Xbfe from the GNU font utilities mentioned
4468 below; the X BDF-editing programs @code{xfed} and @code{xfedor};
4469 finally, if your fonts have only 128 characters, you can use the old
4470 @code{gftopxl}, @code{pxtoch}, and @code{chtopx} programs from
4471 @url{ftp://ftp.tug.org/tex/web}.
4472
4473 @item
4474 @pindex fontforge
4475 @pindex pfaedit
4476 Editing of outline fonts: FontForge,
4477 @url{https://fontforge.sourceforge.net}. This is a very elaborate
4478 program with support for many outline formats (Type@tie{}1, OpenType,
4479 TrueType, @dots{}), and many advanced font editing features.
4480
4481 @item
4482 @cindex PK bitmaps from PostScript
4483 @cindex PostScript to PK bitmaps
4484 @pindex gsftopk
4485 @pindex ps2pk
4486 PK bitmaps from PostScript outline fonts: gsftopk from the @samp{xdvi}
4487 distribution. Alternatively, @code{ps2pk}, from
4488 @file{@var{CTAN:}/fonts/utilities/ps2pk}.
4489
4490 @item
4491 @cindex Type 1 conversion
4492 @cindex PFA and PFB conversion
4493 @cindex PostScript Type 1 font conversion
4494 PostScript Type 1 font format conversion (i.e., between PFA and PFB
4495 formats): @url{https://www.lcdf.org/type}.
4496
4497 @item
4498 @pindex autotrace
4499 @pindex potrace
4500 Tracing bitmaps to fitted outlines: Autotrace
4501 (@url{http://autotrace.sourceforge.net}), Potrace
4502 (@url{http://potrace.sourceforge.net}). For Metafont fonts, either of
4503 the two programs @code{mftrace}
4504 (@url{http://www.xs4all.nl/~hanwen/mftrace}) or @code{textrace}
4505 (@url{http://textrace.sourceforge.net}) make the job easier.
4506
4507 @item
4508 @cindex virtual font creation
4509 @pindex fontinst@r{, for creating virtual fonts}
4510 Virtual font creation: @url{https://ctan.org/pkg/fontinst}.
4511 @end itemize
4512
4513
4514 @node Legalisms
4515 @appendix Legalisms
4516
4517 @cindex legalisms
4518 @cindex copyright notices
4519 @cindex permissions, legal
4520
4521 In general, each file has its own copyright notice stating the copying
4522 permissions for that file. Following is a summary.
4523
4524 The Stanford @TeX{} programs and Web2c system itself are in the public
4525 domain (@url{https://tug.org/texlive/copying.html}). The sources may
4526 be copied verbatim, or used as the starting point of new software
4527 under different names; however, per the wishes of the authors, they
4528 should be modified only through a @file{.ch} file, but this is in the
4529 nature of a development request rather than a legal requirement.
4530
4531 ML@TeX{}, pdf@TeX{}, Lua@TeX{}, Xe@TeX{}, and all the other derived
4532 engines have used various license terms for their additions to the
4533 base code, often the GPL (see @url{https://www.gnu.org/licenses/#GPL})
4534 or (for example) the file @file{web2c/pdftexdir/COPYINGv2}. They also
4535 mostly make use of additional libraries with their own (compatible)
4536 terms. Please see each program's sources.
4537
4538 The Kpathsea library is covered by the GNU Lesser General Public
4539 License (@pxref{Introduction,,, kpathsea, Kpathsea}). Therefore, the
4540 @emph{binaries} resulting from a standard Web2c compilation are also
4541 covered by the LGPL; so if you (re)distribute the binaries, you must
4542 also (offer to) distribute the complete source that went into those
4543 binaries. See @url{https://gnu.org/licenses/#LGPL} or the file
4544 @file{kpathsea/COPYING.LESSERv2}.
4545
4546 @node References
4547 @appendix References
4548
4549 @cindex references
4550 @cindex bibliography
4551
4552 @enumerate
4553 @item
4554 Kpathsea: @xref{Top, Introduction,, kpathsea, Kpathsea}.
4555
4556 @item
4557 Dvips and Afm2tfm: @xref{Top, Introduction,, dvips, Dvips}.
4558
4559 @item
4560 The @TeX{} Users Group: @url{https://tug.org}. For an introduction
4561 to the @TeX{} system, see @url{https://tug.org/begin.html}.
4562
4563 @item
4564 TUGboat, the principal journal for the @TeX{} world:
4565 @url{https://tug.org/TUGboat}.
4566
4567 @item
4568 @TeX{} and computer typesetting in general:@*
4569 @url{https://ftp.math.utah.edu/pub/tex/bib/texbook1.bib} and
4570 @file{texbook3.bib}, among others.
4571
4572 @item
4573 For a bibliography of formal articles and technical reports on the
4574 @TeX{} project, see the books @cite{@TeX{}: The Program} or
4575 @cite{Metafont: The Program} cited below.
4576
4577 @include ref.txi
4578
4579 @end enumerate
4580
4581
4582 @node Index
4583 @unnumbered Index
4584
4585 @printindex cp
4586
4587 @bye