23.7 inputenc package

Synopsis:

\usepackage[encoding-name]{inputenc}

Declare the input file’s text encoding to be encoding-name. (For basic background, see Input encodings). The default, if this package is not loaded, is UTF-8. Technically, specifying the encoding name is optional, but in practice it is not useful to omit it.

The inputenc package tells LaTeX what encoding is used. For instance, the following command explicitly says that the input file is UTF-8 (note the lack of a dash).

\usepackage[utf8]{inputenc}

The most common values for encoding-name are: ascii, latin1, latin2, latin3, latin4, latin5, latin9, latin10, utf8.

Caution: use inputenc only with the pdfTeX engine (see TeX engines); with xelatex or lualatex, declaring a non-UTF-8 encoding with inputenc, such as latin1, will get the error inputenc is not designed for xetex or luatex.

An inputenc package error such as Invalid UTF-8 byte "96 means that some of the material in the input file does not follow the encoding scheme. Often these errors come from copying material from a document that uses a different encoding than the input file. The simplest solution is often to replace the non-UTF-8 character with a UTF-8 or LaTeX equivalent.

If you need to process a non-UTF-8 document with LuaTeX, you can use the luainputenc package (https://ctan.org/pkg/luainputenc). With XeTeX, the \XeTeXinputencoding and \XeTeXdefaultencoding primitives can be used (for an explanation and examples, see https://tex.stackexchange.com/questions/324948).

It’s also possible to re-encode a document from an 8-bit encoding to UTF-8 outside of TeX, using system utilities. For example, ‘recode latin1..utf8’ or ‘iconv -f latin1 -t utf8’.

In a few documents, such as a collection of journal articles from a variety of authors, changing the encoding in mid-document may be necessary. You can use the command \inputencoding{encoding-name} for this.


Unofficial LaTeX2e reference manual