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}\selectfont | Switches the encoding inside the document. babel does this by itself when the language changes. |
\textless, \textgreater, \textbar | Print <, > 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}Compiled with pdfLaTeX from TeX Live 2023.
Pitfalls
- With
T1and the default Computer Modern family, LaTeX uses the EC fonts. If the installation has them only as bitmaps, the text looks blurred on screen. Loadlmodernor another font package to get vector fonts. - Do not load
fontencwith LuaLaTeX or XeLaTeX. These engines use Unicode fonts throughfontspec. - An encoding name that LaTeX does not know stops with Encoding scheme `t1' unknown.
Related pages
- How-to Umlauts and accents in LaTeX
- How-to Hyphenation in LaTeX
- Package
lmodern - Package
inputenc - Error Encoding scheme `t1' unknown
- How-to Inline code in LaTeX
- How-to Write a letter in LaTeX
- How-to Write a CV in LaTeX
- How-to Set up a thesis in LaTeX
- How-to Create an exercise sheet or exam in LaTeX