The inputenc package

Tells pdfLaTeX in which encoding the source file is saved. \usepackage[utf8]{inputenc} has been the default since 2018 and is no longer needed.

Loading the package

\usepackage[utf8]{inputenc}

Since the LaTeX release of April 2018, pdfLaTeX reads source files as UTF-8 without any package. The line \usepackage[utf8]{inputenc} in older templates does no harm and matters only when the document has to compile on an installation from before 2018.

The package is still needed for a file saved in an older 8-bit encoding such as latin1 (ISO 8859-1) or cp1252 (Windows). Name that encoding in the option, or convert the file to UTF-8 and drop the package.

LuaLaTeX and XeLaTeX read UTF-8 themselves. They ignore the package with a warning.

Main commands

\usepackage[utf8]{inputenc}Source file in UTF-8; the default since 2018.
\usepackage[latin1]{inputenc}Source file in ISO 8859-1.
\inputencoding{latin1}Changes the encoding inside the document, for example before an \input of an old file.
\DeclareUnicodeCharacter{2264}{\ensuremath{\leq}}Defines what a Unicode character prints, given by its hexadecimal code point. It belongs to the LaTeX kernel and works without the package.

Complete example

\documentclass{article}
\usepackage[utf8]{inputenc} % only needed for LaTeX before 2018
\usepackage[T1]{fontenc}
\DeclareUnicodeCharacter{2264}{\ensuremath{\leq}}
\begin{document}
Umlauts and accents are typed directly: ä, ö, ü, ß, é, ñ, ç.

A character that LaTeX does not know needs a definition: 3 ≤ 5.
\end{document}
Result
The compiled example

Open in the editor

Compiled with pdfLaTeX from TeX Live 2023.

Pitfalls

Related pages