Sunday, September 16, 2012

Umlaute not working in lualatex/making unicode work

This is a problem, that has confused us about a year ago. Lualatex claims to have the inputlanguage set to utf8, still i couldn't enter umlaute äüöß into the document. They were always eaten up or so it seems.
What really confused me was, that it worked as soon as i used \usepackage[utf8]{luainputenc}. It also started working without the inputenc if i set the fontenc to T1. This seemed to make no sense at all.

What usually happens is: if you enter a char into the document that char is converted to unicode (conceptually, i don't think it's literally done that way), and then replaced by the glyph corresponding to that point in the output.
This isn't quite so with  some chars, umlauts being one example. They are often constructed as an accent (the ") on top of the normal char, so both packages activate a mechanism that replaces these by composited chars, ä by \"{a} for example. This magic is all done by fontenc and inputenc loads fontenc! If fontenc isn't loaded in some way, the character is output unchanged and the font doesn't have that symbol, so it omits it!

If the font happens to sport the symbol, → comes to mind, then it may or may not look different, because it isn't made up of several parts. If you want the best of both worlds you could either
  • use the ucs package which requires knowing the code point
  • use DeclareUnicodeCharacter{<unicode>}{<replacement>} which of course requires knowing the code point as well
  • make it active and redefine it.
    \catcode`\→=13
    \let→{\rightarrow}
If you don't know the code point, just google it, or use something like http://www.utf8-chartable.de/

No comments:

Post a Comment