\title{A Moral Tale}
\author[Malcolm Clark]{Malcolm Clark\\
\texttt{m.clark@warwick.ac.uk}}
\begin{Article}
\section{Keeping to the straight (and narrow)}
Both \TeX\ and \LaTeX\ are remarkably smart.
From time to time they are either too smart, or not quite
smart enough. One area that I have always been dubious about
is how subscripts are handled. In the simple case,
I find that the unevenness of the baselines in a case
like:
\[ x_1y^1_1 \]
is both odd and unsettling. The reasons for this
are mainly in the font dimensions. This is a subject
area which is mostly relegated to a dusty corner, although I do
address it a little in my \emph{Plain \TeX\ Primer}.
At this point, I have to admit that
I strongly believe that the use of \LaTeXe\ is to be
advocated and preferred, at least until \LaTeX3 and \LaTeX4 come along.
Using \LaTeX2.09 is only excusable if you have old documents
you still need to process. Anything new should be done in \LaTeXe.
The justification for the use of \TeX\ is more difficult,
unless you have particularly well developed prejudices.
However, in the explanations that follow
I shall start through plain \TeX\ rather than \LaTeXe.
To some extent, \TeX\ is  the
`accessible basic \LaTeX\ system, which doesn't require
wizardry to tailor to one's own preferences' which
Siep Kroonenberg said is needed (\BV~4.4).
At this point we need something slim and easily tweakable.
I'm therefore using \TeX\ as a sort of `prototyping' system which
allows me to demonstrate things which I will eventually transfer
to \LaTeXe. This is how I think \TeX\ is best used.

\section{A plain explanation}
There are a couple of interactions going on with sub- and superscripts. The
first and easiest to explain is the behaviour of
two of the font dimensions, 16 and 17, which control the distance between
the subscripts and the baseline. If we constrain the two font dimensions
to be equal, our apparent `problem' disappears
(see also Knuth, page 179, a double dangerous bend section).
Therefore, if we set
\begin{verbatim}
\fontdimen16\cmsy=\fontdimen17\cmsy
\end{verbatim}
we can obtain results where the baselines of the  subscripts
are aligned:
\[ x_1^{}y^1_1 \]

This is reasonably well understood, and the explanation,
that we do not wish the superscripts and subscripts to interfere
with one another (in a broader aesthetic sense) seems reasonably
well grounded. I am not too clear how widely this particular attention
to detail is practised in the publishing profession. Perhaps
some readers have information on this. I would be particularly interested
in publishing houses who do not use the `Addison-Wesley' approach
to typesetting mathematics.

The real stimulus for this note was the
common requirement to include pieces of text within
a mathematical expression. When the  concepts
are going to be used frequently, this is unlikely to
be very important, since you would probably  define a
symbol to represent the concept. However, in more informal
works it can make the equation much more accessible to the reader.
To ease terminology,
I shall refer to the relative sizes by the plain \TeX\ terms:
`display style' as in (\ref{naive}), and `script style'
for first level subscripts, diminished in size, as in (\ref{correct}).
In plain \TeX, display style would be a 10\,pt font, and script style would
be 7\,pt.


For example, it may be convenient to be able to say
\begin{equation}
\log(\textrm{amplitude})=-2(2H+1)\log(\textrm{order}) \label{display}
\end{equation}
given by
\begin{verbatim}
\log(\hbox{amplitude})=
  -2(2H+1)\log(\hbox{order})
\end{verbatim}
This is fine until we try to do the same for subscripted
text. For example, the `direct' equivalent of
\begin{verbatim}
 u_{\hbox{ex}}
  =u_{\hbox{maximum Airy wave}}(1-F)
\end{verbatim}
gives
\begin{equation}
 u_{\textrm{ex}}=u_{\textrm{maximum Airy wave}}(1-F)\label{naive}
\end{equation}
which is `subscripted' material  but in display style.
If we really wanted
\begin{equation}
u_{\textrm{\scriptsize ex}}=
   u_{\textrm{\scriptsize maximum Airy wave}}(1-F)\label{correct}
\end{equation}
how would we obtain it?
The answer is fairly straightforward: force the size of the text
to \verb|\scriptstyle| size. Unfortunately we cannot do this by
employing \verb+\scriptstyle+ directly, since it is an instruction
which may be used only within maths. Enclosing it in an \verb+\hbox+
insulates it from maths. The nearest we can do is to recall that
a first level superscript is 7pt, and use \verb+\sevenrm+:
\begin{verbatim}
u_{\hbox{\sevenrm ex}}=
u_{\hbox{\sevenrm maximum Airy wave}}
(1-F)
\end{verbatim}
This is most unsatisfactory. You should never have to declare
explicit font changes like this.

I would also agree that all this \verb|\hbox|  is
a bit of a mouthful, but you are buying convenience for your readers
at the expense of some minor personal inconvenience. But I said earlier,
if you were going to litter your text with this, you really ought
to define a few symbols instead.

There is still a `small' problem with (\ref{naive}).
Let's wind back a little and
assume that we are not all that interested in making sure
the subscripted text is in script style, and that
we are content with display style size for the subscripted
textual material. This is perhaps not
wholly unreasonable, according to the context. Consider the
following equation fragment:
\begin{equation}
a_{\textrm{x}} + a_{\textrm{y}} + a_{\textrm{b}} \label{simple}
\end{equation}
obtained from
\begin{verbatim}
a_{\hbox{x}} + a_{\hbox{y}}
  + a_{\hbox{b}}
\end{verbatim}
The problem is the lack of alignment in the baselines of the subscripted
material, which was also present with the `ex' of (\ref{naive}).
The `x' and `y' are fine, but the `b' has a lower
baseline.  As I said earlier, I find this a little unsettling.
This time however, we have no superscripts interacting with
the positioning.


We can solve the problem of aligning the baselines moderately readily by a
subterfuge. It just `happens' that the left and right parentheses in Computer
Modern are text characters with the maximum vertical extent. No other text
character has a greater ascender or descender. Had our text subscripted material
been parenthetical, the baselines would have been aligned:
\begin{equation}
a_{\textrm{(x)}} + a_{\textrm{(y)}} + a_{\textrm{(b)}} \label{parentheses}
\end{equation}
This is probably not what we wanted, but we could just have a
\verb+\vphantom{)}+ with each subscript. It is ugly and crude,
but it will do what we require.
\begin{equation}
a_{\textrm{x\vphantom{)}}} + a_{\textrm{y\vphantom{)}}}
            + a_{\textrm{b\vphantom{)}}} \label{ugly}
\end{equation}
for example:
\begin{verbatim}
a_{\hbox{x\vphantom{)}}}
  + a_{\hbox{y\vphantom{)}}}
  + a_{\hbox{b\vphantom{)}}}
\end{verbatim}
In passing, those depending on their intuition and considering the use of  a
\verb+\strut+ are sadly wrong. Struts which are
the size of the `local' parenthesis would be a boon, but
unfortunately they are not so defined.


At this point, the question we could ask is `why does
the displaystyle subscripted material behave differently
to the scriptstyle material'. Naturally, all is revealed in
the \TeX\ book. Appendix G (Generating Boxes from Formulas)
reveals all, but in true K(nu)thonic style it demands
great attention to detail.  The answer is clearly not
just in the font dimensions, or placing them equal would have
meant that they all shared the same baseline, and the presence or lack of
superscripts would have been irrelevant. Fighting your way
through the key section (number 18) we will come to the
conclusion that it is the size (mostly the height) of the subscripted
material which determines what happens. In the case of material
set in displaystyle, the extra height of material with an ascender
is sufficient to select a branch which lowers it further. The
material without ascenders does not select the option, and
therefore we can have irregular baselines. The scriptsize material
on the other hand does not branch to this alternative, because it is that
much smaller in the first place, and therefore the baselines remain aligned.

In order to force conditions so that the subscripted display style material
is guaranteed to align, we can fiddle with the font dimensions.
What we cannot do is fiddle with the conditions and rules which are hard
wired into \TeX. This, I think is one of the weaknesses of \TeX. Its
monolithic nature precludes plugging in different rule sets --
either as improvements, or to accommodate new situations. If we
change the two font dimensions to
\begin{verbatim}
\fontdimen16\tensy=1ex
\fontdimen17\tensy=1ex
\end{verbatim}
we can ensure the alignment. Unfortunately, this is less than
perfect when we also wish to have `normal' scriptstyle susbcripts.
They appear much too far below the level of the material they
subscript. The value of 1\,ex is actually a little more than
you would need if you never had superscripts to contend with too
(about 0.95ex would probably do -- you can work it out exactly with
the rules in section 18), but as soon as you bring
in superscripts you then have to contend with an extra vertical
movement designed to ensure that sub- and superscript are apart
by at least four times the thickness of a rule.



\section{Back to the present}
How do we translate all this into \LaTeXe, since that
is what you are going to want to use? It turns out
that the option of altering the font dimensions is not
really one which is open to us. Although the \emph{Companion}
does give an example of the use of \verb+\DeclareFontShape+ where
it demonstrates the syntax of how \verb+\fontdimen+\,s may be changed,
it notes that the example would not work and that `the best way to solve this
problem is to define a virtual font'. I'm afraid that if the solution is to
define a virtual font, then I'll change the problem. Another problem lies in
the fact that you cannot change the characteristics of already loaded fonts.
The fonts we use are almost inevitably preloaded (i.e.~\LaTeXe\ has already
absorbed all their font metric information, including the font dimensions). The
only way to do this is therefore to work with \textsf{tftopl} to convert the
\TeX\ font metric file to a property list, edit the font dimensions by hand,
convert back to a \TeX\ font metric file and then re-create the \LaTeXe\
format. This is almost as bad as using virtual fonts. We do not end up with
something we can switch on and off at will. You cannot change formats part way
through typesetting.

The translations of equations~\ref{display} and~\ref{naive} are
done simply by changing the \TeX\ \verb+\hbox+ instruction into either an
\verb+\mbox+ or \verb+\textrm+. In this instance they are equivalent. In
the case of~\ref{correct}, we do not have a \LaTeXe\ instruction
\verb+\scriptstyle+. How then do we obtain the `correct' size? Things start to
become a little more difficult. \LaTeXe\ does support a number of font size
changing instructions, notably \verb+\small+, \verb+\footnotesize+,
\verb+\scriptsize+ and \verb+\tiny+. In all three size options, \textsf{10pt},
\textsf{11pt} and\textsf{12pt} the relative size gradation is

\[
\texttt{\char'134small}>\texttt{\char'134footnotesize}>
\texttt{\char'134scriptsize}>\texttt{\char'134tiny}
\]
That does not indicate which of these sizes corresponds to a \TeX\ scriptstyle,
although we could make a fair guess that \verb+\scriptsize+ is the likely
candidate. There is also an instruction \verb+\scriptstyle+, but this may only be
used within math style and trying to combine it with \verb+\textrm+ is doomed to
failure. You might have thought that \verb+\mathrm+ could help, but of course
the spacing between letters would be the normal maths spacing between variables.
It is obvious that \LaTeXe\ has a way of doing this properly, or constructs like
\begin{equation}
x_{\log y}
\end{equation}
would not work. If we delve into \textsf{latex2e.ltx}, where this and similar
operators are defined, we discover (certainly to my surprise) that they do not
use the \LaTeXe\ font changing mechanisms, but instead use the definition
\begin{verbatim}
\def\log{\mathop{\rm log}\nolimits}
\end{verbatim}
This is the very font changing mechanism which the \emph{Companion} describes
with the admonishment: `we suggest that you refrain from using such commands in
new documents'. To be fair, this isn't any sort of \LaTeX, but \TeX,
since the \verb+\def+  instruction is \emph{not} a \LaTeX\
command.\footnote{I've tried persuading FM that it should be removed at
\LaTeX3. He smiled.} To be even more fair, this deficiency has been
recognised, and my \textsf{latex2e.ltx} is the beta release. Apparently current
versions refer instead to \verb+\operator@font+: not normally accessible
to humans. 
However, although the sizes will be correct, the inter word spacing
disappears altogether.

The conclusion is therefore that we have to select one of the font size
changing instructions. Before we do that, let's look to see which of these
sizes would give us aligned subscripts. The earlier experiments with \TeX\
indicated that the alignment was sensitive to the size.
Here are the size changing mechanisms of
\verb+\small+ (\ref{small}), \verb+\footnotesize+
(\ref{footnotesize}), \verb+\scriptsize+ (\ref{scriptsize}),
 and \verb+\tiny+ (\ref{tiny}):
\begin{equation}
a_{\textrm{\small x}}
   + a_{\textrm{\small y}}
   + a_{\textrm{\small b}} \label{small}
\end{equation}
\begin{equation}
a_{\textrm{\footnotesize x}}
   + a_{\textrm{\footnotesize y}}
   + a_{\textrm{\footnotesize b}} \label{footnotesize}
\end{equation}
\begin{equation}
a_{\textrm{\scriptsize x}}
   + a_{\textrm{\scriptsize y}}
   + a_{\textrm{\scriptsize b}} \label{scriptsize}
\end{equation}
\begin{equation}
a_{\textrm{\tiny x}}
   + a_{\textrm{\tiny y}}
   + a_{\textrm{\tiny b}} \label{tiny}
\end{equation}
Examination reveals that \verb+\tiny+, and, as anticipated,
\verb+\scriptsize+ are aligned.
The problem stated however, was to have the subscripted material at
`normal' text size. Therefore the easy solution is to incorporate the
\verb+\vphantom+\,s, as in equation~(\ref{ugly}):
\begin{verbatim}
a_{\textrm{x\vphantom{)}}}
+ a_{\textrm{y\vphantom{)}}}
+ a_{\textrm{b\vphantom{)}}}
\end{verbatim}
Of course to save typing you would use \verb+\newcommand+ to
make \verb+\vphantom{)}+ shorter.
Should you wish to reduce the size, then you could do something like
\begin{verbatim}
a_{\textrm{\scriptsize x}}
   + a_{\textrm{\scriptsize y}}
   + a_{\textrm{\scriptsize b}}
\end{verbatim}

\section{Conclusions}
It therefore appears to be cumbersome to come up with some
neat fix, and the rather inelegant solution of phantom parentheses
seems to be about the least inoffensive we can manage. Do
remember that it only works in a guaranteed way with Computer Modern.
There is no reason to assume that other maths fonts will share this
characteristic. If you want to subscripted material to match in size to other
susbcripts, use \verb+\scriptsize+. In some ways the \LaTeX\ solutions are
tidier and marginally less inelegant than the plain \TeX\ solutions.

\section{Afterword}
There is yet hope. After I wrote this, I was alerted to the \textsf{amstext}
package which  produces  \verb+\scriptsize+ text when subscripted, without
any of the trickery outlined here. This is outlined on page 227 of \emph{The
Companion}. I should really have known, since, as Lamport says on page 52 of
\emph{The \LaTeX\ User's Guide}, `sooner or later you'll encounter one
(formula) which can't be handled with the commands described so far\dots
consider using the
\textsf{amstex} package'. \textsf{Amstext} is a sub-package of \textsf{amstex}.
\textsc{rtfm}.

If RAB's handy mathematical hints don't get there first, I'll look
at \textsf{amstex}  more closely in the future\dots
\end{Article}
