I want to put the following phrase into a book.

Khabarovsk (Russian: Хабаровск)
is located 30 kilometers (19 mi) 
from the Chinese border.

The source is NOT UTF-8 and I don't have the option to make it UTF-8. I want to enter the Russian characters in a robust way that will not be distorted when the file is transferred between different people, and so I am limited to ASCII.

I have entered this:

Khabarovsk (Russian: \char"0425 \char"0430 \char"0431 \char"0430 
\char"0440 \char"043E \char"0432 \char"0441 \char"043A )
is located 30 kilometers (19 mi) 
from the Chinese border.

This works in XeLaTeX (which is what I am using). Is this really the best way to enter these Unicode character code-points into LaTeX source?

Is there a standard way to specify a Unicode character that will work across all versions of LaTeX? If not, any comments on why there is no such standard notation for this? I am just trying to understand where all this is going.


Let me expand upon the excellent answer given by David Carlisle below. The caret notation would be like this:

Khabarovsk (Russian: 
is located 30 kilometers (19 mi) 
from the Chinese border.

This is superior for a number of reasons:

  1. The \char form 'eats' a space after the command (the way TeX normally does) and that means that if you want a space, you have to do something special, like put an extra slash-space (standard TeX command behavior). The caret notation is exactly like a character: put a space between them and that space works like a space between characters.
  2. This conversion is done at the initial parsing level, which means these characters can be used for anything in TeX, including spelling of commands. They simply represent characters in the input stream for any purpose.
  3. David implied that the \char notation might be picking a code point in a font. I suppose most fonts use Unicode so this might or might not be a problem, but in any case using the caret notation allows the character to be processed by all the following logic exactly as if you typed the character into the source file.
  4. The notation is slightly more compact: 8 characters instead of 10.

Only note: the hex digits MUST use lower case letters. I don't know for sure, but I assume this only works on XeTeX and variants of that.

See further discussion at blog post on Adding Unicode Characters to LaTeX documents


It's probably better to use ^^^^043a which produces a character token, rather than use \char"043A which is a non expandable primitive accessing a font position. The character token is usable in more contexts (such as writing to tables of contents) and generally has less restrictions than \char.

the ^^^^ notation (and \char"043A) will work in luatex or xetex, neither work in pdftex which can not access slots above "FF To use unicode naturally in pdftex you really want to use utf8 encoding and inputenc.

  • 1
    Thanks for the pointer to quad-^ notation. I saw double-^ notation mentioned elsewhere, but I have not been able to find documentation on it. How does the syntax work: is it exactly 4 hex digits following it? I also am not familiar with the " and how that works. Where could I look up more on this? – AgilePro Apr 6 '15 at 1:34
  • 1
    @AgilePro Four ^ want four hexadecimal digits (with a-f lowercase); five want five and six want six. – egreg Apr 6 '15 at 8:45

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.