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:
\documentclass{standalone}
\begin{document}
\makeatletter
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
\makeatother
\end{document}
Best Answer
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 astexdoc 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).