# No simple UTF8 support in latex?

The following should look good in your browser, AND compile in Latex looking beautiful right?

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
UTF-8 test:
\begin{verbatim}
logic:  not:¬
and: ∧  nand:⊼
or: ∨   nor:⊽
inequal to, xor:≢,≠,⊻,⊕     equal to: ≡,=
Set logic:  ∪,∩,⊊,⊋,⊆,⊇,⊈,⊉,≡
avoid useage of non-specific: ⊂,⊃,⊄,⊅
Set Membership:∈,∉,∌,∋,∅
assignment ≔≕
predicate logic:∃,∄,∀,∴,∵
regex: /|\.⋆^?+(){,}[]
Arrows: ↖↑↗⇖⇑⇗
←↔→⇐⇔⇒⇕↕
↙↓↘⇙⇓⇘
↚↮↛⇍⇎⇏
numbers:ℕatural={0,1,2,3, … ∞}, ℤintegers,
ℚ=rational, ¬ℚ=irrational,
ℝeal, ±∞, ℂomplex
size: ≤,≥,<,>,≮,≯,≰,≱,≪,≫,≢,≠,≡,=
Greek Alphabet:
ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣ ΤΥΦΧΨΩ
αβγδεζηθικλμνξοπρσςτυφχψω
Game:
Chess symbols:♚♛♜♝♞♟♔♕♖♗♘♙
Playing card symbols:♠♣♥♦ 23456789JQKA
miscellaneous:°∙■□▪▫○●☇
\end{verbatim}
\end{document}

Currently(2010 Dec 12 with latest ubuntu with all updated packages) I get the following error:

! Package inputenc Error: Unicode char \u8:**"insert random char here"** not set up for use with LaTeX.

-
@GlassGhost: If you rewrote your question without such an accusative tone (as seen especially in your last comment), people would probably be more willing to help out. TeX can certainly be frustrating, but there's no reason to take that out on the community. –  Antal S-Z Dec 12 '10 at 20:08
@GlassGhost I challenge you to find a better method than TeX/LaTeX to produce a paper as beautiful as arxiv.org/PS_cache/arxiv/pdf/1007/1007.3722v3.pdf and as easy as using LaTeX (including the interactivity on the fig 3). If you want to typeset beautiful documents you found the right community to help you. If you want to type something that is ugly, typographically wrong and mediocre you can buy Word, hey you can even use the arial font. –  Yiannis Lazarides Dec 12 '10 at 20:20
@GlassGhost: I believe I speak for most of us when I say that we do not appreciate the thinly veiled sarcasm and a certain note of entitlement in your comments. The community is happy to help anybody who comes around with a question, even those of the LMGTFY variety. But you need to show a certain degree of respect for people who spend their (free) time answering your questions. –  Martin Tapankov Dec 12 '10 at 22:28
@Martin: (slightly off topic), I'm now glad that I googled LMGTFY myself, instead of asking you what that stood for. –  Willie Wong Dec 13 '10 at 18:14
I don’t see any veiled sarcasm or accusative tone. And yes, it sucks that TeX is oblivious of Unicode, twenty years after the fact. So just to offer a different opinion, I’m completely fine with the question as-is. –  Konrad Rudolph Dec 13 '10 at 20:20

The original TeX engine wasn't designed to handle multi-byte encodings. So any package that provides Unicode functionality on top of that has to be imperfect. There are however two new engines that do provide full Unicode support: LuaTeX and XeTeX. There is also a package that makes it easy to select any OpenType or TrueType font for use with these engines: fontspec. (There is also unicode-math which provides support for Unicode-aware math fonts like STIX (or XITS) and Cambria Math, but it is still in heavy development and not quite complete yet.)

Be aware that the version of these engines and packages shipped with Ubuntu 10.10 (and earlier) are very outdated. If you want to use them, you have to manually install TeX Live 2010 (which is easy).

After you have updated, you can use lualatex or xelatex to compile the following code:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{FreeSerif}
\setmonofont{FreeMono}

\begin{document}
\begin{verbatim}
\end{verbatim}
\end{document}

