# siunitx disturbs spacing of \, in math with xelatex

In the following example - compiled with XeLaTeX - the spacing of \thinspacing/the value of mu (used by \,) is disturbed if \SI is used in the math before:

\documentclass{article}

\usepackage{unicode-math}
\usepackage{siunitx}

\begin{document}

$1\mskip20mu1$ $\Leftarrow$

$\SI{1}{1}$

$1\mskip20mu1$ $\Leftarrow$

$1\mskip20mu1$

$\SI{1}{1}$

$1\mskip20mu1$ $\Leftarrow$

$a\SI{1}{1}$

$1\mskip20mu1$

\end{document}


unicode-math

A similar effect can be seen if \SI is the first command:

\documentclass{article}

\usepackage{unicode-math}
\usepackage{siunitx}

\begin{document}

$a\SI{2}{2}1\mskip20mu1$

$\SI{2}{2}a1\mskip20mu1$

\end{document}


# Observations

• it doesn't happen with LuaLaTeX,
• it doesn't happen with all fonts (unicode-mathCambria is not affected, but xits is),
• one must use \SI in math and in math mode,
• if only happens if \SI is the only thing in the math (which means that it is probably not a very problematic problem),
• at the next math, the value is again correct.

Has someone an idea if it it a XeTeX, a siunitx or a fontspec/unicode-math math bug?

-
It's 'not my fault': try $\text{$1\,1$}$ (which is internally used by siunitx) and you should see the same, although not with $\mbos{$1\,1$}$ –  Joseph Wright Feb 5 at 10:17
I was just going to remark that this is clearly a bug report. However, it is not, because the question is: Whose bug it is? (this comment should hopefully prevent anyone trying to close it as off-topic as a bug report) –  tohecz Feb 5 at 10:33
@JosephWright: I was actually quite sure that siunitx is not the source but couldn't reproduce the problem without it. But now I can: It happens with \text{$1\,1$} if one loads amstext. It disappears if one loads (additionally or instead) amsmath. –  Ulrike Fischer Feb 5 at 10:48
@JosephWright It works if one load amsmath, but not if one load a renamed amsmath, so probably some of the "if package amsmath loaded" code of unicode-math is the problem. –  Ulrike Fischer Feb 5 at 11:13
@UlrikeFischer Ah right, makes sense –  Joseph Wright Feb 5 at 11:15