9

So what I am trying to do is to use the letter-classic class with LuaLaTeX (This is LuaTeX, Version beta-0.80.0 (MiKTeX 2.9) (rev 5238) (format=lualatex 2015.11.10) 25 NOV 2015 09:30) as included in MikTeX.

It bombs in icelandic.ldf with errors like these:

! String contains an invalid utf-8 sequence.
l.144 \DeclareTextCommand{\ooob}{T1}{\sob {
                                         ó}{.85}{0}{.04}{0}}
A funny symbol that I can't read has just been (re)read.
Just continue, I'll change it to 0xFFFD.

! String contains an invalid utf-8 sequence.
l.145 \DeclareTextCommand{\OOob}{T1}{\sob {
                                         Ó}{.7}{0}{0}{0}}
A funny symbol that I can't read has just been (re)read.
Just continue, I'll change it to 0xFFFD.

! String contains an invalid utf-8 sequence.
l.148 \DeclareTextCommand{\eeob}{T1}{\sob {
                                         é}{1}{0}{.04}{0}}
A funny symbol that I can't read has just been (re)read.
Just continue, I'll change it to 0xFFFD.

! String contains an invalid utf-8 sequence.
l.149 \DeclareTextCommand{\EEob}{T1}{\sob {
                                         É}{1}{0}{.04}{0}}
A funny symbol that I can't read has just been (re)read.
Just continue, I'll change it to 0xFFFD.

! String contains an invalid utf-8 sequence.
l.152 \declare@shorthand{icelandic}{"
                                   ó}{\ooob}
A funny symbol that I can't read has just been (re)read.
Just continue, I'll change it to 0xFFFD.

! String contains an invalid utf-8 sequence.
<argument> icelandic@sh@\string "@\string �
                                  \ooob @
