2

I am trying to write a degree symbol for an angle on a Japanese computer running an English version of Windows 7. Consider the following MWE compiled with LuaLaTeX 1.0.4 on TeXLive 2017:

\documentclass{scrreprt}

\usepackage{siunitx}
\usepackage{lmodern}
\usepackage{polyglossia}
\setdefaultlanguage{english}

\begin{document}
The angle is \ang{30}.
\end{document}

The output of this code is the following string:

The angle is 30r

By changing the documentclass to report or removing lmodern, I get the correct degree symbol. Why does this happen and is there a way to produce the right character using these packages?

  • Can you use $^{\circ}$? – Joel Kulesza Sep 21 '18 at 5:13
  • $^{\circ}$ works fine, but I would prefer to keep using the SI package if possible for consistency. – Petroglyph Sep 21 '18 at 5:16
  • 1
    You get the same issue with if you load fontspec and not polyglossia. There are lots of search results on these things, but i'm not entirely familiar with xelatex and not sure how to get the other solutions to work for you. anyhow, just suggesting that maybe if you find a resolution for a fontspec scenario, you might also have a solution in your polyglossia scenario. – A.Ellett Sep 21 '18 at 5:24
  • Changing \usepackage{lmodern} to \usepackage{fontspec} does the trick, thank you! I did not know, lmodern is automatically loaded with lualatex. – Petroglyph Sep 21 '18 at 6:10
  • if removing lmodern fixes the problem, but lualatex and xelatex both auto load it, what exactly is going on here? Can someone explain? – A.Ellett Sep 21 '18 at 13:51
1

The problem is not related to KOMA-Script. With current TeX Live 2018, I get the same result using the standard class report instead of scrreprt.

You do not need \usepackage{lmodern}, because LuaLaTeX already uses Latin Modern as default font. Moreover, the default (without lmodern) is using the OpenType Latin Modern fonts. These are unicode fonts containing much more glyphs than the legacy fonts that are used by \usepackage{lmodern} and are limited to 256 characters. And LuaLaTeX is prepared to use several of those extra glyphs.

If you load \usepackage{lmodern} you switch to the legacy fonts, limited to 256 characters per font. So you should not use \usepackage{lmodern}.

BTW: If you would like to use another font but the default Latin Modern, it is recommended to use package fontspec and commands like \setmainfont, \setsansfont etc. to load an OpenType (or at least an Type-1) font. Such fonts can contain much more than 256 characters.

So I would recommend to use either:

\documentclass{report}

\usepackage{siunitx}
\usepackage{polyglossia}
\setdefaultlanguage{english}

\begin{document}
The angle is \ang{30}.
\end{document}

or

\documentclass{report}

\usepackage{fontspec}
\usepackage{siunitx}
\usepackage{polyglossia}
\setdefaultlanguage{english}

\begin{document}
The angle is \ang{30}.
\end{document}

For extra math features see also package unicode-math.

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.