The fontenc package

Selects the font encoding for pdfLaTeX. \usepackage[T1]{fontenc} switches to fonts that contain accented letters as single characters.

Loading the package

\usepackage[T1]{fontenc}

The default encoding OT1 has 128 characters and no accented letters. LaTeX builds an ä from the letter a and a separate accent. TeX does not hyphenate a word that contains such a built character, and text copied from the PDF can come out with the accent next to the letter.

OT1 also lacks some plain characters: typed in text, <, > and | print as ¡, ¿ and a dash. T1 has 256 characters, among them the accented letters of the western and central European languages, and both problems disappear.

Every document in a language other than English that is compiled with pdfLaTeX should load T1. Other scripts use other encodings, for example T2A for Cyrillic.

Main commands

\usepackage[T1]{fontenc}Makes T1 the encoding of the document.
\usepackage[T2A,T1]{fontenc}Loads several encodings; the last one is the default.
\fontencoding{T1}\selectfontSwitches the encoding inside the document. babel does this by itself when the language changes.
\textless, \textgreater, \textbarPrint <, > and | in text in any encoding, including OT1.

Complete example

\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
With T1 the characters < and > and | print as typed.

Words with accents, such as Größenverhältnisse or différemment, consist
of single characters of the font. LaTeX can hyphenate them, and a search
in the PDF finds them.
\end{document}
Result
The compiled example

Open in the editor

Compiled with pdfLaTeX from TeX Live 2023.

Pitfalls

Related pages