2

The following .tex source file has been working fine for me for decades using pdflatex:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{t1enc}
\usepackage{lmodern}
\def\myhelvetica{\fontfamily{phv}\selectfont}
\begin{document}
\hrule
{\Huge Helló, Wörld, árvíztűrő}
\hrule
{\Huge Helló, Wörld, árvízt\H{u}r\H{o}}
\hrule
{\myhelvetica\Huge Helló, Wörld, árvíztűrő}
\hrule
\end{document}

The good output of pdflatex looks like:

good output of pdflatex

The bad output of lualatex (the 1st line is shorter) looks like:

bad output of lualatex

How do I fix it for lualatex without using Unicode fonts, TrueType fonts, OpenType fonts or \usepackage{fontspec}?

I'm using these on Linux:

  • pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian)
  • LuaTeX, Version 1.07.0 (TeX Live 2019/dev/Debian)
  • It is my understanding that the font handling from pdfLaTeX can't or shouldn't be used in LuaLaTeX. In particular lmodern (and probably t1enc) are out in LuaLaTeX. And if you want to change the font in LuaLaTeX Open Type and fontspec are what you would use. So if you exclude that, there is not a lot (nothing?) left for you to use. – moewe Jan 10 at 15:37
  • 1
    @egreg: Which feature of which package breaks exactly in my example document? How exactly is lualatex different from pdflatex in this situation? Can you cite some documents I can read about this specific difference? – pts Jan 10 at 15:38
4

Change inputenc into luainputenc. But, really, you should switch to OpenType fonts. Don't complain if hyphenation is weird.

\documentclass[a4paper]{article}
\usepackage[utf8]{luainputenc}
\usepackage{t1enc}
\usepackage{lmodern}
\def\myhelvetica{\fontfamily{phv}\selectfont}
\begin{document}
\hrule
{\Huge Helló, Wörld, árvíztűrő}
\hrule
{\Huge Helló, Wörld, árvízt\H{u}r\H{o}}
\hrule
{\myhelvetica\Huge Helló, Wörld, árvíztűrő}
\hrule
\end{document}

enter image description here

For completeness, the fontspec version:

\documentclass[a4paper]{article}
\usepackage{fontspec}

\newfontfamily\myhelvetica{TeX Gyre Heros}

\begin{document}

\hrule
{\Huge Helló, Wörld, árvíztűrő}
\hrule
{\Huge Helló, Wörld, árvízt\H{u}r\H{o}}
\hrule
{\myhelvetica\Huge Helló, Wörld, árvíztűrő}
\hrule

\end{document}
  • Thanks! The source file with luainputenc works correctly with xelatex, pdflatex and lualatex. I haven't checked hyphenation though. – pts Jan 10 at 16:01
  • About hyphenation: With old-style (non-fontspec) fonts in lualatex, hyphenation of words containing Latin-1 letters is correct; hyphenation of words containing letters outside Latin-1 (e.g. \H{o}, or just ő) is incorrect. Hyphenation of everything is correct in pdflatex. Hyphenation of everything is correct with lualatex and fontspec fonts. – pts Jan 10 at 16:15
  • 1
    @pts That's what I said: you can get the right characters with luainputenc, but not hyphenation. – egreg Jan 10 at 16:33
  • Any insights why hyphenation is broken (and how it can be fixed)? Is it because patterns are in Unicode (UTF-8), but characters are in T1 encoding? (This would explain the behavior I'm experiencing.) Is there hack which converts patterns back to T1 encoding? – pts Jan 11 at 2:14
  • @pts Hyphenation is not broken. It just happens that it is available only for T1 encoded fonts or for Unicode fonts. Mixtures are not supported, as each variation would need a specific set of hyphenation patterns. – egreg Jan 11 at 8:28

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.