8

I have a document, where for different reasons, I use unicode-math and siunitx. When I load unicode-math some units whose symbols are usually slanted (as math variables) are not slanted anymore.

Why is that? Do you know a workaround?

Here it is the minimal example:

\documentclass{article}

\usepackage{siunitx}
\usepackage{unicode-math}% this makes e appear straight (not math)

\begin{document}
\noindent

\SI{1.234}{\planckbar^{-4}\elementarycharge^{2}} %the outcome depends on loading unicode-math

$1.234 \hbar^{-4} e^2$ %this is always ok

\end{document}

Output (note the e symbol, electron charge, it should appear slanted)

unicodeplussiunitx

0

2 Answers 2

5

The answer by egreg provides a perfectly good solution, but it might be useful to understand why this is happening.

Internally, siunitx resolves input into constructs of the form

$\mathrm{<unit-output>}$

so here

$\mathrm{\text{\ensuremath{e}}}$

With classical TeX, switching math-text-math gets us 'back to normal' in font terms so we can the normal italic font for letters without any explicit formatting. However, with unicode-math this doesn't seem to happen: nested font changes stay active. As as result, the usual set up gives incorrect results.

I'll see whether this can be addressed at the unicode-math end or whether a change in siunitx is needed.

6

Something weird is happening when \text is processed in the argument of \SI. Here's a fix:

\documentclass{article}

\usepackage{amsmath}
\usepackage{unicode-math}% this makes e appear straight (not math)
\usepackage{siunitx,xparse}

\NewDocumentCommand{\mathnormalsymbol}{m}{\text{$\mathnormal{#1}$}}
\DeclareSIUnit{\elementarycharge}{\mathnormalsymbol{e}}

\begin{document}

\SI{1.234}{\planckbar^{-4}\elementarycharge^{2}}

$1.234\, \hbar^{-4} e^2$ %this is always ok

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .