28

How do I enter Unicode characters in LaTeX? What packages do I need to install and what escape sequence do I type to specify Unicode characters in an ASCII source file?

27

"Unicode" in this context could mean either in the input or in the output. I assume you're looking to insert something like "" into your source and have it do something meaningful.

For full support for unicode input and unicode fonts, take a look at XeTeX; it's easy to get started ? just select an appropriate font and the unicode characters in your input are directly typeset as unicode glyphs in the output. Switching engines is not always a possibility, however, and sometimes you'll want to stick with pdfTeX for its other useful features.

The best that regular LaTeX (i.e., based from pdfTeX in a modern distribution) can do is recognise UTF-8 sequences in the text and expand macros based on what it sees. Load the inputenc package to select the UTF-8 input encoding:

\usepackage[utf8]{inputenc}

(You can also use the [utf8x] option which has more extensive coverage but is not as well supported. I don't have any experience using this option.)

To define behaviour for unicode characters, use the \DeclareUnicodeCharacter command that is then defined. Here's an example for binding the control sequence \dash to the input character "?"; i.e., a literal em-dash, U+2014, in the source:

\DeclareUnicodeCharacter{2014}{\dash}

\dash can then be defined in the usual manner; I use:

\DeclareRobustCommand\dash{%
  \unskip\nobreak\thinspace\textemdash\allowbreak\thinspace\ignorespaces}

This defines a dash that has a small space on either side and will only allow a line break after it.

17 accepted

Have you considered using XeTeX? This is an adaptation of TeX that adds Unicode support, and is included in the latest TeX Live and MiKTeX distributions. This Wikipedia article gives a good introduction.

4

This is a minimal example that finally worked for me without using XeTeX:

\documentclass{minimal}
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}

\begin{document}
    The vorticity $?$ is defined as $? = ?  u$.
\end{document}
2

In this post I describe a way to use Greek Unicode letters in Latex. It could give you some hints for working around your problem with standard Latex.

0

Sorry, I'm not an expert on this, but hope I can at least provide some useful leads.

A lot of the early multi-lingual support for LaTeX predates the widespread adoption of Unicode, although it looks like there's been some consolidation around Unicode recently. So you might find something useful in specific language support packages, e.g. CJK LaTeX (for Chinese, Japanese and Korean).

It looks like one Unicode package for LaTeX is no longer supported, although it may still be the best thing out there.

You might also have a look at the excellent book The LaTeX Companion, which includes a section on multilingual text.

0

Unfortunately Latex doesn't directly do the unicode thing. The closest you get are language or encoding specific packages and tools to produce characters outside of the ASCII character set.