guess we don't want the build dir
[latex2e.git] / trunk / doc / fntguide.tex
blob57ed8cf0f433db12204787beaa655e78a00c1c6c
1 % \iffalse meta-comment
3 % Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
4 % The LaTeX3 Project and any individual authors listed elsewhere
5 % in this file.
6 %
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9 %
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
18 % This file has the LPPL maintenance status "maintained".
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
28 % \fi
29 % Filename: fntguide.tex
31 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
33 \documentclass{ltxguide}[1995/11/28]
35 \title{\LaTeXe{} font selection}
37 \author{\copyright~Copyright 1995--2005, \LaTeX3 Project Team.\\
38 All rights reserved.}
40 \date{27 November 2005}
42 \begin{document}
44 \maketitle
46 \tableofcontents
48 \section{Introduction}
50 This document describes the new font selection features of the \LaTeX{}
51 Document Preparation System. It is intended for package writers who
52 want to write font-loading packages similar to |times| or |latexsym|.
54 This document is only a brief introduction to the new facilities and
55 is intended for package writers who are familiar with \TeX{} fonts and
56 \LaTeX{} packages. It is \emph{neither} a user-guide \emph{nor} a
57 reference manual for fonts in \LaTeXe.
59 \subsection{\LaTeXe~fonts}
61 The most important difference between \LaTeX~2.09 and \LaTeXe{} is the
62 way that fonts are selected. In \LaTeX~2.09, the Computer Modern fonts
63 were built into the \LaTeX~format, and so customizing \LaTeX{} to use
64 other fonts was a major effort.
66 In \LaTeXe, very few fonts are built into the format, and there are
67 commands to load new text and math fonts. Packages such as |times| or
68 |latexsym| allow authors to access these fonts.
69 This document describes how to write similar font-loading packages.
71 The \LaTeXe{} font selection system was first released as the `New Font
72 Selection Scheme' (NFSS) in 1989, and then in release~2 in 1993.
73 \LaTeXe{} includes NFSS release~2 as standard.
75 \subsection{Overview}
77 This document contains an overview of the new font commands
78 of \LaTeX.
80 \begin{description}
82 \item[Section~\ref{Sec:text}] describes the commands for selecting fonts
83 in classes and packages. It lists the five \LaTeX{} font
84 attributes, and lists the commands for selecting fonts. It also
85 describes how to customize the author commands such as |\textrm| and
86 |\textit| to suit your document design.
88 \item[Section~\ref{Sec:math}] explains the commands for controlling
89 \LaTeX{} math fonts. It describes how to specify new math fonts and
90 new math symbols.
92 \item[Section~\ref{Sec:install}] explains how to install new fonts into
93 \LaTeX. It shows how \LaTeX{} font attributes are turned into \TeX{}
94 font names, and how to specify your own fonts using font definition
95 files.
97 \item[Section~\ref{Sec:encode}] discusses text font encodings.
98 It describes how to declare a new encoding and how to define
99 commands, such as |\AE| or |\"|, which have different definitions in
100 different encodings, depending on whether ligatures, etc.\ are
101 available in the encoding.
103 \item[Section~\ref{Sec:misc}] covers font miscellanea. It describes how
104 \LaTeX{} performs font substitution, how to customize fonts that are
105 preloaded in the \LaTeX{} format, and the naming conventions used in
106 \LaTeX{} font selection.
108 \end{description}
110 \subsection{Further information}
112 For a general introduction to \LaTeX, including the new features of
113 \LaTeXe, you should read \emph{\LaTeXbook},
114 Leslie Lamport, Addison Wesley, 2nd~ed, 1994.
116 A more detailed description of the \LaTeX{} font selection scheme is to
117 be found in \emph{\LaTeXcomp}, 2nd~ed, by Mittelbach and Goossens, Addison
118 Wesley, 2004.
120 The \LaTeX{} font selection scheme is based on \TeX, which is described
121 by its developer in \emph{The \TeX book}, Donald E.~Knuth, Addison
122 Wesley, 1986, revised in 1991 to include the features of \TeX~3.
124 Sebastian Rahtz's |psnfss| software contains the software for using a
125 large number of Type~1 fonts (including the Adobe Laser Writer 35 and
126 the Monotype CD-ROM fonts) in \LaTeX. It should be available from the
127 same source as your copy of \LaTeX.
129 The |psnfss| software uses fonts generated by Alan Jeffrey's
130 |fontinst| software. This can convert fonts from Adobe Font Metric
131 format into a format readable by \LaTeX, including the generation of
132 the font definition files described in Section~\ref{Sec:install}. The
133 |fontinst| software should be available from the same source as your
134 copy of \LaTeX.
136 Whenever practical, \LaTeX{} uses the font naming scheme called
137 `fontname'; this was described in \emph{Filenames for fonts},%
138 \footnote{An up-to-date electronic version
139 of this document can be found on any CTAN server, in the directory
140 \texttt{info/fontname}.}
141 \emph{TUGboat}~11(4),~1990.
143 The class-writer's guide \emph{\clsguide} describes
144 the new \LaTeX{} features for writers of document classes and packages
145 and is kept in |clsguide.tex|. Configuring
146 \LaTeX{} is covered by the guide \emph{\cfgguide} in
147 \texttt{cfgguide.tex} whilst the philosophy behind our policy on
148 modifying \LaTeX{} is described in \emph{\modguide} in
149 \texttt{modguide.tex}.
151 The documented source code (from the files used to produce
152 the kernel format via |latex.ltx|) is now available as
153 \emph{The \LaTeXe\ Sources}.
154 This very large document also includes an index of \LaTeX{}
155 commands. It can be typeset from the \LaTeX{} file |source2e.tex|
156 in the |base| directory; this uses the class file |ltxdoc.cls|.
158 For more information about \TeX{} and \LaTeX{}, please contact your
159 local \TeX{} Users Group, or the international \TeX{} Users Group.
160 Addresses and other details can be found at:
161 \begin{quote}\small\label{addrs}
162 \texttt{http://www.tug.org/lugs.html}
163 \end{quote}
166 \section{Text fonts}
167 \label{Sec:text}
169 This section describes the commands available to class and package
170 writers for specifying and selecting fonts.
172 \subsection{Text font attributes}
174 Every text font in \LaTeX{} has five \emph{attributes}:
175 \begin{description}
177 \item[encoding] This specifies the order that characters appear in the
178 font. The two most common text encodings used in \LaTeX{} are
179 Knuth's `\TeX{} text' encoding, and the `\TeX{} text extended'
180 encoding developed by the \TeX{} Users Group members during a \TeX{}
181 Conference at Cork in~1990 (hence its informal name `Cork encoding').
183 \item[family] The name for a collection of fonts, usually grouped under
184 a common name by the font foundry. For example, `Adobe Times', `ITC
185 Garamond', and Knuth's `Computer Modern Roman' are all font families.
187 \item[series] How heavy or expanded a font is. For example, `medium
188 weight', `narrow' and `bold extended' are all series.
190 \item[shape] The form of the letters within a font family. For
191 example, `italic', `oblique' and `upright' (sometimes called
192 `roman') are all font shapes.
194 \item[size] The design size of the font, for example `10pt'. If no
195 dimension is specified, `pt' is assumed.
197 \end{description}
198 The possible values for these attributes are given short acronyms by
199 \LaTeX. The most common values for the font encoding are:
200 \begin{center}
201 \begin{minipage}{.7\linewidth}
202 \begin{tabular}{rl}
203 |OT1| & \TeX{} text \\
204 |T1| & \TeX{} extended text \\
205 |OML| & \TeX{} math italic \\
206 |OMS| & \TeX{} math symbols \\
207 |OMX| & \TeX{} math large symbols \\
208 |U| & Unknown \\
209 |L<xx>| & A local encoding
210 \end{tabular}
211 \end{minipage}
212 \end{center}
213 The `local' encodings are intended for font encodings which are only
214 locally available, for example a font containing an organisation's
215 logo in various sizes.
217 There are far too many font families to list them all, but some common
218 ones are:
219 \begin{center}
220 \begin{minipage}{.7\linewidth}
221 \begin{tabular}{rl}
222 |cmr| & Computer Modern Roman \\
223 |cmss| & Computer Modern Sans \\
224 |cmtt| & Computer Modern Typewriter \\
225 |cmm| & Computer Modern Math Italic \\
226 |cmsy| & Computer Modern Math Symbols \\
227 |cmex| & Computer Modern Math Extensions \\
228 |ptm| & Adobe Times \\
229 |phv| & Adobe Helvetica \\
230 |pcr| & Adobe Courier
231 \end{tabular}
232 \end{minipage}
233 \end{center}
234 The most common values for the font series are:
235 \begin{center}
236 \begin{minipage}{.7\linewidth}
237 \begin{tabular}{rl}
238 |m| & Medium \\
239 |b| & Bold \\
240 |bx| & Bold extended \\
241 |sb| & Semi-bold \\
242 |c| & Condensed
243 \end{tabular}
244 \end{minipage}
245 \end{center}
246 The most common values for the font shape are:
247 \begin{center}
248 \begin{minipage}{.7\linewidth}
249 \begin{tabular}{rl}
250 |n| & Normal (that is `upright' or `roman') \\
251 |it| & Italic \\
252 |sl| & Slanted (or `oblique') \\
253 |sc| & Caps and small caps
254 \end{tabular}
255 \end{minipage}
256 \end{center}
257 The font size is specified as a dimension, for example |10pt| or
258 |1.5in| or |3mm|; if no unit is specified, |pt| is assumed. These five
259 parameters specify every \LaTeX{} font, for example:
260 \begin{center}
261 \begin{tabular}{@{}r@{\,}l@{\,}c@{\,}c@{\,}cc@{}r@{}}
262 \multicolumn{5}{@{}c}{\emph{\LaTeX{} specification}} &
263 \emph{Font} &
264 \emph{\TeX{} font name} \\
265 |OT1| & |cmr| & |m| & |n| & |10| &
266 Computer Modern Roman 10 point &
267 |cmr10| \\
268 |OT1| & |cmss| & |m| & |sl| & |1pc| &
269 Computer Modern Sans Oblique 1 pica &
270 |cmssi12| \\
271 |OML| & |cmm| & |m| & |it| & |10pt| &
272 Computer Modern Math Italic 10 point &
273 |cmmi10| \\
274 |T1| & |ptm| & |b| & |it| & |1in| &
275 Adobe Times Bold Italic 1 inch &
276 |ptmb8t at 1in|
277 \end{tabular}
278 \end{center}
279 These five parameters are displayed whenever \LaTeX{} gives an overfull
280 box warning, for example:
281 \begin{verbatim}
282 Overfull \hbox (3.80855pt too wide) in paragraph at lines 314--318
283 []\OT1/cmr/m/n/10 Normally [] and [] will be iden-ti-cal,
284 \end{verbatim}
285 The author commands for fonts set the five attributes:
286 \begin{center}
287 \begin{tabular}{rcl}
288 \emph{Author command} &
289 \emph{Attribute} &
290 \emph{Value in} |article| \emph{class} \\
291 |\textrm{..}| or |\rmfamily| & family & |cmr| \\
292 |\textsf{..}| or |\sffamily| & family & |cmss| \\
293 |\texttt{..}| or |\ttfamily| & family & |cmtt| \\
294 |\textmd{..}| or |\mdseries| & series & |m| \\
295 |\textbf{..}| or |\bfseries| & series & |bx| \\
296 |\textup{..}| or |\upshape| & shape & |n| \\
297 |\textit{..}| or |\itshape| & shape & |it| \\
298 |\textsl{..}| or |\slshape| & shape & |sl| \\
299 |\textsc{..}| or |\scshape| & shape & |sc| \\
300 |\tiny| & size & |5pt| \\
301 |\scriptsize| & size & |7pt| \\
302 |\footnotesize| & size & |8pt| \\
303 |\small| & size & |9pt| \\
304 |\normalsize| & size & |10pt| \\
305 |\large| & size & |12pt| \\
306 |\Large| & size & |14.4pt| \\
307 |\LARGE| & size & |17.28pt| \\
308 |\huge| & size & |20.74pt| \\
309 |\Huge| & size & |24.88pt|
310 \end{tabular}
311 \end{center}
312 The values used by these commands are determined by the document class,
313 using the parameters defined in Section~\ref{Sec:text.param}.
315 Note that there are no author commands for selecting new encodings.
316 These should be provided by packages, such as the |fontenc| package.
318 This section does not explain how \LaTeX{} font specifications are
319 turned into \TeX{} font names. This is described in
320 Section~\ref{Sec:install}.
322 \subsection{Selection commands}
324 The low-level commands used to select a text font are as follows.
326 \begin{decl}
327 |\fontencoding| \arg{encoding} \\
328 |\fontfamily| \arg{family}\\
329 |\fontseries| \arg{series}\\
330 |\fontshape| \arg{shape}\\
331 |\fontsize| \arg{size} \arg{baselineskip}\\
332 |\linespread| \arg{factor}
333 \end{decl}
335 \NEWdescription{1998/12/01}
336 Each of the commands starting with |\font...| sets one of the font
337 attributes; |\fontsize| also sets |\baselineskip|. The |\linespread|
338 command prepares to multiply the current (or newly defined)
339 |\baselineskip| with \m{factor} (e.g., spreads the lines apart for
340 values greater one).
342 The actual font in use is not altered by these commands, but the
343 current attributes are used to determine which font and baseline skip
344 to use after the next |\selectfont| command.
347 \begin{decl}
348 |\selectfont|
349 \end{decl}
350 Selects a text font, based on the current values of the font attributes.
352 \emph{Warning}: There \emph{must} be a |\selectfont| command
353 immediately after any settings of the font parameters by (some of)
354 the six commands above, before any following text.
355 For example, it is legal to say:
356 \begin{verbatim}
357 \fontfamily{ptm}\fontseries{b}\selectfont Some text.
358 \end{verbatim}
359 but it is \emph{not} legal to say:
360 \begin{verbatim}
361 \fontfamily{ptm} Some \fontseries{b}\selectfont text.
362 \end{verbatim}
363 You may get unexpected results if you put text between a
364 |\font<parameter>| command (or |\linespread|) and a |\selectfont|.
366 \begin{decl}
367 |\usefont| \arg{encoding} \arg{family} \arg{series} \arg{shape}
368 \end{decl}
369 A short hand for the equivalent |\font...| commands followed by a
370 call to |\selectfont|.
373 \subsection{Internals}
375 The current values of the font attributes are held in internal macros.
377 \begin{decl}
378 |\f@encoding| \\
379 |\f@family| \\
380 |\f@series| \\
381 |\f@shape| \\
382 |\f@size| \\
383 |\f@baselineskip| \\
384 |\tf@size| \\
385 |\sf@size| \\
386 |\ssf@size|
387 \end{decl}
389 These hold the current values of the encoding, the family, the series,
390 the shape, the size, the baseline skip, the main math size, the
391 `script' math size and the `scriptscript' math size. The last three
392 are accessible only within a formula; outside of math they may contain
393 arbitrary values.
395 For example, to set the size to 12 without
396 changing the baseline skip:
397 \begin{verbatim}
398 \fontsize{12}{\f@baselineskip}
399 \end{verbatim}
400 However, you should \emph{never} alter the values of the internal
401 commands directly; they must only be modified using the low-level
402 commands like |\fontfamily|, |\fontseries|, etc. If you disobey this
403 warning you might produce code that loops.
405 \subsection{Parameters for author commands}
406 \label{Sec:text.param}
408 The parameter values set by author commands such as |\textrm| and
409 |\rmfamily|, etc.\ are not hard-wired into \LaTeX; instead these
410 commands use the values of a number of parameters set by the document
411 class and packages. For example, |\rmdefault| is the name of the
412 default family selected by |\textrm| and |\rmfamily|. Thus to set a
413 document in Adobe Times, Helvetica and Courier, the document designer
414 specifies:
415 \begin{verbatim}
416 \renewcommand{\rmdefault}{ptm}
417 \renewcommand{\sfdefault}{phv}
418 \renewcommand{\ttdefault}{pcr}
419 \end{verbatim}
421 \begin{decl}
422 |\encodingdefault| \\
423 |\familydefault| \\
424 |\seriesdefault| \\
425 |\shapedefault|
426 \end{decl}
427 The encoding, family, series and shape of the main body font. By
428 default these are |OT1|, |\rmdefault|, |m| and |n|. Note that since
429 the default family is |\rmdefault|, this means that changing
430 |\rmdefault| will change the main body font of the document.
432 \begin{decl}
433 |\rmdefault| \\
434 |\sfdefault| \\
435 |\ttdefault|
436 \end{decl}
437 The families selected by |\textrm|, |\rmfamily|, |\textsf|,
438 |\sffamily|, |\texttt| and |\ttfamily|. By default these are |cmr|,
439 |cmss| and |cmtt|.
441 \begin{decl}
442 |\bfdefault| \\
443 |\mddefault|
444 \end{decl}
445 The series selected by |\textbf|, |\bfseries|, |\textmd| and
446 |\mdseries|. By default these are |bx| and |m|.
447 These values are suitable for the default families used. If other
448 fonts are used as standard document fonts (for example, certain
449 PostScript fonts) it might be necessary to adjust the value of
450 |\bfdefault| to |b| since only a few such families have a `bold
451 extended' series. An alternative (taken for the fonts provided by
452 |psnfss|) is to define silent substitutions from |bx| series to |b|
453 series with special |\DeclareFontShape| declarations and the |ssub|
454 size function, see Section~\ref{sec:sizefunct}.
457 \begin{decl}
458 |\itdefault| \\
459 |\sldefault| \\
460 |\scdefault| \\
461 |\updefault|
462 \end{decl}
463 The shapes selected by |\textit|, |\itshape|, |\textsl|, |\slshape|,
464 |\textsc|, |\scshape|, |\textup| and |\upshape|. By default these are
465 |it|, |sl|, |sc| and |n|.
467 Note that there are no parameters for the size commands. These should
468 be defined directly in class files, for example:
469 \begin{verbatim}
470 \renewcommand{\normalsize}{\fontsize{10}{12}\selectfont}
471 \end{verbatim}
472 More elaborate examples (setting additional parameters when the text
473 size is changed) can be found in |classes.dtx| the source
474 documentation for the classes |article|, |report|, and |book|.
477 \subsection{Special font declaration commands}
479 \begin{decl}
480 |\DeclareFixedFont| \arg{cmd} \arg{encoding} \arg{family} \arg{series}
481 \arg{shape} \arg{size}
482 \end{decl}
484 Declares command \m{cmd} to be a font switch which selects the font
485 that is specified by the attributes \m{encoding}, \m{family},
486 \m{series}, \m{shape}, and \m{size}.
488 The font is selected without any adjustments to baselineskip and other
489 surrounding conditions.
491 This example makes |{\picturechar .}| select a small dot very quickly:
492 \begin{verbatim}
493 \DeclareFixedFont{\picturechar}{OT1}{cmr}{m}{n}{5}
494 \end{verbatim}
497 \begin{decl}
498 |\DeclareTextFontCommand| \arg{cmd} \arg{font-switches}
499 \end{decl}
501 Declares command \m{cmd} to be a font command with one argument.
502 The current font attributes are locally modified by \m{font-switches}
503 and then the argument of \m{cmd} is typeset in the resulting new font.
505 Commands defined by |\DeclareTextFontCommand| automatically take care
506 of any necessary italic correction (on either side).
508 The following example shows how |\textrm| is defined by the kernel.
509 \begin{verbatim}
510 \DeclareTextFontCommand{\textrm}{\rmfamily}
511 \end{verbatim}
513 To define a command that always typeset its argument in the italic
514 shape of the main document font you could declare:
515 \begin{verbatim}
516 \DeclareTextFontCommand{\normalit}{\normalfont\itshape}
517 \end{verbatim}
519 This declaration can be used to change the meaning of a command; if
520 \m{cmd} is already defined, a log that it has been redefined
521 is put in the transcript file.
523 \begin{decl}
524 |\DeclareOldFontCommand| \arg{cmd} \arg{text-switch}
525 \arg{math-switch}
526 \end{decl}
528 Declares command \m{cmd} to be a font switch (i.e.~used with the
529 syntax |{<cmd>...}|) having the definition \m{text-switch}
530 when used in text and the definition \m{math-switch} when used in a
531 formula.
532 Math alphabet commands, like |\mathit|, when used within \m{math-switch}
533 should not have an argument. Their use in this argument causes their
534 semantics to change so that they here act as a font switch, as
535 required by the usage of the \m{cmd}.
537 This declaration is useful for setting up commands like |\rm| to behave
538 as they did in \LaTeX~2.09. We strongly urge you \emph{not} to misuse
539 this declaration to invent new font commands.
541 The following example defines |\it| to produce the italic shape of the
542 main document font if used in text and to switch to the font that would
543 normally be produced by the math alphabet |\mathit| if used in a
544 formula.
545 \begin{verbatim}
546 \DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
547 \end{verbatim}
549 This declaration can be used to change the meaning of a command; if
550 \m{cmd} is already defined, a log that it has been redefined
551 is put in the transcript file.
554 \section{Math fonts}
555 \label{Sec:math}
557 This section describes the commands available to class and package
558 writers for specifying math fonts and math commands.
560 \subsection{Math font attributes}
562 The selection of fonts within math mode is quite different to that of
563 text fonts.
565 Some math fonts are selected explicitly by one-argument commands such
566 as |\mathsf{max}| or |\mathbf{vec}|; such fonts are called \emph{math
567 alphabets}. These math alphabet commands affect only the font used
568 for letters and symbols of type |\mathalpha| (see
569 Section~\ref{Sec:math.commands}); other symbols within the argument
570 will be left unchanged. The predefined math alphabets are:
571 \begin{center}
572 \begin{tabular}{ccc}
573 \emph{Alphabet} & \emph{Description} & \emph{Example} \\
574 |\mathnormal| & default & $abcXYZ$ \\
575 |\mathrm| & roman & $\mathrm{abcXYZ}$ \\
576 |\mathbf| & bold roman & $\mathbf{abcXYZ}$ \\
577 |\mathsf| & sans serif & $\mathsf{abcXYZ}$ \\
578 |\mathit| & text italic & $\mathit{abcXYZ}$ \\
579 |\mathtt| & typewriter & $\mathtt{abcXYZ}$ \\
580 |\mathcal| & calligraphic & $\mathcal{XYZ}$
581 \end{tabular}
582 \end{center}
583 Other math fonts are selected implicitly by \TeX{} for symbols, with
584 commands such as |\oplus| (producing $\oplus$) or with straight
585 characters like |>>| or |+|. Fonts containing such math symbols are
586 called \emph{math symbol fonts}. The predefined math symbol fonts
587 are:
588 \begin{center}
589 \begin{tabular}{ccc}
590 \emph{Symbol font} & \emph{Description} & \emph{Example} \\
591 |operators| & symbols from |\mathrm| & $[\;+\;]$ \\
592 |letters| & symbols from |\mathnormal| & $<<\star>>$ \\
593 |symbols| & most \LaTeX{} symbols & $\leq*\geq$ \\
594 |largesymbols| & large symbols & $\sum\prod\int$
595 \end{tabular}
596 \end{center}
597 Some math fonts are both \emph{math alphabets} and \emph{math symbol
598 fonts}, for example |\mathrm| and |operators| are the same font, and
599 |\mathnormal| and |letters| are the same font.
601 Math fonts in \LaTeX{} have the same five attributes as text fonts:
602 encoding, family, series, shape and size. However, there are no
603 commands that allow the attributes to be individually changed.
604 Instead, the conversion from math fonts to these five attributes is
605 controlled by the \emph{math version}. For example, the |normal| math
606 version maps:
607 \begin{center}
608 \begin{tabular}{rlc@{ }c@{ }c@{ }c}
609 \multicolumn{2}{c}{\emph{Math font}} &
610 \multicolumn{4}{c}{\emph{External font}} \\
611 \emph{Alphabets} & \emph{Symbol fonts} &
612 \multicolumn{4}{c}{\emph{Attributes}} \\
613 |\mathnormal| & |letters| & |OML| & |cmm| & |m| & |it| \\
614 |\mathrm| & |operators| & |OT1| & |cmr| & |m| & |n| \\
615 |\mathcal| & |symbols| & |OMS| & |cmsy| & |m| & |n| \\
616 & |largesymbols| & |OMX| & |cmex| & |m| & |n| \\
617 |\mathbf| & & |OT1| & |cmr| & |bx| & |n| \\
618 |\mathsf| & & |OT1| & |cmss| & |m| & |n| \\
619 |\mathit| & & |OT1| & |cmr| & |m| & |it| \\
620 |\mathtt| & & |OT1| & |cmtt| & |m| & |n|
621 \end{tabular}
622 \end{center}
623 The |bold| math version is similar except that it contains bold fonts.
624 The command |\boldmath| selects the |bold| math version.
626 Math versions can only be changed outside of math mode.
628 The two predefined math versions are:
629 \begin{center}
630 \begin{tabular}{rl}
631 |normal| & the default math version \\
632 |bold| & the bold math version
633 \end{tabular}
634 \end{center}
635 Packages may define new math alphabets, math symbol fonts, and math
636 versions. This section describes the commands for writing such
637 packages.
639 \subsection{Selection commands}
641 There are no commands for selecting symbol fonts. Instead, these are
642 selected indirectly through symbol commands like |\oplus|.
643 Section~\ref{Sec:math.commands} explains how to define symbol commands.
645 \begin{decl}
646 |\mathnormal{<math>}|\\
647 |\mathcal{<math>}|\\
648 |\mathrm{<math>}|\\
649 |\mathbf{<math>}|\\
650 |\mathsf{<math>}|\\
651 |\mathit{<math>}|\\
652 |\mathtt{<math>}|
653 \end{decl}
654 Each math alphabet is a command which can only be used inside math
655 mode. For example, |$x + \mathsf{y} + \mathcal{Z}$| produces $x +
656 \mathsf{y} + \mathcal{Z}$.
658 \begin{decl}
659 |\mathversion{<version>}|
660 \end{decl}
661 This command selects a math version; it can only be used outside math
662 mode. For example, |\boldmath| is defined to be |\mathversion{bold}|.
664 \subsection{Declaring math versions}
666 \begin{decl}
667 |\DeclareMathVersion| \arg{version}
668 \end{decl}
670 Defines \m{version} to be a math version.
672 The newly declared version is initialised with the defaults for all
673 symbol fonts and math alphabets declared so far (see the commands
674 |\DeclareSymbolFont| and |\DeclareMathAlphabet|).
676 If used on an already existing version, an information message is
677 written to the transcript file and all previous |\SetSymbolFont| or
678 |\SetMathAlphabet| declarations for this version are overwritten by
679 the math alphabet and symbol font defaults, i.e.~one ends up with a
680 virgin math version.
682 Example:
683 \begin{verbatim}
684 \DeclareMathVersion{normal}
685 \end{verbatim}
688 \subsection{Declaring math alphabets}
690 \begin{decl}
691 |\DeclareMathAlphabet| \arg{math-alph} \arg{encoding} \arg{family}
692 \arg{series} \arg{shape}
693 \end{decl}
695 \NEWdescription{1997/12/01}
696 If this is the first declaration for \m{math-alph} then a new math
697 alphabet with this as its command name is created.
699 The arguments \m{encoding} \m{family} \m{series} \m{shape} are used to
700 set, or reset, the default values for this math alphabet in all math
701 versions; if required, these must be further reset later for a
702 particular math version by a |\SetMathAlphabet| command.
704 If \m{shape} is empty then this \m{math-alph} is declared to be invalid
705 in all versions, unless it is set by a later |\SetMathAlphabet|
706 command for a particular math version.
708 Checks that the command \m{math-alph} is either already a math
709 alphabet command or is undefined; and that \m{encoding} is a known
710 encoding scheme, i.e., has been previously declared.
713 In these examples, |\foo| is defined for all math versions but |\baz|,
714 by default, is defined nowhere.
715 \begin{verbatim}
716 \DeclareMathAlphabet{\foo}{OT1}{cmtt}{m}{n}
717 \DeclareMathAlphabet{\baz}{OT1}{}{}{}
718 \end{verbatim}
721 \begin{decl}
722 |\SetMathAlphabet| \arg{math-alph} \arg{version}\\
723 \null\hfill\arg{encoding} \arg{family} \arg{series} \arg{shape}
724 \end{decl}
726 Changes, or sets, the font for the math alphabet \m{math-alph} in math
727 version \m{version} to \m{encoding}\m{family}\m{series}\m{shape}.
729 Checks that \m{math-alph} has been declared as a math alphabet,
730 \m{version} is a known math version and \m{encoding} is a known
731 encoding scheme.
734 This example defines |\baz| for the `normal' math version only:
735 \begin{verbatim}
736 \SetMathAlphabet{\baz}{normal}{OT1}{cmss}{m}{n}
737 \end{verbatim}
739 Note that this declaration is not used for all math alphabets:
740 Section~\ref{sec:symalph} describes |\DeclareSymbolFontAlphabet|,
741 which is used to set up math alphabets contained in fonts which have
742 been declared as symbol fonts.
745 \subsection{Declaring symbol fonts}
746 \label{sec:symalph}
748 \begin{decl}
749 |\DeclareSymbolFont| \arg{sym-font} \arg{encoding} \arg{family}
750 \arg{series} \arg{shape}
751 \end{decl}
753 \NEWdescription{1997/12/01}
754 If this is the first declaration for \m{sym-font} then a new
755 symbol font with this name is created (i.e.~this identifier is assigned
756 to a new \TeX{} math group).
758 The arguments \m{encoding} \m{family} \m{series} \m{shape} are used to
759 set, or reset. the default values for this symbol font in \emph{all}
760 math versions; if required, these must be further reset later for
761 a particular math version by a |\SetSymbolFont| command.
763 Checks that \m{encoding} is a declared encoding scheme.
766 For example, the following sets up the first four standard math symbol
767 fonts:
768 \begin{verbatim}
769 \DeclareSymbolFont{operators}{OT1}{cmr}{m}{n}
770 \DeclareSymbolFont{letters}{OML}{cmm}{m}{it}
771 \DeclareSymbolFont{symbols}{OMS}{cmsy}{m}{n}
772 \DeclareSymbolFont{largesymbols}{OMX}{cmex}{m}{n}
773 \end{verbatim}
776 \begin{decl}
777 |\SetSymbolFont| \arg{sym-font} \arg{version}\\
778 \null\hfill \arg{encoding} \arg{family} \arg{series} \arg{shape}
779 \end{decl}
781 Changes the symbol font \m{sym-font} for math version \m{version}
782 to \m{encoding} \m{family} \m{series} \m{shape}.
784 Checks that \m{sym-font} has been declared as a symbol font,
785 \m{version} is a known math version and \m{encoding} is a
786 declared encoding scheme.
789 For example, the following come from the set up of the `bold'
790 math version:
791 \begin{verbatim}
792 \SetSymbolFont{operators}{bold}{OT1}{cmr}{bx}{n}
793 \SetSymbolFont{letters}{bold}{OML}{cmm}{b}{it}
794 \end{verbatim}
797 \begin{decl}
798 |\DeclareSymbolFontAlphabet| \arg{math-alph} \arg{sym-font}
799 \end{decl}
801 \NEWdescription{1997/12/01}
802 Allows the previously declared symbol font \m{sym-font} to be the
803 math alphabet with command \m{math-alph} in \emph{all} math versions.
805 Checks that the command \m{math-alph} is either already a math alphabet
806 command or is undefined; and that \m{sym-font} is a symbol font.
809 Example:
810 \begin{verbatim}
811 \DeclareSymbolFontAlphabet{\mathrm}{operators}
812 \DeclareSymbolFontAlphabet{\mathcal}{symbols}
813 \end{verbatim}
815 This declaration should be used in preference to
816 |\DeclareMathAlphabet| and |\SetMathAlphabet| when a math alphabet is
817 the same as a symbol font; this is because it makes better use of the
818 limited number (only 16) of \TeX's math groups.
820 \NEWdescription{1997/12/01}
821 Note that, whereas a \TeX{} math group is allocated to each symbol font
822 when it is first declared, a math alphabet uses a \TeX{} math group
823 only when its command is used within a math formula.
826 \subsection{Declaring math symbols}
827 \label{Sec:math.commands}
829 \begin{decl}
830 |\DeclareMathSymbol| \arg{symbol} \arg{type} \arg{sym-font}
831 \arg{slot}
832 \end{decl}
834 The \m{symbol} can be either a single character such as `|>>|', or a
835 macro name, such as |\sum|.
837 Defines the \m{symbol} to be a math symbol of type
838 \m{type} in slot \m{slot} of symbol font \m{sym-font}. The
839 \m{type} can be given as a number or as a command:
840 \begin{center}
841 \begin{tabular}{ccc}
842 \emph{Type} & \emph{Meaning} & \emph{Example} \\
843 |0| or |\mathord | & Ordinary & $\alpha$ \\
844 |1| or |\mathop | & Large operator & $\sum$ \\
845 |2| or |\mathbin | & Binary operation & $\times$ \\
846 |3| or |\mathrel | & Relation & $\leq$ \\
847 |4| or |\mathopen | & Opening & $\langle$ \\
848 |5| or |\mathclose| & Closing & $\rangle$ \\
849 |6| or |\mathpunct| & Punctuation & $;$ \\
850 |7| or |\mathalpha| & Alphabet character & $A$
851 \end{tabular}
852 \end{center}
853 Only symbols of type |\mathalpha| will be affected by math alphabet
854 commands: within the argument of a math alphabet command they will
855 produce the character in slot \m{slot} of that math alphabet's font.
856 Symbols of other types will always produce the same symbol
857 (within one math version).
859 |\DeclareMathSymbol| allows a macro \m{symbol} to be redefined only if
860 it was previously defined to be a math symbol. It also checks that
861 the \m{sym-font} is a declared symbol font.
863 Example:
864 \begin{verbatim}
865 \DeclareMathSymbol{\alpha}{0}{letters}{"0B}
866 \DeclareMathSymbol{\lessdot}{\mathbin}{AMSb}{"0C}
867 \DeclareMathSymbol{\alphld}{\mathalpha}{AMSb}{"0C}
868 \end{verbatim}
870 \begin{decl}
871 |\DeclareMathDelimiter| \arg{cmd} \arg{type}
872 \arg{sym-font-1} \arg{slot-1}\\
873 \null\hfill \arg{sym-font-2} \arg{slot-2}
874 \end{decl}
875 Defines \m{cmd} to be a math delimiter where the small variant is in
876 slot \m{slot-1} of symbol font \m{sym-font-1} and the large
877 variant is in slot \m{slot-2} of symbol font \m{sym-font-2}.
878 Both symbol fonts must have been declared previously.
880 Checks that \m{sym-font-i} are both declared symbol fonts.
882 If \TeX{} is not looking for a delimiter, \m{cmd} is treated just as
883 if it had been defined with |\DeclareMathSymbol| using
884 \m{type}, \m{sym-font-1} and \m{slot-1}. In other words, if a
885 command is defined as a delimiter then this automatically defines it
886 as a math symbol.
888 \NEWdescription{1998/06/01}
889 In case \m{cmd} is a single character such as `|[|', the same syntax is
890 used. Previously the \arg{type} argument was not present (and thus the
891 corresponding math symbol declaration had to be provided seperately).
893 Example:
894 \begin{verbatim}
895 \DeclareMathDelimiter{\langle}{\mathopen}{symbols}{"68}
896 {largesymbols}{"0A}
897 \DeclareMathDelimiter{(} {\mathopen}{operators}{"28}
898 {largesymbols}{"00}
899 \end{verbatim}
902 \begin{decl}
903 |\DeclareMathAccent| \arg{cmd} \arg{type} \arg{sym-font} \arg{slot}
904 \end{decl}
906 Defines \m{cmd} to act as a math accent.
908 The accent character comes from slot \m{slot} in
909 \m{sym-font}. The \m{type} can be either
910 |\mathord| or |\mathalpha|; in the latter case the accent character
911 changes font when used in a math alphabet.
913 Example:
914 \begin{verbatim}
915 \DeclareMathAccent{\acute}{\mathalpha}{operators}{"13}
916 \DeclareMathAccent{\vec}{\mathord}{letters}{"7E}
917 \end{verbatim}
920 \begin{decl}
921 |\DeclareMathRadical| \arg{cmd}
922 \arg{sym-font-1} \arg{slot-1}\\
923 \null\hfill \arg{sym-font-2} \arg{slot-2}
924 \end{decl}
926 Defines \m{cmd} to be a radical where the small variant is in
927 slot \m{slot-1} of symbol font \m{sym-font-1} and the
928 large variant is in slot \m{slot-2} of symbol font
929 \m{sym-font-2}. Both symbol fonts must have been declared
930 previously.
932 Example (probably the only use for it!):
933 \begin{verbatim}
934 \DeclareMathRadical{\sqrt}{symbols}{"70}{largesymbols}{"70}
935 \end{verbatim}
937 \subsection{Declaring math sizes}
939 \begin{decl}
940 |\DeclareMathSizes| \arg{t-size} \arg{mt-size} \arg{s-size}
941 \arg{ss-size}
942 \end{decl}
944 Declares that \m{mt-size} is the (main) math text size, \m{s-size} is
945 the `script' size and \m{ss-size} the `scriptscript' size to be used
946 in math, when \m{t-size} is the current text size. For text sizes for
947 which no such declaration is given the `script' and `scriptscript'
948 size will be calculated and then fonts are loaded for the calculated
949 sizes or the best approximation (this may result in a warning
950 message).
952 Normally, \m{t-size} and \m{mt-size} will be identical; however, if,
953 for example, PostScript text fonts are mixed with bit-map math fonts
954 then you may not have available a \m{mt-size} for every \m{t-size}.
956 Example:
957 \begin{verbatim}
958 \DeclareMathSizes{13.82}{14.4}{10}{7}
959 \end{verbatim}
961 \section{Font installation}
962 \label{Sec:install}
964 This section explains how \LaTeX's font attributes are turned into
965 \TeX{} font specifications.
967 \subsection{Font definition files}
969 \NEWdescription{1997/12/01}
970 The description of how \LaTeX{} font attributes are turned into \TeX{}
971 fonts is usually kept in a \emph{font definition file} (|.fd|). The
972 file for family \m{family} in encoding \m{ENC} must be
973 called |<enc><family>.fd|: for example, |ot1cmr.fd| for Computer
974 Modern Roman with encoding |OT1| or |t1ptm.fd| for Adobe Times with
975 encoding |T1|. Note that encoding names are converted to lowercase
976 when used as part of file names.
978 Whenever \LaTeX{} encounters an encoding/family combination that it
979 does not know (e.g.~if the document designer says
980 |\fontfamily{ptm}\selectfont|) then \LaTeX{} attempts to load the
981 appropriate |.fd| file. ``Not known'' means: there was no
982 |\DeclareFontFamily| declaration issued for this encoding/family
983 combination. If the |.fd| file could not be found, a warning is
984 issued and font substitutions are made.
986 The declarations in the font definition file are responsible for
987 telling \LaTeX{} how to load fonts for that encoding/family
988 combination.
990 \subsection{Font definition file commands}
992 \emph{Note}: A font definition file should contain only commands
993 from this subsection.
995 Note that these commands can also be used outside a font definition
996 file: they can be put in package or class files, or even in the
997 preamble of a document.
999 \begin{decl}
1000 |\ProvidesFile{<file-name>}[<release-info>]|
1001 \end{decl}
1002 The file should announce itself with a |\ProvidesFile| command,
1003 as described in \emph{\clsguide}. For example:
1004 \begin{verbatim}
1005 \ProvidesFile{t1ptm.fd}[1994/06/01 Adobe Times font definitions]
1006 \end{verbatim}
1008 Spaces within the arguments specific to font definition files are
1009 ignored to avoid surplus spaces in the document. If a real space is
1010 necessary use |\space|.
1011 \NEWdescription{2004/02/10}However, note that this is only true if the
1012 declaration is made at top level! If used within the definition of
1013 another command, within |\AtBeginDocument|, option code or in similar
1014 places, then spaces within the argument will remain and may result in
1015 incorrect table entries.
1017 \begin{decl}
1018 |\DeclareFontFamily| \arg{encoding} \arg{family} \arg{loading-settings}
1019 \end{decl}
1021 Declares a font family \m{family} to be available in encoding scheme
1022 \m{encoding}.
1024 The \m{loading-settings} are executed immediately after loading any
1025 font with this encoding and family.
1027 Checks that \m{encoding} was previously declared.
1029 This example refers to the Computer Modern Typewriter font family in
1030 the Cork encoding:
1031 \begin{verbatim}
1032 \DeclareFontFamily{T1}{cmtt}{\hyphenchar\font=-1}
1033 \end{verbatim}
1035 Each |.fd| file should contain exactly one |\DeclareFontFamily|
1036 command, and it should be for the appropriate encoding/family
1037 combination.
1039 \begin{decl}
1040 |\DeclareFontShape| \arg{encoding} \arg{family} \arg{series}
1041 \arg{shape}\\
1042 \null\hfill \arg{loading-info} \arg{loading-settings}
1043 \end{decl}
1045 Declares a font shape combination; here \m{loading-info} contains the
1046 information that combines sizes with external fonts. The syntax is
1047 complex and is described in Section~\ref{sec:loadinfo} below.
1049 The \m{loading-settings} are executed after loading any font with this
1050 font shape. They are executed immediately after the
1051 `loading-settings' which were declared by |\DeclareFontFamily| and so
1052 they can be used to overwrite the settings made at the family level.
1054 Checks that the combination \m{encoding}\m{family} was previously
1055 declared via |\DeclareFontFamily|.
1057 Example:
1058 \begin{verbatim}
1059 \DeclareFontShape{OT1}{cmr}{m}{sl}{%
1060 <<5-8>> sub * cmr/m/n
1061 <<8>> cmsl8
1062 <<9>> cmsl9
1063 <<10>> <<10.95>> cmsl10
1064 <<12>> <<14.4>> <<17.28>> <<20.74>> <<24.88>> cmsl12
1066 \end{verbatim}
1067 The file can contain any number of |\DeclareFontShape| commands,
1068 which should be for the appropriate \m{encoding} and \m{family}.
1070 \NEWfeature{1996/06/01}
1071 The font family declarations for the |OT1|-encoded fonts now all
1072 contain:
1073 \begin{verbatim}
1074 \hyphenchar\font=`\-
1075 \end{verbatim}
1076 This enables the use of an alternative |\hyphenchar| in other encodings
1077 whilst maintaining the correct value for all fonts.
1079 \subsection{Font file loading information}
1080 \label{sec:loadinfo}
1082 The information which tells \LaTeX{} exactly which font ({\tt .tfm})
1083 files to load is contained in the \m{loading-info} part of a
1084 |\DeclareFontShape| declaration. This part consists of one or more
1085 \m{fontshape-decl}s, each of which has the following form:
1087 \begin{center}
1088 \begin{tabular}{r@{ $::=$ }l}
1089 \m{fontshape-decl} & \m{size-infos} \m{font-info} \\
1090 \m{size-infos} & \m{size-infos} \m{size-info} $\mid$
1091 \m{size-info} \\
1092 \m{size-info} & ``|<<|'' \m{number-or-range} ``|>>|'' \\
1093 \m{font-info} & $[$ \m{size-function} ``|*|'' $]$
1094 $[$ ``|[|'' \m{optarg} ``|]|'' $]$ \m{fontarg} \\
1095 \end{tabular}
1096 \end{center}
1097 The \m{number-or-range} denotes the size or size-range
1098 for which this entry applies.
1100 If it contains a hyphen it is a
1101 range: lower bound on the left (if missing, zero implied), upper bound
1102 on the right (if missing, $\infty$ implied). For ranges, the
1103 upper bound is \emph{not} included in the range and the lower bound is.
1105 Examples:
1106 \begin{center}
1107 \begin{tabular}{lll}
1108 |<<10>>| & simple size& 10pt only\\
1109 |<<-8>>| & range& all sizes less than 8pt\\
1110 |<<8-14.4>>| & range& all sizes greater than or equal to 8pt\\
1111 & & \ but less than 14.4pt\\
1112 |<<14.4->>| & range& all sizes greater than or equal 14.4pt
1113 \end{tabular}
1114 \end{center}
1115 If more than one \m{size-info} entry follows without any
1116 intervening \m{font-info}, they all share the next \m{font-info}.
1118 The \m{size-function}, if present, handles the use of \m{font-info}.
1119 If not present, the `empty' \m{size-function} is assumed.
1121 All the \m{size-info}s are inspected in the order in which they appear
1122 in the font shape declaration. If a \m{size-info} matches the
1123 requested size, its \m{size-function} is executed. If |\external@font|
1124 is non-empty afterwards this process stops, otherwise the next
1125 \m{size-info} is inspected. (See also |\DeclareSizeFunction|.)
1127 If this process does not lead to a non-empty |\external@font|,
1128 \LaTeX{} tries the nearest simple size. If the entry contains only
1129 ranges an error is returned.
1132 \subsection{Size functions}
1133 \label{sec:sizefunct}
1136 \LaTeX{} provides the following size functions, whose `inputs' are
1137 \m{fontarg} and \m{optarg} (when present).
1139 \begin{description}
1140 \item[`' (empty)]
1141 Load the external font \m{fontarg} at the user-requested size. If
1142 \m{optarg} is present, it is used as the scale-factor.
1144 \item[s]
1145 Like the empty function but without terminal warnings, only
1146 loggings.
1148 \item[gen]
1149 Generates the external font from \m{fontarg} followed by
1150 the user-requested size, e.g.~|<<8>> <<9>> <<10>> gen * cmtt|
1152 \item[sgen]
1153 Like the `gen' function but without terminal warnings, only loggings.
1155 \item[genb]
1156 \NEWfeature{1995/12/01}
1157 Generates the external font from \m{fontarg} followed by
1158 the user-requested size, using the conventions of the `ec' fonts.
1159 e.g.~|<<10.98>> genb * dctt| produces |dctt1098|.
1161 \item[sgenb]
1162 \NEWfeature{1995/12/01}
1163 Like the `genb' function but without terminal warnings, only loggings.
1165 \item[sub]
1166 Tries to load a font from a different font shape declaration given by
1167 \m{fontarg} in the form \m{family}|/|\m{series}|/|\m{shape}.
1169 \item[ssub]
1170 Silent variant of `sub', only loggings.
1172 \item[subf]
1173 Like the empty function but issues a warning that it has to substitute
1174 the external font \m{fontarg} because the desired font shape was not
1175 available in the requested size.
1177 \item[ssubf]
1178 Silent variant of `subf', only loggings.
1180 \item[fixed]
1181 Load font \m{fontarg} as is, disregarding the user-requested size.
1182 If present, \m{optarg} gives the ``at \ldots pt'' size to be used.
1184 \item[sfixed]
1185 Silent variant of `fixed', only loggings.
1187 \end{description}
1189 Examples for the use of most of the above size functions can be found
1190 in the file |cmfonts.fdd|---the source for the standard |.fd| files
1191 describing the Computer Modern fonts by Donald Knuth.
1194 \begin{decl}
1195 |\DeclareSizeFunction| \arg{name} \arg{code}
1196 \end{decl}
1198 Declares a size-function \m{name} for use in |\DeclareFontShape|
1199 commands. The interface is still under development but there should be
1200 no real need to a define new size functions.
1202 The \m{code} is executed when the size or size-range in
1203 |\DeclareFontShape| matches the user-requested size.
1205 The arguments of the size-function are automatically parsed and placed
1206 into |\mandatory@arg| and |\optional@arg| for use in \m{code}. Also
1207 available, of course, is |\f@size|, which is the user-requested size.
1209 To signal success \m{code} must define the command |\external@font|
1210 to contain the external name and any scaling options (if present) for
1211 the font to be loaded.
1213 This example sets up the `empty' size function (simplified):
1214 \begin{verbatim}
1215 \DeclareSizeFunction{}
1216 {\edef\external@font{\mandatory@arg\space at\f@size}
1217 \end{verbatim}
1220 \section{Encodings}
1221 \label{Sec:encode}
1223 This section explains how to declare and use new font encodings and
1224 how to declare commands for use with particular encodings.
1226 \subsection{The \textsf{fontenc} package}
1228 Users can select new font encodings using the |fontenc| package. The
1229 |fontenc| package has options for encodings; the last option becomes
1230 the default encoding. For example, to use the |OT2| (Washington
1231 University Cyrillic encoding) and |T1| encodings, with |T1| as the
1232 default, an author types:
1233 \begin{verbatim}
1234 \usepackage[OT2,T1]{fontenc}
1235 \end{verbatim}
1237 \NEWdescription{1997/12/01}
1238 For each font encoding \m{ENC} given as an option, this package loads
1239 the \emph{encoding definition} (|<enc>enc.def|, with an all
1240 lower-case name) file; it also sets |\encodingdefault| to be the last
1241 encoding in the option list.
1243 The declarations in the encoding definition file |<enc>enc.def| for
1244 encoding \m{ENC} are responsible for declaring this encoding and
1245 telling \LaTeX{} how to produce characters in this encoding; this file
1246 should contain nothing else (see Section~\ref{Sec:encode.def}.
1248 The standard \LaTeX{} format declares the |OT1| and |T1| text
1249 encodings by inputting the files |ot1enc.def| and |t1enc.def|; it also
1250 sets up various defaults which require that |OT1|-encoded fonts are
1251 available.
1252 Other encoding set-ups might be added to the distribution at a
1253 later stage.
1255 Thus the example above loads the files |ot2enc.def| and |t1enc.def|
1256 and sets |\encodingdefault| to |T1|.
1258 \emph{Warning}: If you wish to use |T1|-encoded fonts other than the `cmr'
1259 family then you may need to load the package (e.g.~\texttt{times})
1260 that selects the fonts \emph{before} loading \texttt{fontenc} (this
1261 prevents the system from attempting to load any |T1|-encoded fonts from
1262 the `cmr' family).
1264 \subsection{Encoding definition file commands}
1265 \label{Sec:encode.def}
1267 \emph{Note}: An encoding definition file should contain only commands
1268 from this subsection.
1270 \NEWdescription{1997/12/01}
1271 As with the font definition file commands, it is also possible
1272 (although normally not necessary) to use these declarations directly
1273 within a class or package file.
1275 \emph{Warning}: Some aspects of the contents of font definition files
1276 are still under development. Therefore, the current versions of the
1277 files |ot1enc.def| and |t1enc.def| are temporary versions and should
1278 not be used as models for producing further such files. For further
1279 information you should read the documentation in |ltoutenc.dtx|.
1281 \begin{decl}
1282 |\ProvidesFile{<file-name>}[<release-info>]|
1283 \end{decl}
1284 The file should announce itself with a |\ProvidesFile|
1285 command, described in \emph{\clsguide}. For example:
1286 \begin{verbatim}
1287 \ProvidesFile{ot2enc.def}
1288 [1994/06/01 Washington University Cyrillic encoding]
1289 \end{verbatim}
1292 \begin{decl}
1293 |\DeclareFontEncoding| \arg{encoding} \arg{text-settings}
1294 \arg{math-settings}
1295 \end{decl}
1297 Declares a new encoding scheme \m{encoding}.
1299 The \m{text-settings} are
1300 declarations which are executed every time |\selectfont| changes the
1301 encoding to be \m{encoding}.
1303 The \m{math-settings} are similar but are for math alphabets. They
1304 are executed whenever a math alphabet with this encoding is
1305 called.
1307 \NEWfeature{1998/12/01}
1308 It also saves the value of \m{encoding} in the macro
1309 |\LastDeclaredEncoding|.
1311 Example:
1312 \begin{verbatim}
1313 \DeclareFontEncoding{OT1}{}{}
1314 \end{verbatim}
1316 Some author commands need to change their definition depending on
1317 which encoding is currently in use. For example, in the |OT1|
1318 encoding, the letter `\AE' is in slot |"1D|, whereas in the |T1|
1319 encoding it is in slot |"C6|. So the definition of |\AE| has to
1320 change depending on whether the current encoding is |OT1| or |T1|.
1321 The following commands allow this to happen.
1323 \begin{decl}
1324 |\DeclareTextCommand| \arg{cmd} \arg{encoding}
1325 \oarg{num} \oarg{default} \arg{definition}
1326 \end{decl}
1327 This command is like |\newcommand|, except that it defines a
1328 command which is specific to one encoding. For example, the
1329 definition of |\k| in the |T1| encoding is:
1330 \begin{verbatim}
1331 \DeclareTextCommand{\k}{T1}[1]
1332 {\oalign{\null#1\crcr\hidewidth\char12}}
1333 \end{verbatim}
1334 |\DeclareTextCommand| takes the same optional arguments as
1335 |\newcommand|.
1337 The resulting command is
1338 robust, even if the code in \m{definition} is fragile.
1340 It does not produce an error if the command has already
1341 been defined but logs the redefinition in the transcript file.
1343 \begin{decl}[1994/12/01]
1344 |\ProvideTextCommand| \arg{cmd} \arg{encoding}
1345 \oarg{num} \oarg{default} \arg{definition}
1346 \end{decl}
1347 This command is the same as |\DeclareTextCommand|, except that
1348 if \m{cmd} is already defined in encoding \m{encoding}, then the
1349 definition is ignored.
1351 \begin{decl}
1352 |\DeclareTextSymbol| \arg{cmd} \arg{encoding} \arg{slot}
1353 \end{decl}
1354 This command defines a text symbol with slot \m{slot} in the
1355 encoding. For example, the definition of |\ss| in the |OT1| encoding
1357 \begin{verbatim}
1358 \DeclareTextSymbol{\ss}{OT1}{25}
1359 \end{verbatim}
1360 It does not produce an error if the command has already
1361 been defined but logs the redefinition in the transcript file.
1363 \begin{decl}
1364 |\DeclareTextAccent| \arg{cmd} \arg{encoding} \arg{slot}
1365 \end{decl}
1366 This command declares a text accent, with the accent taken from slot
1367 \m{slot} in the encoding. For example, the definition of |\"| in
1368 the |OT1| encoding is:
1369 \begin{verbatim}
1370 \DeclareTextAccent{\"}{OT1}{127}
1371 \end{verbatim}
1372 It does not produce an error if the command has already
1373 been defined but logs the redefinition in the transcript file.
1375 \begin{decl}
1376 |\DeclareTextComposite| \arg{cmd} \arg{encoding} \arg{letter}
1377 \arg{slot}
1378 \end{decl}
1379 This command declares that the composite letter formed from applying
1380 \m{cmd} to \m{letter} is defined to be simply slot \m{slot} in the
1381 encoding. The \m{letter} should be a single letter (such as |a|) or
1382 a single command (such as |\i|).
1385 For example, the definition of |\'{a}|
1386 in the |T1| encoding could be declared like this:
1387 \begin{verbatim}
1388 \DeclareTextComposite{\'}{T1}{a}{225}
1389 \end{verbatim}
1391 The \m{cmd} will normally have been previously declared
1392 for this encoding, either by using
1393 |\DeclareTextAccent|, or as a one-argument |\DeclareTextCommand|.
1395 \begin{decl}[1994/12/01]
1396 |\DeclareTextCompositeCommand| \arg{cmd} \arg{encoding} \arg{letter}
1397 \arg{definition}
1398 \end{decl}
1399 This is a more general form of |\DeclareTextComposite|, which allows
1400 for an arbitrary \m{definition}, not just a \m{slot}. The main use
1401 for this is to allow accents on |i| to act like accents on |\i|, for
1402 example:
1403 \begin{verbatim}
1404 \DeclareTextCompositeCommand{\'}{OT1}{i}{\'\i}
1405 \end{verbatim}
1406 It has the same restrictions as |\DeclareTextComposite|.
1409 \begin{decl}[1998/12/01]
1410 |\LastDeclaredEncoding|
1411 \end{decl}
1412 This holds the name of the last encoding declared via
1413 |\DeclareFontEncoding| (this should also be the currently most
1414 efficient encoding). It can be used in the \m{encoding} argument
1415 of the above declarations in place of explicitly mentioning the
1416 encoding, e.g.
1417 \begin{verbatim}
1418 \DeclareFontEncoding{T1}{}{}
1419 \DeclareTextAccent{\`}{\LastDeclaredEncoding}{0}
1420 \DeclareTextAccent{\'}{\LastDeclaredEncoding}{1}
1421 \end{verbatim}
1422 This can be useful in cases where encoding files sharing common code
1423 are generated from one source.
1426 \subsection{Default definitions}
1428 \NEWdescription{1997/12/01}
1429 The declarations used in encoding definition files define
1430 encoding-specific commands but they do not allow those commands to be
1431 used without explicitly changing the encoding. For some commands,
1432 such as symbols, this is not enough. For example, the~|OMS| encoding
1433 contains the symbol~`\S', but we need to be able to use the
1434 command~|\S| whatever the current encoding may be, without explicitly
1435 selecting the encoding~|OMS|.
1437 \NEWdescription{1997/12/01}
1438 To allow this, \LaTeX{} has commands that declare default definitions
1439 for commands; these defaults are used when the command is not defined
1440 in the current encoding. For example, the default encoding for~|\S|
1441 is~|OMS|, and so in an encoding (such as |OT1|) which does not
1442 contain~|\S|, the~|OMS| encoding is selected in order to access this
1443 glyph. But in an encoding (such as~|T1|) which does contain~|\S|, the
1444 glyph in that encoding is used. The standard \LaTeXe{} format sets
1445 up several such defaults using the following encodings: |OT1|,~|OMS|
1446 and~|OML|.
1448 \emph{Warning}: These commands should \emph{not} occur in encoding
1449 definition files, since those files should declare only commands for use
1450 when that encoding has been selected. They should instead be placed
1451 in packages; they must, of course, always refer to encodings that are
1452 known to be available.
1454 \begin{decl}[1994/12/01]
1455 |\DeclareTextCommandDefault| \arg{cmd} \arg{definition}
1456 \end{decl}
1457 This command allows an encoding-specific command to be given a default
1458 definition. For example, the default definition for |\copyright| is
1459 defined be be a circled `c' with:
1460 \begin{verbatim}
1461 \DeclareTextCommandDefault{\copyright}{\textcircled{c}}
1462 \end{verbatim}
1463 \begin{decl}[1994/12/01]
1464 |\DeclareTextAccentDefault| \arg{cmd} \arg{encoding} \\
1465 |\DeclareTextSymbolDefault| \arg{cmd} \arg{encoding}
1466 \end{decl}
1467 These commands allow an encoding-specific command to be given a
1468 default encoding. For example, the default encoding for |\"| and
1469 |\ae| is set to be |OT1| by:
1470 \begin{verbatim}
1471 \DeclareTextAccentDefault{\"}{OT1}
1472 \DeclareTextSymbolDefault{\ae}{OT1}
1473 \end{verbatim}
1474 Note that |\DeclareTextAccentDefault| can be used on any one-argument
1475 encoding-specific command, not just those defined with
1476 |\DeclareTextAccent|. Similarly, |\DeclareTextSymbolDefault| can be
1477 used on any encoding-specific command with no arguments, not just
1478 those defined with |\DeclareTextSymbol|.
1480 For more examples of these definitions, see |ltoutenc.dtx|.
1482 \begin{decl}[1994/12/01]
1483 |\ProvideTextCommandDefault| \arg{cmd} \arg{definition}
1484 \end{decl}
1485 This command is the same as |\DeclareTextCommandDefault|, except that
1486 if the command already has a default definition, then the definition
1487 is ignored. This is useful to give `faked' definitions of symbols
1488 which may be given `real' definitions by other packages. For example,
1489 a package might give a fake definition of |\textonequarter| by saying:
1490 \begin{verbatim}
1491 \ProvideTextCommandDefault{\textonequarter}{$\m@th\frac14$}
1492 \end{verbatim}
1494 \subsection{Encoding defaults}
1496 \begin{decl}
1497 |\DeclareFontEncodingDefaults| \arg{text-settings} \arg{math-settings}
1498 \end{decl}
1500 Declares \m{text-settings} and \m{math-settings} for all encoding
1501 schemes. These are executed before the encoding scheme dependent ones
1502 are executed so that one can use the defaults for the major cases and
1503 overwrite them if necessary using |\DeclareFontEncoding|.
1505 If |\relax| is used as an argument, the current setting of this default
1506 is left unchanged.
1508 This example is used by amsfonts.sty for accent positioning; it changes
1509 only the math settings:
1510 \begin{verbatim}
1511 \DeclareFontEncodingDefaults{\relax}{\def\accentclass@{7}}
1512 \end{verbatim}
1515 \begin{decl}
1516 |\DeclareFontSubstitution| \arg{encoding} \arg{family} \arg{series}
1517 \arg{shape}
1518 \end{decl}
1520 Declares the default values for font substitution which will be used
1521 when a font with encoding \m{encoding}
1522 should be loaded but no font can be found with the current
1523 attributes.
1525 These substitutions are local to the encoding scheme because the
1526 encoding scheme is never substituted! They are tried in the order
1527 \m{shape} then \m{series} and finally \m{family}.
1529 If no defaults are set up for an encoding, the values given by
1530 |\DeclareErrorFont| are used.
1532 The font specification for
1533 \m{encoding}\m{family}\m{series}\m{shape}
1534 must have been defined by |\DeclareFontShape|
1535 before the |\begin{document}| is reached.
1537 Example:
1538 \begin{verbatim}
1539 \DeclareFontSubstitution{T1}{cmr}{m}{n}
1540 \end{verbatim}
1542 \subsection{Case changing}
1543 \label{sec:case}
1545 \begin{decl}
1546 |\MakeUppercase| \arg{text} \\
1547 |\MakeLowercase| \arg{text}
1548 \end{decl}
1550 \NEWfeature{1995/06/01}
1551 \TeX{} provides the two primitives |\uppercase| and |\lowercase| for
1552 changing the case of text. Unfortunately, these \TeX{} primitives do
1553 not change the case of characters accessed by commands like |\ae| or
1554 |\aa|. To overcome this problem, \LaTeX{} provides these two commands.
1556 In the long run, we would like to use all-caps fonts rather than any
1557 command like |\MakeUppercase| but this is not possible at the moment
1558 because such fonts do not exist.
1560 For further details, see \texttt{clsguide.tex}.
1562 \NEWdescription{1999/04/23}
1563 In order that upper/lower-casing will work reasonably well, and in
1564 order to provide any correct hyphenation, \LaTeXe{} \emph{must} use,
1565 throughout a document, the same fixed table for changing case. The
1566 table used is designed for the font encoding |T1|; this works well
1567 with the standard \TeX{} fonts for all Latin alphabets but will cause
1568 problems when using other alphabets. As an experiment, it has now
1569 been extended for use with some Cyrillic encodings.
1572 \section{Miscellanea}
1573 \label{Sec:misc}
1575 This section covers the remaining font commands in \LaTeX{} and some
1576 other issues.
1578 \subsection{Font substitution}
1580 \begin{decl}
1581 |\DeclareErrorFont| \arg{encoding} \arg{family} \arg{series}
1582 \arg{shape} \arg{size}
1583 \end{decl}
1585 Declares \m{encoding}\m{family}\m{series}\m{shape} to be the font shape
1586 used in cases where the standard substitution mechanism fails
1587 (i.e.~would loop). For the standard mechanism see the command
1588 |\DeclareFontSubstitution| above.
1590 The font specification for
1591 \m{encoding}\m{family}\m{series}\m{shape}
1592 must have been defined by |\DeclareFontShape|
1593 before the |\begin{document}| is reached.
1595 Example:
1596 \begin{verbatim}
1597 \DeclareErrorFont{OT1}{cmr}{m}{n}{10}
1598 \end{verbatim}
1601 \begin{decl}
1602 |\fontsubfuzz|
1603 \end{decl}
1605 This parameter is used to decide whether or not to produce a terminal
1606 warning if a font size substitution takes place. If the difference
1607 between the requested and the chosen size is less than |\fontsubfuzz|
1608 the warning is only written to the transcript file. The default value
1609 is |0.4pt|. This can be redefined with |\renewcommand|, for example:
1610 \begin{verbatim}
1611 \renewcommand{\fontsubfuzz}{0pt} % always warn
1612 \end{verbatim}
1614 \subsection{Preloading}
1616 \begin{decl}
1617 |\DeclarePreloadSizes| \arg{encoding} \arg{family} \arg{series}
1618 \arg{shape}
1619 \arg{size-list}
1620 \end{decl}
1623 Specifies the fonts that should be preloaded by the format. These
1624 commands should be put in a |preload.cfg| file, which is read in when
1625 the \LaTeX{} format is being built.
1626 Read |preload.dtx| for more information on how to built such a
1627 configuration file.
1629 Example:
1630 \begin{verbatim}
1631 \DeclarePreloadSizes{OT1}{cmr}{m}{sl}{10,10.95,12}
1632 \end{verbatim}
1635 \subsection{Accented characters}
1637 \NEWdescription{1996/06/01}
1638 Accented characters in \LaTeX{} can be produced using commands such as
1639 |\"a| etc. The precise effect of such commands depends on the font
1640 encoding being used. When using a font encoding that contains the
1641 accented characters as individual glyphs (such as the |T1| encoding,
1642 in the case of |\"a|) words that contain such accented characters can
1643 be automatically hyphenated. For font encodings that do not contain
1644 the requested individual glyph (such as the |OT1| encoding) such a
1645 command invokes typesetting instructions that produce the accented
1646 character as a combination of character glyphs and diacritical marks
1647 in the font. In most cases this involves a call to the \TeX{}
1648 primitive |\accent|. Glyphs constructed as composites in this way
1649 inhibit hyphenation of the current word; this is one reason why the
1650 |T1| encoding is preferable to the original \TeX{} font encoding
1651 |OT1|.
1653 It is important to understand that commands like |\"a| in \LaTeXe{}
1654 represent just a name for a single glyph (in this case `umlaut a') and
1655 contain no information about how to typeset that glyph---thus it does
1656 \emph{not} mean `put two dots on top of the character a'. The
1657 decision as to what typesetting routine to use will depend on the
1658 encoding of the current font and so this decision is taken at the last
1659 minute. Indeed, it is possible that the same input will be typeset in
1660 more than one way in the same document; for example, text in section
1661 headings may also appear in table of contents and in running heads; and
1662 each of these may use a font with a different encoding.
1664 For this reason the notation |\"a| is \emph{not} equivalent to:
1665 \begin{verbatim}
1666 \newcommand \chara {a} \"\chara
1667 \end{verbatim}
1668 In the latter case, \LaTeX{} does not expand the macro |\chara| but
1669 simply compares the notation (the string |\"\chara|) to its list of
1670 known composite notations in the current encoding; when it fails to
1671 find |\"\chara| it does the best it can and invokes the typesetting
1672 instructions that put the umlaut accent on top of the expansion of
1673 |\chara|. Thus, even if the font actually contains `\"a' as an
1674 individual glyph, it will not be used.
1676 The low-level accent commands in \LaTeX{} are defined in such a way
1677 that it is possible to combine a diacritical mark from one font with a
1678 glyph from another font; for example, |\"\textparagraph| will produce
1679 \"\textparagraph. The umlaut here
1680 is taken from the |OT1| encoded font |cmr10| whilst the paragraph sign
1681 is from the |OMS| encoded font |cmsy10|. (This example may be
1682 typographically silly but better ones would involve font encodings
1683 like |OT2| (Cyrillic) that might not be available at every
1684 site.)
1686 There are, however, restrictions on the font-changing commands that
1687 will work within the argument to such an accent command. These are
1688 \TeX{}nical in the sense that they follow from the way that \TeX{}'s
1689 |\accent| primitive works, allowing only a special class of commands
1690 between the accent and the accented character.
1692 The following are examples of commands that will not work correctly as
1693 the accent will appear above a space: the font commands with text
1694 arguments (|\textbf{...}| and friends); all the font size declarations
1695 (|\fontsize| and |\Large|, etc.); |\usefont| and declarations that
1696 depend on it, such as |\normalfont|; box commands (e.g.~|\mbox{...}|).
1698 The lower-level font declarations that set the attributes family,
1699 series and shape (such as |\fontshape{sl}\selectfont|) will produce
1700 correct typesetting, as will the default declarations such as
1701 |\bfseries|.
1704 \subsection{Naming conventions}
1706 \begin{itemize}
1707 \item
1708 Math alphabet commands all start with |\math...|: examples are
1709 |\mathbf|, |\mathcal|, etc.
1711 \item
1712 The text font changing commands with arguments all start with
1713 |\text...|: e.g.~|\textbf| and |\textrm|. The exception to this is
1714 |\emph|, since it occurs very commonly in author documents and so
1715 deserves a shorter name.
1717 \item
1718 Names for encoding schemes are strings of up to three letters (all
1719 upper case) plus digits.
1721 The \LaTeX3 project reserves the use of encodings starting with the
1722 following letters: |T| (standard 256-long text encodings), |TS|
1723 (symbols that are designed to extend a corresponding |T| encoding),
1724 |X| (text encodings that do not conform to the strict requirements for
1725 |T| encodings), |M| (standard 256-long math encodings), |S| (other
1726 symbol encodings), |A| (other special applications), |OT| (standard
1727 128-long text encodings) and |OM| (standard 128-long math encodings).
1729 Please do not use the above starting letters for non-portable
1730 encodings. If new standard encodings emerge then we shall add them in
1731 a later release of \LaTeX.
1733 Encoding schemes which are local to a site or a system should start
1734 with |L|, experimental encodings intended for wide distribution will
1735 start with |E|, whilst |U| is for Unknown or Unclassified encodings.
1737 \item
1738 Font family names should contain up to five lower case letters.
1739 Where possible, these should conform to the \emph{Filenames for fonts}
1740 font naming scheme.
1742 \item
1743 Font series names should contain up to four lower case letters.
1745 \item
1746 Font shapes should contain up to two letters lower case.
1748 \item
1749 Names for symbol fonts are built from lower and upper case letters
1750 with no restriction.
1751 \end{itemize}
1753 Whenever possible, you should use the series and shape names suggested
1754 in \emph{\LaTeXcomp} since this will make it easier to combine new
1755 fonts with existing fonts.
1757 \NEWdescription{1994/12/01}
1758 Where possible, text symbols should be named as |\text| followed by
1759 the Adobe glyph name: for example |\textonequarter| or
1760 |\textsterling|. Similarly, math symbols should be named as
1761 |\math| followed by the glyph name, for example |\mathonequarter|
1762 or |\mathsterling|. Commands which can be used in text or math can
1763 then be defined using |\ifmmode|, for example:
1764 \begin{verbatim}
1765 \DeclareRobustCommand{\pounds}{%
1766 \ifmmode \mathsterling \else \textsterling \fi
1768 \end{verbatim}
1769 Note that commands defined in this way must be robust, in case they
1770 get put into a section title or other moving argument.
1772 \section{If you need to know more \ldots}
1774 \NEWdescription{1996/06/01}
1775 The |tracefnt| package provides for tracing the actions concerned with
1776 loading, substituting and using fonts.
1777 The package accepts the following options:
1778 \begin{description}
1779 \item[errorshow] Write all information about font changes, etc.\ but
1780 only to the transcript file unless an error occurs. This means that
1781 information about font substitution will not be shown on the
1782 terminal.
1784 \item[warningshow] Show all font warnings on the terminal. This
1785 setting corresponds to the default behaviour when this
1786 \texttt{tracefnt} package is \emph{not} used!
1788 \item[infoshow] Show all font warnings and all font info messages
1789 (that are normally only written to the transcript file) also on the
1790 terminal. This is the default when this \texttt{tracefnt} package is
1791 loaded.
1793 \item[debugshow] In addition to what is shown by \texttt{infoshow},
1794 show also changes of math fonts (as far as possible): beware, this
1795 option can produce a large amount of output.
1797 \item[loading] Show the names of external font files when they are
1798 loaded. This option shows only `newly loaded' fonts, not those
1799 already preloaded in the format or the class file before this
1800 \texttt{tracefnt} package becomes active.
1802 \item[pausing]
1803 Turn all font warnings into errors so that \LaTeX{} will stop.
1804 \end{description}
1806 \emph{Warning}: The actions of this package can change the layout of a
1807 document and even, in rare cases, produce clearly wrong output, so
1808 it should not be used in the final formatting of `real documents'.
1810 \begin{thebibliography}{1}
1812 \bibitem{A-W:MG2004}
1813 Frank Mittelbach and Michel Goossens.
1814 \newblock {\em The {\LaTeX} Companion second edition}.
1815 \newblock With Johannes Braams, David Carlisle, and Chris Rowley.
1816 \newblock Addison-Wesley, Reading, Massachusetts, 2004.
1818 \bibitem{tub:DKn89}
1819 Donald~E. Knuth.
1820 \newblock Typesetting concrete mathematics.
1821 \newblock {\em {TUG}boat}, 10(1):31--36, April 1989.
1823 \bibitem{A-W:LLa94}
1824 Leslie Lamport.
1825 \newblock {\em {\LaTeX:} A Document Preparation System}.
1826 \newblock Addison-Wesley, Reading, Massachusetts, second edition, 1994.
1828 \end{thebibliography}
1830 \end{document}