This sets FreeSerif as the main font (Free Serif isn't the most beautiful font, but I do not know any other free font that rivals it in Unicode coverage; it comes preinstalled with Ubuntu -- in fact your browser probably uses it to display the symbols) and FreeMono as the monospace font (Free Mono lacks the chess symbols and diagonal implication arrows, but provides everything else in your example; Free Serif would provide everything but isn't monospace). Another free font family with good Unicode coverage is DejaVu, which as based on Bitstream Vera. The compiled document looks as follows:

You could of course replace \setmonofont{FreeMono} by \setmonofont{FreeSerif}. Then your verbatim text wouldn't be monospaced anymore, but would contain all symbols. See the fontspec manual for other fancy things that are possible.

If you are writing a text that mixes several languages and scripts then a single font will probably not cover all possible symbols. In this case the polyglossia package will come in handy (it currently only works with XeLaTeX).

-
your answer seems to be the best, if you remove that giant image from it, I'll mark it as accepted. Also I thought that UTF8 or Unicode supports most languages, is this not true? –  GlassGhost Dec 12 '10 at 22:00
@GlassGhost: It does, but most fonts only implement a tiny subset. So if you want to mix say Chinese and Arabic text, you will need a font that has Chinese characters and a font that has Arabic characters. It is rather unlikely that you will find a good font that has both of them. –  Caramdir Dec 12 '10 at 22:18
@GlassGhost: If you rewrite your question to be more concise and less accusing, I will remove the picture. –  Caramdir Dec 12 '10 at 22:19
@Caramdir: I think the image proves the concept and should stay. Don't sacrifice useful information for 15 rep points. –  Matthew Leingang Dec 13 '10 at 1:23
@Matthew I won't. However, if the question is formulated more concisely with a smaller example, I will adapt the image to the question. Most of the example symbols are math symbols which should be set in math mode, so actually the image could be slightly misleading. –  Caramdir Dec 13 '10 at 1:44
show 1 more comment

inputenc with option utf8 knows definitions only for a subset of unicode. And from this subset it will only load a small subset as default. If you want more definitions you should load the corresponding font encodings. If you want full unicode support use a unicode enabled engine like xetex or luatex (but I have some doubt that you will find many fonts with chess support).

-

For Unicode support, you need to use XeTeX. It supports using UTF-8 encoded files by default. The Wikipedia page on XeTeX is also useful.

-
Or LuaTeX, see my answer. It supports UTF-8 encoded documents also by default. –  topskip Dec 12 '10 at 20:12

Here is your example which can be compiled using XeTeX or LuaTeX. Deja Vu Sans Mono contains all occurring characters except for nand, nor and xor:

\documentclass{article}
\usepackage{fontspec}
\setmonofont{DejaVu Sans Mono}
\begin{document}
\begin{verbatim}
°±∞∙■□▪▫○●
Set Membership:∈,∉,∌,∋,∅
Set logic:
∪,∩,⊊,⊋,⊆,⊇,⊈,⊉,≡
avoid but don't be frightened of usage of non-specific: ⊂,⊃,⊄,⊅
assignment≔≕
logic:
and: ∧
nand:⊼
or: ∨
nor:⊽
not:¬
inequal to, xor:≢,≠,⊻,⊕
equal to: ≡,=
size: ≤,≥,<,>,≮,≯,≰,≱,≪,≫
regex: ⋆
predicate logic:∃,∄,∀,∴,∵
numbers:
ℂomplex
ℝeal
ℚ=rational
¬ℚ=irrational
ℤintegers
ℕatural={0,1,2,3,
Arrows:
↖↑↗⇖⇑⇗
←↔→⇐⇔⇒⇕↕
↙↓↘⇙⇓⇘
↚↮↛⇍⇎⇏

Greek Alphabet:
ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣ ΤΥΦΧΨΩ
αβγδεζηθικλμνξοπρσςτυφχψω

Game:
Chess symbols:♚♛♜♝♞♟♔♕♖♗♘♙
Playing card symbols:♠♣♥♦ 23456789JQKA
\end{verbatim}
\end{document}
-

Use this:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Arial Unicode MS}
\begin{document}
... (your font list, but not verbatim, because arial is not a typewriter font) ...
\end{document}

with lualatex. There you go.

You will need a proper unicode font though.

-