l.153 \declare@shorthand
                      {icelandic}{"Ó}{\OOob}
A funny symbol that I can't read has just been (re)read.
Just continue, I'll change it to 0xFFFD.

My minimal working example is this one:

\documentclass[english,12pt,a4paper]{letter-classic}
\usepackage[T1]{fontenc}
\usepackage[icelandic,german,english]{babel}
\selectlanguage{english}
\newcommand{\ISL}[1]{\foreignlanguage{icelandic}{#1}}
\newcommand{\DEU}[1]{\foreignlanguage{german}{#1}}
%%\usepackage[utf8]{inputenc} % needed with pdfLaTeX, but not with LuaLaTeX (see comment below question)

\begin{document}

\begin{letter}{Troll family\\\ISL{Elliðaárdalur}\\\ISL{999 Reykjavík}\\ICELAND}
\fromname{\DEU{Mäxchen Mustermann}}
\fromstreet{\DEU{Musterstraße 123}}
\fromtown{12345 Musterstadt}
\fromphone{+49 123 4567890}
\fromtownshort{Musterstadt}
\fromsignature{\DEU{Mäxchen}}

\subject{\ISL{Jólasveinar}}
\opening{Folks,}

do you know the current address of the \ISL{Jólasveinar} and/or their parents \ISL{Grýla} and \ISL{Leppalúði}?

\closing{\ISL{Með kveðju,}}
\end{letter}

\end{document}

The actual document worked without problems until a few months ago, using pdfLaTeX (and still does, see below).

How it looks when rendered with pdfLaTeX.

Can anyone explain to me how to mix Icelandic and German using LuaLaTeX with the letter-classic class?


I looked into the KOMA letter class already, but I prefer a slightly more modern/custom look for the letter head, such that at this moment I really want to avoid that one.

  • You mustn't use inputenc with LuaLaTeX. But, unfortunately, icelandic-babel is not compatible with LuaLaTeX. – egreg Nov 25 '15 at 9:53
  • @egreg: even when taking that line out, I get the same errors ... obviously pdfLaTeX now shows me the individual bytes of the UTF-8 codepoints I am using. But LuaLaTeX simply gives the same errors after commenting out that line. – 0xC0000022L Nov 25 '15 at 9:57
  • Simple solution: Don't use babel. Take care of hyphenation by hand. – Johannes_B Nov 25 '15 at 10:13
  • @Johannes_B: well babel appears to do something more than merely hyphenation. Without it I could not mix Icelandic and German characters in the same document and have them rendered correctly. – 0xC0000022L Nov 25 '15 at 11:12
  • 2
    Of course you can: \documentclass{article} \usepackage{fontspec} \begin{document} ä ß Elliðaárdalur \end{document} – Johannes_B Nov 25 '15 at 11:37
13

The problem is not in mixing Icelandic and German. A smaller example shows the issue in all document classes.

\documentclass{article}
\usepackage[icelandic]{babel}

\begin{document}

Test

\end{document}

Running this through LuaLaTeX produces the same error you see (and similar ones later on):

! String contains an invalid utf-8 sequence.
l.144 \DeclareTextCommand{\ooob}{T1}{\sob {
                                         ?}{.85}{0}{.04}{0}}
? 

Unfortunately, the file icelandic.ldf loaded by babel hardcodes four Latin-1 characters to be used for shorthands in

"Ó "ó "É "é

and, when LuaTeX is reading the file, it chokes on that invalid input. XeTeX is more forgiving in this respect and doesn't choke.

As it stands, babel-icelandic is not compatible with LuaLaTeX and there's no workaround, as far as I can see, except writing a modified icelandic.ldf file.

Lines 142 to 157 should be

142 \DeclareTextCommand{\oob}{T1}{\sob {o}{.85}{0}{.04}{0}}
143 \DeclareTextCommand{\Oob}{T1}{\sob {O}{.7}{0}{0}{0}}
144 \DeclareTextCommand{\ooob}{T1}{\sob {^^f3}{.85}{0}{.04}{0}}
145 \DeclareTextCommand{\OOob}{T1}{\sob {^^d3}{.7}{0}{0}{0}}
146 \DeclareTextCommand{\eob}{T1}{\sob {e}{1}{0}{.04}{0}}
147 \DeclareTextCommand{\Eob}{T1}{\sob {E}{1}{0}{.04}{0}}
148 \DeclareTextCommand{\eeob}{T1}{\sob {^^e9}{1}{0}{.04}{0}}
149 \DeclareTextCommand{\EEob}{T1}{\sob {^^c9}{1}{0}{.04}{0}}
150 \declare@shorthand{icelandic}{"o}{\oob}
151 \declare@shorthand{icelandic}{"O}{\Oob}
152 \declare@shorthand{icelandic}{"^^f3}{\ooob}
153 \declare@shorthand{icelandic}{"^^d3}{\OOob}
154 \declare@shorthand{icelandic}{"e}{\eob}
155 \declare@shorthand{icelandic}{"E}{\Eob}
156 \declare@shorthand{icelandic}{"^^e9}{\eeob}
157 \declare@shorthand{icelandic}{"^^c9}{\EEob}

Changes are in the lines where ^^ appears; I added the line numbers for convenience.

A bug report should be filed to the maintainer of babel.

  • There's an address listed in texdoc.net/texmf-dist/doc/generic/babel-icelandic/icelandic.pdf – egreg Dec 7 '15 at 20:40
  • email bounced. will try alternative route. – 0xC0000022L Dec 7 '15 at 22:20
  • 1
    @0xC0000022L With today's update of babel-icelandic some of the problems have been solved, but others arose. :-( For instance you can't use it in LuaTeX without fontspec; and the characters with the ogonek are typeset wrongly. – egreg Dec 31 '15 at 11:46
  • @egreg Please, could you report a bug with a MWE? – Javier Bezos Jan 12 '16 at 15:01
  • @JavierBezos Hasn't this been solved with the recent update? – egreg Jan 12 '16 at 15:05
7

As a work-around you could switch locally to ansinew reading with luainputenc: (edited a bit to reset the catcodes afterwards and also removed the write call back so that the toc now contains again real utf8).

\documentclass{article}
\usepackage{fontspec}
\usepackage{luatexbase} %not needed now, but probably in the future.
\PushCatcodeTableNumStack
\usepackage[ansinew]{luainputenc}
\usepackage[icelandic]{babel}
\PopCatcodeTableNumStack

\directlua{luatexbase.remove_from_callback('process_input_buffer', 'luainputenc.fake_utf_read')
           luatexbase.remove_from_callback('process_output_buffer','luainputenc.fake_utf_write')
           luainputenc.state = stopped}
\begin{document}

\tableofcontents
\section{öäüß}
äöüß €
 ólasveinar Grýla Leppalúði
\end{document}

But it is quite possible that some other things in icelandic.ldf are not suitable to luatex and then you will have to adapt more.

enter image description here

6

Why not use polyglossia? I don't have letter-classic, but here is similar version in letter:

Sample

\documentclass{letter}

\usepackage[T1]{fontenc}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguages{icelandic,german}

\newcommand{\ISL}[1]{\texticelandic{#1}}
\newcommand{\DEU}[1]{\textgerman{#1}}

\begin{document}

\begin{letter}{Troll family\\\ISL{Elliðaárdalur}\\\ISL{999 Reykjavík}\\ICELAND}
\name{\DEU{Mäxchen Mustermann}}
\address{\DEU{Musterstraße 123}\\
12345 Musterstadt}
\telephone{+49 123 4567890}
\signature{\DEU{Mäxchen}}

\opening{Folks,}

\begin{center}
  \ISL{Jólasveinar}
\end{center}

Do you know the current address of the \ISL{Jólasveinar} and/or their parents \ISL{Grýla} and \ISL{Leppalúði}?

\closing{\ISL{Með kveðju,}}
\end{letter}

\end{document}

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.