[Tex/LaTex] Error: Unicode char \u8:φ not set up for use with LaTeX

unicode

I have the following LaTeX document, saved in the UTF-8 character set encoding:

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
φΔδ汉
\end{document}

(it has 3 Greek characters followed by a Chinese one.) When I try to compile it, I get the following error:

$ latex foo
This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010)
restricted \write18 enabled.
[...]
! Package inputenc Error: Unicode char \u8:φ not set up for use with LaTeX.

How can I use these and other characters, in UTF-8 encoded .tex files?

Note: This and this look like duplicates but they are slightly different and don't answer my question.

Best Answer

The inputenc package, even with the utf8 option doesn't load all the Unicode tables. It loads only those for which it knows it will have to typeset some glyphs.

You have then to teach the proper environment, because each Unicode block requires a different TeX fonts (they have only 256 characters).

So your example works with pdflatex, but modified into the following code.

\documentclass{article}
\usepackage[LGRx,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}
\usepackage{CJKutf8}
\begin{document}

\foreignlanguage{greek}{φΔδ}\begin{CJK}{UTF8}{gbsn}汉\end{CJK}

\end{document}

This is admittedly largely impractical for extensive usage of characters belonging to different blocks, so it may be advisable to switch to XeLaTeX or LuaLaTeX that can use OpenType fonts.

enter image description here

Important update

After release of Babel version 3.9, the LGRx encoding should not be used any more. Now LaTeX is able to interpret correctly UTF-8 characters for Greek out of the box, provided the Greek language is loaded with babel. So the example above becomes

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}
\usepackage{CJKutf8}
\begin{document}

\foreignlanguage{greek}{φΔδ}\begin{CJK}{UTF8}{gbsn}汉\end{CJK}

\end{document}