2

I switched from LaTex to LuaLaTex. This is my basic preamble:

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{lmodern}

For some reason, with LuaLaTex charakters like ß are displayed as SSand the german glyphs / quotation marks are displayed wrong. I still don't exactly know how to print these symbols. Sometimes I stumbled over "' or '' (cant even display these symbols correctly in this editor). With LaTex the notation ,, / '' did work so far, but it does not with LuaLaTex.

Is there some recommenced general robust way to do this, that works with LaTex and LuaLaTex without fiddeling around and will not create other side-effects?

9
  • 6
    inputenc and fontenc shouldn't be used in LuaTeX and XeTeX. Commented Jun 20, 2019 at 13:21
  • 1
    don't use lmodern either. Commented Jun 20, 2019 at 13:26
  • 3
    See tex.stackexchange.com/a/470987/2388 why fontenc can be a problem with luatex. Commented Jun 20, 2019 at 13:27
  • 4
    Because these packages are work-arounds to have an 8-bit engine, like pdfTeX, understand multi-byte encodings, like utf8. XeTeX and LuaTeX are unicode aware engines, so these packages do nothing at best. At worst they make special characters not work, like what you're seeing. Removing those packages solves the issue for me. Commented Jun 20, 2019 at 13:28
  • 3
    The babel manual provides some explanations on how to use it with lualatex (sec. 1.4). Commented Jun 20, 2019 at 13:33

1 Answer 1

6

As the comments to you query have pointed out, one should not load the fontenc and inputenc packages when using LuaLaTeX. Instead, get used to working with the fontspec package. Or, if your document has math-y parts, load the unicode-math package, which loads fontspec automatically.

Modifying the preamble as shown below lets you go back and forth between pdfLaTeX and LuaLaTeX. This may be the way to go for you until you've fully settled on LuaLaTeX.

enter image description here

The preceding screenshot is the result of compiling the following test document with LuaLaTeX. Observe the use of the ß character for both lowercase and uppercase. Compiling the same document under pdfLaTeX produces a nearly-identical result, except that it produces SS as the uppercase variant of ß for both the roman and the sans-serif font shape, and nothing at all for the monospaced font shape.

\documentclass{article} % or some other suitable document class

\usepackage[ngerman]{babel}
\usepackage{amsmath,amssymb} % no need to load 'amsfonts' explicitly
\usepackage{graphicx}

\usepackage{ifluatex}
\ifluatex
   \usepackage{unicode-math}
   \setmainfont{Latin Modern Roman}
   \setsansfont{Latin Modern Sans}
   \setmonofont{Latin Modern Mono}
   \setmathfont{Latin Modern Math} 
\else % pdflatex
   \usepackage[utf8]{inputenc}
   \usepackage[T1]{fontenc}
   \usepackage{lmodern}
\fi

\begin{document}
äöü ÄÖÜ ß \MakeUppercase{ß}

\textsf{äöü ÄÖÜ ß \MakeUppercase{ß}}

\texttt{äöü ÄÖÜ ß \MakeUppercase{ß}}
\end{document}
1
  • 1
    Excellend answer. Thanks! Commented Jun 20, 2019 at 14:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .