%
% define the standard logo (since we use the new logo throughout)
\makeatletter
\DeclareRobustCommand{\stdLaTeX}{L\kern-.36em
  {%
    \sbox\z@ T%
    \vbox to\ht0{\hbox{$\m@th$%
        \csname S@\f@size\endcsname
        \fontsize\sf@size\z@
        \math@fontsfalse\selectfont
        A}%
      \vss}%
  }%
  \kern-.15em
  \TeX}
%
\DeclareRobustCommand{\faqLaTeX}{L%
  {%
    \setbox0\hbox{T}%
    \setbox\@tempboxa\hbox{$\m@th$%
      \csname S@\f@size\endcsname
      \fontsize\sf@size\z@
      \math@fontsfalse\selectfont
      A}%
    \@tempdima\ht0
    \advance\@tempdima-\ht\@tempboxa
    \@tempdima\strip@pt\fontdimen1\font\@tempdima
    \advance\@tempdima-.36em
    \kern\@tempdima
    \vbox to\ht0{\box\@tempboxa
      \vss}%
  }%
  \kern-.15em
  \TeX}
\makeatother
%
\title{Typesetting the \LaTeX{} Logo: a Saga}
\author{Robin Fairbairns}
\begin{Article}
  When I was collating the first edition of the \uktug\ \acro{FAQ},
  one of the people I asked to review it was Barbara Beeton, and one
  of her comments was that the \LaTeX{} logo looked awful,
  specifically when typeset in \emph{Baskerville Italic}.

  Barbara's observation set me on a quest for a resilient macro to
  typeset this curious object; I still haven't found any philosopher's
  stone for this task, but I have at least got a formula that enables
  one to codify some working parameters in a \LaTeX-like sort of
  way\dots.

  Sebastian Rahtz, in one of his fulminating editorials, cried `a pox
  on all these logos'.  In retrospect one could wish that Lamport
  hadn't taken us beyond Knuth's original \TeX{} logo (which seemed
  amusing at first encounter), but while one can steadfastly ignore
  most other logos, it seems difficult to ignore \LaTeX{} (whether
  you're a convinced user or a virulent hater).  I hope that the work
  I describe here will make its own small contribution to the beauty
  of descriptions, in \LaTeX{}, of \LaTeX{} itself~\dots or will, at
  least, draw them back from the abyss of hideousness that the logo
  itself seems inexorably to pull towards.

  \section{The Old \LaTeX\ coding}

  The last release of~2.09 (dating from March~1992), had:
\begin{verbatim}
\def\p@LaTeX{{\reset@font\rm L\kern-.36em%
    \raise.3ex\hbox{\sc a}\kern-.15em%
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\def\LaTeX{\protect\p@LaTeX}
\end{verbatim}
  Apart from the \cs{reset@font}, this is (in essence) Lamport's
  original coding; the definition of \cs{p@LaTeX} provides the basis
  for the robust command \cs{LaTeX} (Lamport's original was fragile).

  The output the macro produces is reasonable, \emph{if} you're using
  \texttt{cmr} at a `reasonable' size: at \texttt{10pt}, we see
  {\fontfamily{cmr}\fontencoding{OT1}\selectfont L\kern-.36em\raise.3ex\hbox{\sc a}%
    \kern-.15emT\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}\@.  It's
  odd that its code includes that for (Knuth's) logo \cs{TeX} (rather
  than referring to the older macro), and it's noteworthy that neither
  it nor Knuth's code makes the spacefactor adjustment due at the end
  of the word\footnote{This observation is due to Barbara Beeton.} (in
  English typesetting, it's common practice to set the capitals in
  acronyms and logos as if they were lower-case letters).

  The problems that arise from the macro are:
  \begin{itemize}
  \setlength{\itemsep}{0pt}%
  \item that it steadfastly sets in the default font (\texttt{cmr}),
    and
  \item that its use of \cs{sc} restricts it to a smaller range of
    sizes than one might hope.
  \end{itemize}
  These restrictions make it appear odd in section titles (which are
  set in bold in \LaTeX's standard classes), and prevent (what seems
  to me) entirely reasonable use in sans fonts, etc.  However, since
  it's now history, I shan't discuss it further.

  \section{The standard \LaTeX{} coding}

  I don't any longer have the sources, but as I recall at least some
  of the pre-release versions of \LaTeXe{} had something similar to
  the \LaTeX209{} version of the logo.  This version, instead of using
  the `old' font command \cs{sc} (which selects some `fixed' font,
  rather than a font related to that which surrounds it), used the
  \LaTeX{} command \cs{scshape}.  (The same would also have been true
  of pre-\LaTeXe{} versions of the \acro{NFSS} with their subversion
  of the \LaTeX209{} font commands.)  This had the unfortunate effect
  that \LaTeX{} warned you about using \cs{LaTeX} in a section title,
  since almost no font family defines a bold-series
  Caps-and-Small-Caps font\dots.

  The appearance of the present \LaTeX{} logo was therefore a minor
  relief for navel-contemplating\footnote{`Real' users, writing about
    anything other than \LaTeX{} itself would never have noticed the
    problem!} users such as myself.  The new logo coding sets the `\acro{A}'
  of \LaTeX{} in the scriptfont size related to the current text size,
  and with its apex at the same level as the top of the `T'.  This
  logo actually looks slightly different from the one in \LaTeX209{},
  but is noticeably more stable:
\begin{verbatim}
\DeclareRobustCommand{\LaTeX}{L\kern-.36em
  {%
    \sbox\z@ T%
    \vbox to\ht0{\hbox{$\m@th$%
        \csname S@\f@size\endcsname
        \fontsize\sf@size\z@
        \math@fontsfalse\selectfont
        A}%
      \vss}%
  }%
  \kern-.15em
  \TeX}
\end{verbatim}
  As you can see, the code sets `T' into a scratch \cs{hbox} which it
  then uses as the height of a \cs{vbox} into the top of which the `\acro{A}'
  is stuck.  The size of the `\acro{A}' is selected in the curious sequence
  involving an empty maths mode (with zero \cs{mathsurround}), the
  setting-up of current maths sizes using \cs{S@}\meta{\cs{f@size}}
  (as it were), and then using the \cs{sf@size} (which is the `current
  script font size') thus defined.

  This version of the logo deals with some of the problems of the
  \LaTeX209{} version, and pushes back the boundaries of difficulty into
  new areas:
  \begin{itemize}
  \setlength{\itemsep}{0pt}%
  \item very small font sizes, where the scriptfont size doesn't
    differ much (or at all) from the textfont size,
  \item font sizes for which no \cs{DeclareMathSizes} has been issued:
    in this case, \LaTeX{} will calculate a value for the size of
    \cs{scriptstyle} which ought to be appropriate, but which could
    well not be available within the set of fonts \LaTeX{} is willing
    to employ,
  \item thoroughly peculiar uses (for example, the man who complained
    on \Newsgroup|comp.text.tex| that the \textsf{textfit} package
    produces odd effects, like:
    {{\huge\global\edef\grumble{\the\font}}\grumble\stdLaTeX},
    which fails because the font is selected outside of the
    \acro{NFSS}, and so the `\acro{A}' matches whatever size is
    \acro{NFSS}-selected\Dash in this case 10pt\footnote{That example
      was achieved by selecting \cs{huge} outside of the \acro{NFSS}:
      the original complaint was about a 1~inch high logo, at which
      size it's difficult to see that there's an `\acro{A}' there at all!}),
    and
  \item use in fonts that don't match the kerning parameters used.
  \end{itemize}
  It's the last problem that I've been attempting to address in my
  investigations of the logo.

  \begin{figure*}[tp]
    \begin{center}
      \leavevmode
      \includegraphics{logo-mbvx-m-n}
      \caption{\LaTeX{} logo samples for Baskerville medium, normal}
      \label{fig:bv-latex-sample}
    \end{center}
  \end{figure*}
  \section{My first attempt}

  This code deals with the slant of an italic character, and has been
  used in the published editions of the \acro{FAQ}.
\begin{verbatim}
\DeclareRobustCommand{\LaTeX}{L%
  {%
    \setbox0\hbox{T}%
    \setbox\@tempboxa\hbox{$\m@th$%
      \csname S@\f@size\endcsname
      \fontsize\sf@size\z@
      \math@fontsfalse\selectfont
      A}%
    \@tempdima\ht0
    \advance\@tempdima-\ht\@tempboxa
\end{verbatim}
  That sets up the amount by which the `\acro{A}' will be raised,
  in \cs{@tempdima}; the next line of code extracts the font dimension
  that gives the slant, and multiplies \cs{@tempdima} by it; this is
  simple coordinate geometry, and gives an amount by which to adjust
  the negative kern in the standard version of the logo.  We then
  calculate an actual value to use for the kern, and complete the
  fractured coding of the standard logo.
\begin{verbatim}
    \@tempdima
    \strip@pt\fontdimen1\font\@tempdima
    \advance\@tempdima-.36em
    \kern\@tempdima
    \vbox to\ht0{\box\@tempboxa
      \vss}%
  }%
  \kern-.15em
  \TeX}
\end{verbatim}
  This code improves the appearance of inclined copies of the
  logo\Dash inclined copies are absolutely dire if you're using
  Baskerville fonts (as we do in \BV): compare \emph{\stdLaTeX} (the
  standard logo) with \emph{\faqLaTeX} (the above code).

  \section{But the standard code doesn't even work with
    \acro{CM}-family fonts!}

  Section titles in \tub{} are set in \texttt{cmssbx}\footnote{\tub{}
    `sections' are collections of related papers within one issue;
    sections within a \tub{} paper are like sections within any
    \LaTeX{} document.}: the fragility of the logo is demonstrated by
  the fact that the standard code fails with this font:
  {\fontfamily{cmss}\fontencoding{OT1}\bfseries\selectfont\stdLaTeX}.  When the first
  `\LaTeX{} macros' section turned up since I joined the \tub{}
  production team, Barbara Beeton asked me to `sort it out'.  Since
  this problem is occurring for an upright font, the trick I developed
  for use in \BV{} doesn't help.

  I could have taken a hint from the documentation that's included in
  the \LaTeX{} distribution, which defines a different logo for each
  font family one might use to print it; however, I didn't notice
  this, and developed a version that can in principle behave
  differently for every value of font family, series and shape.

  The \cs{LaTeX} command itself is simple: it simply chooses a set of
  pre-defined parameters (or, in default of that, selects the
  parameters used in the standard logo), and then relays to a patched
  version of the standard logo:
\begin{verbatim}
\DeclareRobustCommand\LaTeX{%
 \expandafter\let\expandafter\@tempa
 \csname @LaTeX@\f@family/\f@series/%
   \f@shape\endcsname
 \ifx\@tempa\relax\let\@tempa\@LaTeX@default\fi
 \expandafter\@LaTeX\@tempa}
\end{verbatim}
  The patched version of the standard logo is equally trivial:
\begin{verbatim}
\newcommand\@LaTeX[2]{L\kern-#1em
  {%
    \sbox\z@ T%
    \vbox to\ht0{\hbox{$\m@th$%
        \csname S@\f@size\endcsname
        \fontsize\sf@size\z@
        \math@fontsfalse\selectfont
        A}%
      \vss}%
    }%
  \kern-#2em%
  \TeX}
\end{verbatim}
  The parameters are defined by the command
\begin{verbatim}
\newcommand\DeclareLaTeXLogo[5]{%
  \expandafter\def
  \csname @LaTeX@#1/#2/#3\endcsname
   {{#4}{#5}}}
\end{verbatim}
  whose parameters are font family, series and shape, and then the two
  extra parameters to be used by \cs{@LaTeX}.  The default setting is
  simply:
\begin{verbatim}
\def\@LaTeX@default{{.36}{.15}}
\end{verbatim}
  My \textsf{ltugboat} class defines three sets of \acro{CM}-family
  parameters:
\begin{verbatim}
\DeclareLaTeXLogo{cmss}{bx}{n}{.3}{.15}
\DeclareLaTeXLogo{cmr}{m}{it}{.3}{.27}
\DeclareLaTeXLogo{cmr}{bx}{it}{.3}{.27}
\end{verbatim}
  the first of which deals with the problem that Barbara Beeton had
  highlighted.

  Finding sets of parameters to use isn't entirely trivial; I generate
  a set of logos with different parameters for the font family, series
  and shape under consideration, examine them, adjust the set of
  parameters and iterate until I have something that looks
  satisfactory.  The last sample in this exercise for Baskerville
  medium, normal, is shown in figure~\ref{fig:bv-latex-sample}.

  \section{Conclusion: future work}

  The macros I describe above are available on \acro{CTAN} in
  directory \url{macros/latex/contrib/supported/ltx-logo} (together
  with the source of this note, by way of justification).  The
  \texttt{ltx-logo} package takes font family names as package
  options: for each option quoted, the package will define any logo
  parameter sets it knows for that family: at the time of writing, the
  package knows about the \texttt{cm} family (using the parameters
  shown above for \url{cmss/bx/n}, \url{cmr/m/it} and \url{cmr/bx/it})
  and the Monotype Baskerville families \texttt{mbv} and \texttt{mbvx}
  (the latter includes use of the so-called `expert' fonts: for the
  purposes of the \LaTeX{} logo, the required parameters are the same
  as for the non-expert set).

  I remarked above that the \LaTeX{} team had defined special-purpose
  \LaTeX{} logos for a number of font families, in the macros used for
  the documentation distributed with \LaTeX.  Their approach (which
  was developed independently of mine) isn't as general as mine, but I
  was interested to note that they also redefine the \TeX{} logo: I
  hadn't bothered with that, on the grounds that it seemed `mostly
  \acro{OK}' in texts I had set.  I suppose it offers an avenue for
  still further enthralling developments in my study of \TeX-based
  logos.

  The macros on \acro{CTAN} include the test code I used to evaluate
  parameters for the fonts.  People who feel moved to work out sets
  for their own favourite font family are encouraged to submit them to
  me for inclusion in the distribution\dots.
\end{Article}
