# unicode-math interferes with siunitx and ignore setting for complex unit

I'm just trying to extend \sisetup by output-complex-root=\ensuremath{\imath} according to table 16 in siunitx package. But the symbol \imath is missing in the output file, compiled by lualatex. See my MNWE:

\documentclass{scrbook}
\usepackage{amsmath}
\usepackage{unicode-math}
% \usepackage{lualatex-math}
\usepackage{siunitx}
\sisetup{
math-micro=\text{µ},text-micro=µ,
input-complex-roots = i,
output-complex-root=\ensuremath{\imath}
}

\begin{document}
\num{1+2i} or $$\num{1+2i}$$ test: $$\imath$$
output
\SI{10}{\micro\m}
\SI[mode=text]{10}{\micro\m} % just for reference

\end{document}


While the package lualatex-math works properly. I found a similar question (here), but unfortunately it did not help.

With unicode-math, you can define an upright-math-symbols alphabet that’s distinct from text symbols in math mode. Here is an example that sets the imaginary unit i in ISO style, from the upright italic font, but keeps the µ symbol from the main text font.

Using \text for symbols in math mode is a mistake I’ve made in the past—but then bold or italic formatting will bleed through from the surrounding text! Here, you want to use \mathrm, but an alternative would be \text{\normalfont µ}.

\documentclass{scrbook}
\usepackage{amsmath}
\usepackage[math-style=ISO]{unicode-math}

\setmathfont{Latin Modern Math}
\setmathfont[range=up]{Latin Modern Roman Unslanted}

\usepackage{siunitx}
\sisetup{
math-micro=\mathrm{µ},text-micro=µ,
input-complex-roots = i,
output-complex-root=\ensuremath{\symup{i}}
}

\begin{document}
\num{1+2i} or $$\num{1+2i}$$ test: $$\imath$$
output
\SI{10}{\micro\m}
\SI[mode=text]{10}{\micro\m} % just for reference

\end{document}


Note that \mathrm, \mathup, \operatorname and so on use the default text font, while \symup uses the fancy upright-math-symbol font.

My go-to example is Euler’s identities, set with the constants in Hermann Zapf’s Neo Euler, with the remaining text in (clones of) his Palatino:

\documentclass[varwidth, preview]{standalone}

\usepackage{mathtools}
\usepackage[math-style=ISO]{unicode-math}

\setmainfont{TeX Gyre Pagella}
\defaultfontfeatures{Scale=MatchLowercase}

\setmathfont{Asana Math}
\setmathfont[range={up/{Latin,latin,Greek,greek},
bfup/{Latin,latin,Greek,greek}},
script-features={}, sscript-features={}
]{Neo Euler}

\newcommand\upe{\symup{e}}
\newcommand\upi{\symup{i}}

\begin{document}
\begin{align*}
\upe^{\upi x} &= \cos{x} + \upi \sin{x} \\
\upe^{\upi \uppi} + 1 &= 0
\end{align*}
\end{document}


## Using the Dotless ı

That doesn’t answer the literal question you asked, though, which was how to use dotless ı. Since the problem is that siunitx switches the font to \mathrm, just change it back. The following works:

output-complex-root=\ensuremath{\mathnormal\imath}


If you use the technique above to load a math font with an upright dotless ı, \symup\imath will work as well.

## Changing \mathrm

Ulrike Fischer’s answer works great, but if you take that approach, I would recommend \setmathrm over \setmathfontface\mathrm.

siunitx uses \mathrm for the typesetting of the number and as this is normally a text font it doesn't have the math symbols. You could map \mathrm to the math font:

\documentclass{scrbook}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfontface\mathrm{Latin Modern Math}
\usepackage{siunitx}
\sisetup{
math-micro=\text{µ},text-micro=µ,
output-complex-root=\ensuremath{\imath},
}

\begin{document}
\num{1+2i} or $$\num{1+2i}$$ test: $\imath$
\SI{10}{\micro\m}
\SI[mode=text]{10}{\micro\m} % just for reference
\end{document}


• I would recommend the \setmathrm command over \setmathfontface. It’s designed for this and also allows BoldFont, etc. – Davislor Dec 25 '19 at 3:08
• One mistake I’ve frequently made in the past: \text in math mode inherits the current text style, which might be bold, italic, etc. Either use \symup or \text{\normalfont µ}. – Davislor Dec 25 '19 at 3:10
• Also note that you can load an upright math alphabet distinct from the plain text font as \symup. E.g., \setmathfont[range=up]{Latin Modern Roman Unslanted} and output-complex-root=\ensuremath{\symup i}. – Davislor Dec 25 '19 at 3:19