2

I am trying to TeX a Hungarian document including ű characters. As you can see I am using a UTF-8 encoding with lmodern, but the double accented u does not show up:

\documentclass{article}

\usepackage[magyar]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\begin{document}    
ű
\end{document}

What am I missing?

2
  • 3
    \"{u} is a different one (ü). The desired one would be \H{u}. But for me the document works, ű = \H{u} gives ű=ű. So what does the log file say? Dec 12, 2016 at 7:38
  • 2
    This code also works for me. Is you distribution up to date? Which versions of the packages are you using? Dec 12, 2016 at 7:42

2 Answers 2

2

Adding fontspec looks to be enough, but if it still doesn't work, then you can try adding the missing characters manually as well.

(Note that on MacTeX I had to use hungarian instead of magyar in the babel settings, as only the former is supported)

\documentclass{article}

\usepackage{fontspec, newunicodechar}
\usepackage[hungarian]{babel}
\usepackage{lmodern}

\newunicodechar{ű}{\H{u}}
\newunicodechar{ő}{\H{o}}

\begin{document}
árvíztűrő tükörfúrógép

ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP
\end{document}

There are still some LaTeX warnings displayed though:

LaTeX Warning: Please use \usepackage{t1enc} with
               \usepackage[hungarian]{babel}, to get accented chars hyphenated.

LaTeX Warning: Please use \usepackage[latin2]{inputenc} with
               \usepackage[hungarian]{babel}.

But the output is okay:

LuaLaTeX output

0

Looking at the logs again I noticed a warning:

Package inputenc Warning: inputenc package ignored with utf8 based engines.

I am using lualatex which always uses UTF8 so the inputenc is obsolet. The solution is as David mentioned in the comments:

\documentclass{article}

\usepackage[magyar]{babel}
\usepackage{fontspec}

\begin{document}
ű
\end{document}

Otherwise you could also change the compiler from lualtex to pdflatex and use the input given in the question.

6
  • that isn't really an answer. As the warning says the package is ignored in luatex so you should get the same output even if you omit the inputenc package. Dec 12, 2016 at 7:59
  • 2
    you should almost always never use \usepackage[T1]{fontenc} with luatex. Dec 12, 2016 at 8:00
  • yes, but the encoding is needed to encode the double accented u. I only had to use lualatex to produce some Feynman diagrams. Switching back to pdflatex solved the problem for me.
    – DrDirk
    Dec 12, 2016 at 8:04
  • 3
    no that is a misunderstanding you do not need inputenc because luatex input is always UTF8 and you should not use T1 encoding but a natural Uniocde encoded font (the default is in fact latin modern even without the lmodern package) so just using \usepackage{fontspec} and not fontenc or inputenc should be fine Dec 12, 2016 at 8:06
  • 1
    Lualatex uses utf8 as input encoding. So it doesn't need inputenc and inputenc apparently disables itself under lualatex. But then babel complains about inputenc not used with magyar. But even without babel and inputenc, lualatex doesn't know ű and that looks like a bug. For the time being you could use \H{u}. Dec 12, 2016 at 8:14

You must log in to answer this question.

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