          The file plainfsl.doc^{∗}.

Wayne G. Sullivan

February 6, 1994

1 Font selection scheme

The Mittelbach/Schöpf font selection scheme is a systematic approach for handling of fonts in TEX documents. It was originally designed for use under L^{A}TEX, but it may be used with other formats. The purpose of the present work is to provide the necessary adaptations for Plain TEX. First we include a few macros based on those in L^{A}TEX.

\protect \makeatletter \makeatother The control sequence \protect is rather subtle. In ordinary text setting it is superfluous. However, there are numerous contexts where it can be used to control the way macros are expanded, as in the \typeout macro given below. Other contexts require other tricks. Some macros of Plain TEXuse @ as a letter to inhibit redefinition. To access these, the catcode of @ needs to be changed. The experienced TEX user may occasionally wish to access these private macros, so the required catcode changes are assigned to control sequences. We use such a change here.

  \let\protect\relax
  \def\makeatletter{\catcode`\@11 }
  \def\makeatother{\catcode`\@12 }
  \makeatletter

\@ifundefined \@ifdefinable L^{A}TEX is sometimes careful about assigning new macro names. In these cases the new identifier will be checked to see if it has already been used. \@ifundefined takes the characters in the identifier as its first parameter and uses \csname to construct the control sequence name. Control sequences so constructed are given the value \relax if they have not previously appeared. If the control sequence defined by the characters has not previoulsy appeared, or is currently equivalent to \relax, then the second parameter of \@ifundefined is included; otherwise the third. The macro \@ifdefinable takes as first parameter a control sequence which is converted to its characters. If these characters form an undefined control sequence (in the above sense), then the second parameter of the macro is included. Otherwise an error messsage is issued.

∗This file has version number 0.01, dated 91/8/20. The documentation was last updated on 91/8/20.

  \long\def\@ifundefined#1#2#3{\expandafter\ifx\csname
      #1\endcsname\relax#2\else#3\fi}
  \long\def\@ifdefinable#1#2{\relax\count@\escapechar\escapechar\m@ne
      \edef\@tempa{\string#1}\escapechar\count@
      \expandafter\@ifundefined\expandafter{\@tempa
      }{#2}{\errmessage{\string#1 already defined}}}

\typeout \@latexerr \@eha One of the main tools the font selection scheme uses for sending messages to the screen is \typeout. Without the redefinition of \protect, the output in some cases would be considerably less legible. For reporting errors the font selection scheme uses L^{A}TEX macros which are given here. The \@eha error help given here is even more terse than the original: such general messages are of little use anyway.

  \def\typeout#1{{\let\protect\string\immediate\write\sixt@@n{#1}}}
  \def\@eha{Enter `?' for options.}
  \def\@latexerr#1#2{%
  \edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}%
     \errmessage{#1}}

\mbox Most of those who use TEX are sometimes baffled by TEX’s mode (or mood). In order to get a paragraph to start with an \hbox some coaxing must be employed. \leavevmode does the trick and leaves no sticky residue.

  \def\mbox#1{\leavevmode\hbox{#1}}

\@ifnextchar \@ifstar It is convenient when writing macros to have a technique for modifying the interpretation based on the first character following the control sequence. Thus \@ifstar will invoke one set of instuctions if the character following is * and another otherwise. This is achieved by means of the TEX primitive \futurelet. The matter is complicated by the fact that spaces are skipped when undelimited macro parameters are scanned. So if \futurelet detects a space, the macro should skip on until a non-blank token is found. The coding borders on the clever, but because of the subtle difference between characters and control sequences equating to characters, the whole business could be derailed by a devious or unlucky token. Below, to obtain space tokens in the desired locations, \edef and \expandafter are used. The macros so defined do not contain

\expandafter.
  \edef\@ifnextchar#1#2#3{\let\noexpand\@tempc=#1\def\noexpand
      \@tempa{#2}\def\noexpand\@tempb{#3}\noexpand\@peeknextch\space}
  \expandafter\def\expandafter\@peeknextch\space
        {\futurelet\@tempd\@finifnextch}
  \expandafter\def\expandafter\@finifnextch
  \expandafter{\expandafter\ifx\space\@tempd\let\@tempd\@peeknextch\else
      \ifx\@tempd\@tempc\let\@tempd\@tempa\else\let\@tempd\@tempb\fi\fi

      \@tempd}
  \def\@ifstar#1#2{\@ifnextchar*{\def\@tempa*{#1}\@tempa}{#2}}

This completes the discussion of the macros adapted from L^{A}TEX.

2 Plain fonts

Next we proceed to the font selection macros which are described in detail in their own documentation. Since these will be loaded after Plain TEX, some font material is already loaded. If your version of plain preloads more than the 16 basic fonts and you make little use of the other preloaded fonts, you might consider commenting out the extra preloaded fonts in plain.tex. Now that there is a much greater choice of fonts for use with TEX, it makes even more sense to preload only fonts which are frequently used. Whether a font is preloaded does not effect the final output. The only advantage of preloading is that it may result in slightly reduced processing time. Excessive preloading can result in reduced processing speed. The font selection scheme does its own allocation of math alphabets, i.e., \fam, so we need to reset this allocation to the minimum corresponding to roman, math italic, symbol and extensible. We also give the font selection name to the extensible font.

  \count18=3 % deallocate plain math alphabets=>\fam numbers
  \expandafter\let\csname cmex/m/n/10\endcsname=\tenex

3 Mittelbach/Schöpf

Next we append the bulk of the font selection macros by using the docstrip utility to include the macros in the same file as the above macros. However, near the end of the scheme there are macros which appeal directly to L^{A}TEX structures. We use a trick to omit these. The scheme requests the file xxxlfont.sty to give the user the option of retaining the basic way that L^{A}TEX handles math mode fonts or use a different approach. For use with Plain TEX we include a file with the name xxxlfont.sty, which itself will request the input of a file yyylfont.sty, again to allow the user choice of math mode font selection styles. Penultimatily xxxlfont.sty will request the input of a file anyextra.xyz to allow the user to include other material in the format file. Only one file is requested; if the user has several to include, then a single file which inputs each of these should be made. If no further material is to be included, then the user should enter the name of the system null file or make up a file which consists simply of \endinput. The file xxxlfont.sty then executes \dump.

4 Other files needed

In addition to plainfsl.tex and xxxlfont.sty one needs a fontdef.tex.

There are several of these available from the general font selection distribution. This file should be adapted to local available fonts. Also requested during the format processing is preload.tex. The user should make up his own preload file based on the fonts commonly used, but it is not necessary to preload any additional fonts: a system null file (or equivalent) can be supplied in place of

preload.tex. Also needed is either oldlfont.sty or basefont.tex.

          The file scripts.doc^{∗}.

Wayne G. Sullivan

February 6, 1994

The macros below are designed for the Mittelbach/Schöpf font selection scheme. If this scheme is not loaded, the scripts macros are omitted.

  \chardef\next\catcode`\@
  \catcode`\@11
  \@ifundefined{extract@font}
       {\errmessage{The style option `scripts' does not work unless you
                    use a format with the new font selection scheme.}
  \catcode`\@\next
        \endinput}
       {}

We begin by identifying the latest version of this file on the VDU and in the log file.

  \immediate\write\sixt@@n{Style Option `scripts'
   \fileversion\space <\filedate>  (WGS) \@spaces<\docdate>}

{\ssp \atop \ssb} Superscrips and subscripts are often used in ordinary text. TEX’s math mode provides easy access to such scripts, with an automatic size reduction. If one does not desire a size reduction, then one should use \raise with \hbox. The problem with math mode is that the fonts used may be totally unrelated to the one currently used in horizontal mode. In math mode TEX can access at most sixteen fonts, each in three sizes. Furthermore, the fonts are subject to \mathcode restrictions, so that many expressions are not affected by a change of math alphabet. However, letters and digits do change, and this suffices in many cases. The macro \@sspssb temporarily assigns the last math alphabet to the current font so that one can use letters and digits as scripts. Then \ssp{a} yields superscript a in the current font; \ssb is similar for subscripts. If one wishes a change of font, this should be done before using these macros. These macros are designed for one or a few letters or numbers as scripts. If a complicated expression is given as the parameter, strange effects may occur.

  \chardef\fift@@n 15
  \def\ssp{\protect\@sspssb^}%

∗This file has version number 0.02, dated 91/8/14. The documentation was last updated on 91/8/15.

\def\ssb{\protect\@sspssb_}%
\def\@sspssb#1#2{\begingroup\ifreseTmathcodes\reseTmathcodes{#2}\fi
    \ifmmode#1{#2}\else \xdef\font@name{%
      \csname\f@family/\f@series/\f@shape/\sf@size\endcsname}%
    \pickup@font$\scriptfont\fift@@n\font@name
    \xdef\font@name{%
      \csname\f@family/\f@series/\f@shape/\ssf@size\endcsname}%
    \pickup@font\scriptscriptfont\fift@@n\font@name
    \fam\fift@@n#1{#2}$\fi\endgroup}%

\reseTmathcodes In some cases one wishes to use characters in the current font whose math codes do not allow change of font. Macros to handle this case have also been included. If one wishes something like [a] in the current font as a superscript, then one should first include \reseTmathcodestrue and then invoke \ssp{[a]}. To return to the original form, include \reseTmathcodesfalse. The macros are even more fragile when resetting math codes: only character tokens are allowed. We use the uppercase T to avoid possible name confict with other macros which change math codes.

\newif\ifreseTmathcodes
\def\glop@ne#1#2\glop@ne{\def\@tempa{#1}\def\@tempb{#2}}
\def\reseTmathcodes#1{\def\@tempb{#1}\def\next
     {\ifx\@tempb\empty\let\next\relax\else
     \expandafter\glop@ne\@tempb\glop@ne
     \count@"7000 \advance\count@\expandafter`\@tempa\mathcode
     \expandafter`\@tempa\count@\fi\next}\next}
\catcode`\@\next

          The file xxxlfont.doc^{∗}.

Wayne G. Sullivan

February 6, 1994

5 Skipping the tail macros

This is a hack file to be used with plainfsl. It is designed to omit the last part of the code in lfonts.doc. What should be omitted is most of the material

after \input  xxxlfont.sty, but not all.

\cases Some of the techniques in the font selection scheme do not behave as desired in special contexts. One difficulty arises in alignments. The implicit grouping in alignments can at times confilct with the use of \aftergroup. To overcome this problem in some cases it is necessary explicitly to include some alignment arguments in braces. Other added macros are also included here.

    \def\cases#1{\left\{\,\vcenter{%
        \normalbaselines\m@th\ialign{%
           $##\hfil$&\quad{##}\hfil\crcr
           #1\crcr}}\right.}%
     \def\reset@font{\protect\p@reset@font}
     \def\p@reset@font{\fontfamily{\rmdefault}%
                    \fontseries{\mediumseriesdefault}%
                    \fontshape{\normalshapedefault}\selectfont}

6 Handling math mode fonts

yyylfont.sty Now we can get on with loading extra material for math mode. There is a choice. If one wants math mode to behave like horizontal mode regarding the choice of fonts, then the easy answer is to enter the file name oldlfont.sty when requested for a file name after yyylfont.sty cannot be found. The resulting format behaves very much like Plain TEX regarding choice of fonts in math mode, e.g., \rm in math mode will select the math group 0, which is initially cm roman. However, because of mathcode values $\bf*$ is no different from $*$. The only characters reliably changed by font changes in math mode are the letters and digits. If one makes little explicit use of math mode it is probably better to select basefont.tex. If one enters basefont rather than oldlfont.sty when requested for a substitute for yyylfont.sty, then changes of font in math mode behave like single parameter macros. Thus to get the caligraphic letters ABC in math mode one uses $\cal{ABC}$. Also, only four math alphabets are predefined: \mathrm,\mit,\cal and extensible. If others are desired, they must be defined as explained below. At most sixteen different font styles may be used without leaving math mode. If one only wants an expression at standard size, place the expression in an \hbox and include the \hbox in the math formula. Any font may be used in the \hbox.

∗This file has version number 0.02, dated 91/12/12. The documentation was last updated on 91/8/20.

\lyfam Some consider it advisable to reserve the limited math fonts for special symbol fonts like the AMS fonts and cmmib. The L^{A}TEX symbol fonts add only a few new symbols, so the following is used to exclude them. To include them, comment out the following line.

     \let\lyfam=\null  % comment out if LaTeX symbol fonts desired
     \typeout{}
     \typeout{Choose oldlfont.sty or basefont}
     \typeout{}
   \input yyylfont.sty

7 Defining new math alphabets and characters

\newmathalphabet To use symbols in math mode which are not included in standard Plain TEX one can either include the material in an \hbox or define a new math alphabet. The advantage of the latter is that the symbol will change size depending on the math context. The simplest way to introduce an new math alphabet is as follows.

 \newmathalphabet*{\bmit}{cmm}{b}{it}

\new@mathgroup \define@mathgroup Sadly, the above does not allow ready access to characters other than letters and digits. However, it only loads script and scriptscript fonts when needed. To access other characters in the font one uses \mathchardef. With such definitions it is better to use \new@mathgroup.

 \new@mathgroup\bmitgroup
 \define@mathgroup{\mv@normal}{\bmitgroup}{cmm}{b}{it}
 \xdef\bmit{\noexpand\use@mathgroup\expandafter
     \noexpand\csname=cmm\endcsname\noexpand\bmitgroup}

which results in math fonts being defined for \bmit for each new size. Note the catcode of @ may need changing. Furthermore some command, e.g., \rm, which invokes \selectfont is required to complete the process. One may use either

\newmathalphabet or \define@mathgroup with \new@mathgroup to define a

new math font; do not use both for the same new math font.

\makemathchar Now to define new math characters one may use \bmit to produce bold Greek minuscules. To get bold α we need the correct \mathchardef. Each math character has class number (0–7), a math alphabet number (0–15) and a character location (0–255). From font tables we have α at position 11 and we take the class 0. The macro below uses the math alphabet identifier to evaluate the required number. Then the mathchar is defined as follows:

 \makemathchar{\alphabold}{0}{\bmit}{11}

This is the macro which does the work:

  \def\makemathchar#1#2#3#4{\count@=#2\relax
      \multiply\count@\sixt@@n\setbox0\hbox
      {$#3\global\advance\count@\mathgroup$}\multiply\count@\@cclvi
       \advance\count@#4\relax\mathchardef#1=\count@}

This definition may also be used with font identifiers defined using \newmathalphabet, but the size of the fonts may not be correct unless the math font identifier has appeared in the same or previous math expression since the last size change. Of course, one must have the TFM files for the fonts at the various text and script sizes.

8 Inhibiting math fonts

\stopdefmathfonts \restoredefmathfonts Math fonts set up by \define@newmathgroup are defined at text, script and

scriptscript for every size change, including loading if necessary. It is possible to inhibit fonts for math mode at specific sizes by using \define@nomathsize instead of \define@mathsize, but this is a bit troublesome to change and will not work properly with the subscript and superscript macros in scripts.doc. We include here some macros to simplify the choice of whether to load math fonts for a given size. The sizes for script and scriptscript are still set up, so the macros of scripts.doc may still be used. The reader should be aware that macros like \copyright (unless redefined) use math mode so require the loading of math fonts. To inhibit math fonts for a given size one should include \stopdefmathfonts just before the size change. If the size change including the above command is enclosed in a group, the original math font procedure will be restored at the end of the group. Otherwise one can use

\restoredefmathfonts.
  \let\savedefine@mathfonts=\define@mathfontstrue
  \def\stopdefmathfonts{\let\define@mathfontstrue\define@mathfontsfalse}
  \def\restoredefmathfonts{\let\define@mathfontstrue\savedefine@mathfonts}

9 Local modifications

anyextra.xyz To allow the user to include further macros in the format file the file anyextra.xyz is sought. The system should not find a file of this name so that TEX will request an alternative. If there is nothing to add, then a null system name should be given, or one should prepare a file which includes simply \endinput. All extra material should be specified by the one file to be \input here.

     \typeout{}
     \typeout{Add extra material to the format here:}
     \typeout{}
   \input anyextra.xyz

\mathversion Because L^{A}TEX allows two different math versions, normal and bold, the font selection scheme has two math versions. Here we select the normal version and set up the initial font and line spacing.

   \size{10}{12pt}\mathversion{normal}\rm

10 Finishing off

\dump It only remains to make @ into an other character and dump the format file. We

also turn on \tracingstats, but this is optional.

  \makeatother
  \tracingstats 1 % comment out if undesired
    \dump

11 Extras

Since there is a \dump above, the material below will not be seen by TEX. It is included because PostScript fonts and John Sauter’s parameterization of the cm fonts fit well into the font selection scheme. The reader should realize that font specifications additional to those in fontdef.tex may be included in documents; they do not have to be in the format file. Some material below is based on a macro due to Sebastian Rahtz. EXTRA MATERIAL NOT IN THE FORMAT, BUT WHICH MAY BE OF INTEREST:

    \def\sauterfontshape#1#2#3#4{%
       \new@fontshape{#1}{#3}{#4}{%
        <5>#25<6>#26<7>#27<8>#28<9>#29<10>#210<11>#211%
        <12>#212<14>#214<17>#217<20>#220<25>#225}{}}%
  \def\ps@fs@#1#2#3#4{\new@fontshape{#1}{#2}{#3}{%
        <5>#4 at5pt<6>#4 at6pt<7>#4 at7pt<8>#4 at8pt%
        <9>#4 at9pt<10>#4 at10pt<11>#4 at11pt<12>#4 at12pt%
        <14>#4 at14pt<17>#4 at17pt<20>#4 at20pt<25>#4 at25pt}{}}%

\sauterfontshape{cmm}{cmmib}{b}{it}
\def\postscriptfontdef#1#2#3#4#5#6#7#8#9{%
% 1 : short name for family
% 2 : tfm name for normal font
% 3 : tfm name for italic font
% 4 : tfm name for bold font
% 5 : tfm name for bold italic font
% 6 : tfm name for smallcaps font
% 7 : tfm name for bold smallcaps font
% 8 : tfm name for slanted font
% 9 : tfm name for slanted bold font
\ps@fs@{#1}{m}{n}{#2}%
\ps@fs@{#1}{m}{it}{#3}%
\ps@fs@{#1}{bx}{n}{#4}%
\ps@fs@{#1}{bx}{it}{#5}%
\ps@fs@{#1}{m}{sc}{#6}%
\ps@fs@{#1}{bx}{sc}{#7}%
\ps@fs@{#1}{m}{sl}{#8}%
\ps@fs@{#1}{bx}{sl}{#9}%
\extra@def{#1}{}{}%
% bold and bold-extended regarded as the same
\subst@fontshape{#1}{b}{sc}{#1}{bx}{sc}%
\subst@fontshape{#1}{b}{sl}{#1}{bx}{sl}%
\subst@fontshape{#1}{b}{n}{#1}{bx}{n}%
\subst@fontshape{#1}{b}{it}{#1}{bx}{it}%
%% Below the control sequence \short_name is defined to
%% invoke the standard font of the family.
\expandafter\gdef\csname p@#1\endcsname{\family{#1}\shape
   \normalshapedefault\series\mediumseriesdefault
   \selectfont}%
\expandafter\xdef\csname #1\endcsname{\noexpand\protect
   \expandafter\noexpand\csname p@#1\endcsname}%
}%