latex3 / unicode-math

XeLaTeX/LuaLaTeX package for using unicode/OpenType maths fonts
http://ctan.org/pkg/unicode-math
LaTeX Project Public License v1.3c
245 stars 29 forks source link

\mathrm swallows symbols #438

Closed u-fischer closed 6 years ago

u-fischer commented 6 years ago

In TL 16 (unicode-math 2017/01/27 v0.8d ) the following document outputs three upright mu. In Tl 17 ({2018/01/13} {v0.8k}) only the last mu is output. In the log there are three missing character messages:

  Missing character: There is no μ (U+03BC) in font [lmroman10-regular]:+tlig;!
\documentclass{article}
\usepackage{unicode-math}
\begin{document}
$\mathrm{\upmu} \mathrm{\symrm{\upmu}} \mathrm{\hbox{$\upmu$}}$
\end{document}

(This is a problem for siunitx: https://tex.stackexchange.com/questions/411558/siunitx-abbreviations-are-not-printed-with-mathtools-fontspec-and-unicode-math).

maxnoe commented 6 years ago

This is not fixed in v0.8l and still an issue (Even in TL2018 pretest)

maxnoe commented 6 years ago
\documentclass{scrartcl}

\usepackage{fontspec}

\usepackage{mathtools}

\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\usepackage{siunitx}
% \sisetup{math-micro=\text{µ},text-micro=µ} % this fixes it

\begin{document}
\SI{10}{\milli\second} \\
\SI{10}{\micro\second} \\
\SI{10}{\nano\second}
\end{document}
u-fischer commented 6 years ago

The problem is solved. My example above shows in texlive 2018 (and in texlive 2017) three mu's. But this doesn't mean that siunitx directly will use it, only that it is now possible in a sane way to tell siunitx about the micro, e.g.:

\documentclass{article}
\usepackage{unicode-math}
\usepackage{siunitx}
\sisetup{detect-mode,math-micro=\upmu,text-micro=µ}
\begin{document}
Time $\si{\us}$ \si{\us}

$\mathrm{\upmu} \mathrm{\symrm{\upmu}} \mathrm{\hbox{$\upmu$}}$
\end{document}
maxnoe commented 6 years ago

So you say this is a siunitx issue now?

It shouldn't be necessary to do any special \sisetup to get a working \micro.

u-fischer commented 6 years ago

Yes.

maxnoe commented 6 years ago

I don't really get it. Because this used to work and it was unicode-math which changed, not siunitx. Also it's very unfortunate that this broke just before TL2017 was frozen.

wspr commented 6 years ago

I don't have time right now to fully unpack what situnitx is doing, I'm afraid.

Technically speaking the micro sign should be coming from the text font, and should never involve switching to the maths font(s). I would have thought that \char"00B5 would be the best option for this?

If you do use that value, it all seems to work, so maybe the hardcoded value of "03BC that siunitx uses when unicode-math is loaded is not the best approach any more. @josephwright ?

\documentclass{article}
\usepackage{unicode-math}
\usepackage{siunitx}
\begin{document}
\ExplSyntaxOn
\cs_undefine:N \c__siunitx_micro_int
\int_const:Nn \c__siunitx_micro_int {"00B5}
\ExplSyntaxOff

[\SIUnitSymbolMicro] [$\text{\SIUnitSymbolMicro}$]

$\si{\micro m}$
\end{document}