# Strange behavior with using lmodern together with siunitx package

I would like to use the siunitx package in my document, but when I try to print an angle with the command \ang{90}, I've received

90ř

instead of

90°

Gradual reduction of the code, I found that the reason is the use of the package lmodern. How can this problem be solved? It seems that this behavior is similar to the description in the question: siunitx: µ doesn't work

MNWE:

\documentclass{scrbook}
\usepackage{xltxtra}
\usepackage{lmodern}
\usepackage{siunitx}

\begin{document}
Angle is \ang{90} or $$\ang[number-angle-product = \,]{2.67}$$
\end{document}

• Not surprising: outside of my normal test rig (you are using an 8-bit font with a Unicode engine, based on loading xltextra). For that set up, I'd expect fontspec to be loaded. – Joseph Wright Dec 1 '16 at 21:08
• Load fontspec instead of xltxtra and remove lmodern. – egreg Dec 1 '16 at 21:36

## 1 Answer

The set up in siunitx for fonts tries to cover a range of 'common' cases. Here, with the Unicode engine XeTeX I'm 'expecting' you to use fontspec (perhaps with unicode-math). If you'd just loaded lmodern things would look OK (but see note below), but adding xltxtra before lmodern has confused the 'guesses' entirely: it's a far-from typical set up. Once you go 'off piste' you do have to set such things yourself: siunitx can't predict every possible combination of font choices. (Loading fontspec, which xltxtra does, uses the OpenType form of Latin Modern so I'm not really sure what you are aiming for!)

In detail, what happens here is that siunitx detects fontspec so switches the standard definition for the degree symbol to use the Unicode codepoint (decimal 176). When you then load lmodern later, this position is no longer the right glyph as the OT1-encoded font you end up with math mode has something different in that slot.

Whilst one can load lmodern with XeTeX, the font encoding (OT1 or T1) is wrong: some slots are incorrect and will hyphenate badly. You really should consider using fontspec here.

• Not sure what you mean by “confusing the guesses”, because xltxtra loads fontspec. By the way, lmodern is agnostic with respect to output encodings. – egreg Dec 2 '16 at 9:55
• @egreg I've refined a bit. lmodern isn't encoding-agnostic: it's an 8-bit font so usable with OT1 or T1 but not TU, which is what we have here. – Joseph Wright Dec 2 '16 at 10:25
• The lmodern package does something encoding related with math, otherwise just sets values for \rmdefault, \sfdefault and \ttdefault. It doesn't set an output encoding. – egreg Dec 2 '16 at 10:36
• @egreg Yes, but the font files themselves are 8-bit and thus not available in TU – Joseph Wright Dec 2 '16 at 10:37
• @JosephWright: Try out \usepackage[no-math]{fontspec} without lmodern. You are not only assuming that fontspec is loaded, you are actually assuming that it resets some math fonts. – Ulrike Fischer Dec 2 '16 at 12:18