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