5

An exercise from 'The TeXbook' asks to write "Pál Erdős" in typewriter type. The difficulty comes that \H cannot be used, as the typewriter font contains other symbols (namely a })

The proposed solution is to borrow the accent from another font

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

however the output does not have the accent over the o but on an space, as if Erd\H{}os was written

The book's solution works with plain TeX but fails with LaTeX

  • 1
    Welcome to TeX.SX! Are you using Plain TeX or LaTeX? – egreg Feb 22 '14 at 9:42
3

Fonts in the OT1 encoding are those described in the TeXbook, but \tt and \bf work very differently in LaTeX than in Plain TeX. And they're obsolete and deprecated.

If you want to stick with the OT1 encoding, then

\documentclass{article}

\begin{document}

{\ttfamily P\'{a}l Erd{\rmfamily\bfseries\H{\mdseries\ttfamily o}}s}

\end{document}

is the LaTeX counterpart of the TeXbook exercise.

With the T1 encoding it is much easier, because the typewriter type font has the glyph:

\documentclass{article}
\usepackage[T1]{fontenc}

\begin{document}

{\ttfamily P\'{a}l Erd\H{o}s}

\end{document}

If you also use UTF-8 for inputting the file, then it's even easier:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}

{\ttfamily Pál Erdős}

\end{document}

and the output is identical to the preceding one.

enter image description here

0
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[scaled=0.88]{beramono}
\begin{document}

\ttfamily P\'al Erd{\bfseries\H{o}}s 

Pál Erd\textbf{ő}s 

\rmfamily Pál Erd\textbf{ő}s 
\end{document}

enter image description here

  • The “o” shouldn't be boldface; moreover no trick is needed if the T1 encoding is selected. – egreg Feb 22 '14 at 10:36

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.