4

In TeXBook, exercise 9.6 Knuth asks to type Pal Erdos with needed accents in \tt font.

So I've tried the naive {\tt P\'al Erd\H os} and succeed. But Knuth proposes to use the next mixup of fonts:

{\tt P\'al Erd{\bf\H{\tt o}}s}

It seems like an interesting technique, as it allows to catch accents from other fonts. But it strange that the code was not succeed, as I received accent \H and o separate from eacha other. It seems like they were not bound.

How to apply Knuth's technique?

outmind
  • 377
  • You shouldn't tag your questions with "plain-tex" when they involve LaTeX. – egreg Jul 10 '11 at 12:46
  • @egreg -- where does the question say anything about latex? since a texbook exercise is cited explicitly, i believe the poster's tagging of "plain-tex" was justified. for a plain tex answer, i believe this can be done with some \expandafters, but i have to experiment first to figure out how many and where. – barbara beeton Jul 10 '11 at 13:23
  • @barbara There is at least one other message by the OP that has the same problem. Since the present code works perfectly in Plain TeX, the only cause for failure is its use in LaTeX. – egreg Jul 10 '11 at 13:45

1 Answers1

6

The commands \tt and \bf shouldn't be used in LaTeX any more, they are present only for back compatibility.

The following input works without any special trick

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\begin{document}
\texttt{P\'al Erd\H{o}s}
\end{document}

since T1 encoded fonts are used, which have a richer supply of accents and accented characters than OT1 encoded fonts.

Implementing the trick is more complicated in LaTeX:

\documentclass{article}
\begin{document}

\texttt{Erd\textnormal{\textbf{\H{\mdseries\ttfamily o}}}s}

\end{document}

We first need to call normal font, then boldface for the accent, and return to \ttfamily in medium series for the accentee.

enter image description here

For comparison, here is the plain TeX version

{\tt Erd{\bf\H{\tt o}}s}
\bye

enter image description here

egreg
  • 1,121,712