I am trying to typeset a word in a similar fashion as the \LaTeX logo. I have found the code for the logo (given below in the MWE), but it uses many commands that I have never seen before, such as \z@ (which according to a google search is zero?), and strange syntax (T\vbox to \ht) which I am not used to.

I am trying to understand each step of the command, including the syntax, and why it is done this way.

A MWE if anyone feels the need to play around with the code:

    L\kern -.36em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts \fontsize \sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.15em\TeX
  • It's a bit of a mix of LaTeX document commands, LaTeX internals and TeX primitives :-)
    – Joseph Wright
    Jun 7, 2016 at 14:45

1 Answer 1

\makeatletter %% access private macros
L%% print an L
\kern -.36em%% add a negative kern
{%% open a group
  \sbox \z@ T%% load box 0 with a T
  \vbox to\ht \z@ {%% start a vertical box as high as box 0
    \hbox {% start a horizontal box
      \check@mathfonts%% ensure the math fonts sizes are set up at the current font size
      \fontsize \sf@size \z@%% use the established font size for sub/superscripts
      \math@fontsfalse%% don't bother setting up all the math fonts for the new current size
      \selectfont%% select the font
      A%% print an A
    }%% finish the horizontal box
    \vss%% fill up the stated height
  }%% finish the \vbox
}%% end the group
\kern -.15em%% add a negative kern
\TeX%% print the TeX logo
\makeatother%% no more private macros allowed

Some notes.

\sbox\z@ T is completely equivalent to \sbox{0}{T}; the code is reduced to the minimum number of tokens because at the time LaTeX2e was being developed, computer memory was very scarce. The code stored in the definition of \LaTeX is three tokens, whereas \sbox{0}{T} has seven.

What a \vbox and an \hbox are can be found in TeX by Topic (freely available in any TeX distribution as texdoc texbytopic or on CTAN).

\check@mathfonts ensures that the math fonts are set up for the current size; normally this is only done when a math formula is started. This command, in particular, defines \sf@size as the font size for first level sub/superscripts. The macro \selectfont sets up the current font; with \math@fontsfalse we tell it not to do the necessary work for setting up also the math fonts, because we just want to print an A at the requested size, not to typeset arbitrary text with math.

\vss is the same as \vspace{0pt plus 1fil minus 1fil}, so it is an infinitely stretchable and shrinkable space, which will push the \hbox containing the A flush with the top of the \vbox. Thus, the top of the A will be at the same height as the top bar of the T (and probably also the top of the L).

A \kern is something like \hspace, but not stretchable nor shrinkable. In these places it ia preferred because it cannot be used as a line break point (unless it is followed by a skip).

The definition of \TeX is simpler: the E is shifted down and some kerns are applied.

As Barbara notes in comments, this definition is very carefully studied for the Computer Modern fonts. Other fonts may give a not so good result. The metalogo package tries to “abstract” the spacings, so the logo can be adapted to other fonts with minimum hassle (but some tries are needed to get the parameters right).

  • 6
    well, that's an accurate technical explanation, but it doesn't say why the logo is constructed that way. here's the rationale: a smaller "A" (the same size as a superscript would be) is raised so that its top is at the same height as the top of the "T" (and the "L"), and centered between them, with the spacing closed up to look close to the inter-letter spacing in the tex logo. the spacing adjustments were determined by experimentation and may differ with a different font. Jun 7, 2016 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.