5

Consider a LaTeX document with the minimal configuration necessary to support UTF-8 characters — as I understand it, such a document would look like this:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
Text goes here.
\end{document}

In such a document, what Unicode characters does pdfLaTeX recognize & support? Is it just the characters belonging to the T1 encoding (which apparently looks like this)? Is it a function of the current font? Is it a built-in ad hoc list that tends to expand with new LaTeX/pdfTeX/pdfLaTeX releases?

This answer tells me that the characters are defined in t1enc.dfu (and/or utf8enc.dfu?), but I'm interested in a more intensional, not extensional, answer.

  • 2
    Please clarify what you take to be “LaTeX”: pdfLaTeX only? Or XeLaTeX and LuaLaTeX as well? – Mico Jul 27 at 4:14
  • @Mico: For the purposes of this question, I'm only interested in pdfLaTeX (though an answer covering all three would save me some time). – jwodder Jul 27 at 4:17
  • XeTeX and LuaTeX fully support UTF-8 (LuaTeX will in fact reject your input file if it is not UTF-8). That means that all UTF-8 character are supported, however, whether they can be displayed is up to whether they are mapped in the font that you load. This is outside of TeX's control, but good candidates for a broad coverage of Unicode are the DejaVu and Noto families of fonts. – Henri Menke Jul 27 at 4:21
  • 3
    You already linked to the answer that lists all the UTF-8 character that are defined by pdflatex. What else are you looking for here? – Henri Menke Jul 27 at 4:34
  • 1
    The T1 font encoding is very limited. It can only map 256 glyphs. The ASCII range is mapped directly and there is no additional work necessary for these because ASCII is a strict subset of UTF-8. Other glyphs have to be mapped, like œ has to be mapped to \oe which in turn is mapped to the font. Then there are those glyphs that are not mapped by the font but are still representable, like Ž as \v Z which is the Latin capital Z overlayed with a caron accent. Both Z and the caron are independent characters in the font. – Henri Menke Jul 27 at 4:52
7

A current LaTeX format will input omsenc.dfu, ot1enc.dfu, t1enc.dfu and ts1enc.dfu (this is new in a current latex compared to the answer you linked too).

You can find all four files in tex/latex/base and check which unicode input they support. As the names imply their support range is related to output encodings but can there is no strict 1-1 relationship. t1enc.def e.g. contains also \DeclareUnicodeCharacter{00A0}{\nobreakspace}.

It is not needed with a current latex to load inputenc. utf8 is the default anyway. So you get this support also with this document:

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

\begin{document}
Text goes here.
\end{document}
| improve this answer | |
  • Do you know what the rationale is for loading omsenc.dfu and ts1enc.dfu? I can see why ot1enc.dfu (the default encoding) and t1enc.dfu (the requested encoding) would be loaded, but I don't see why the other two and no others would be. – jwodder Jul 27 at 15:51
5

Your question is rather undefined as "minimal preamble" can be interpreted to mean "the minimal required to support the Unicode Characters needed" which is somewhat circular.

The example preamble posted produces the following if I add Cyrillic text

! Package inputenc Error: Unicode character П (U+041F)
(inputenc)                not set up for use with LaTeX.

As Cyrillic codepoints are not set up by default, but independent of the input encoding they would not typeset anyway as T1 font encoding is specified, which only covers Latin alphabet.

You do not need inputenc in current latex as UTF-8 is the default, and if you specify a font encoding such as X2 that includes Cyrillic, suitable Unicode mappings will be loaded x2enc.dfu which is in the base latex distribution.

So this runs without error:

\documentclass{article}
\usepackage[T1,X2]{fontenc}
\begin{document}
{\fontencoding{T1}\selectfont Text goes here}. Привет
\end{document}

The file /usr/local/texlive/2020/texmf-dist/tex/latex/base/utf8enc.dfu (use kpsewhich utf8enc.dfu to find the file on your local system) lists all the characters declared in encoding dfu files in the base distribution but contributed packages may add more.

grep '[.]dfu' `kpsewhich --all ls-R`

will list all the ones available, as well as the core latin Greek and Cyrillic encodings I see armglyphs.dfu pmboxdrawenc.dfu otf-hangul.dfufor example.

Basically the restriction is not on the interpretation of UTF-8. Pdflatex's inputenc code understands the full UTF-8 encoding and so you can specify any Unicode number. But a font in pdflatex can only have 256 characters so most Unicode characters can not be defined until you specify a font to cover the required character set.

If you have a font that covers a Unicode range; the matching inputenc mapping probably already exists (and will be input automatically for any font encoding declared in the preamble) or can easily be added.

| improve this answer | |

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.