josephwright / siunitx

A comprehensive (SI) units package for LaTeX
LaTeX Project Public License v1.3c
359 stars 26 forks source link

Support math versions #209

Closed josephwright closed 3 years ago

josephwright commented 11 years ago

[Anonymous report]

Support unicode-math's math versions.

The attached minimal example uses the math version "pagella" (being the font TG Pagella Math) only in the case not using siunitx.

Either the lines beginning with %1 or %2 should work or a new key should be added.

\documentclass{minimal}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{Asana Math}
\setmathfont[version=asana]{Asana Math}
\setmathfont[version=pagella]{TG Pagella Math}

\usepackage[mode=math,math-rm=\mathrm]{siunitx}
%1 \usepackage[mode=math,math-rm=\mathversion{pagella}\mathrm]{siunitx}
\DeclareSIUnit{\litre}{\mscrl}
\DeclareSIUnit{\metre}{\mscrm}
\DeclareSIPrefix{\milli}{\mscrm}{-3}
\DeclareSIPrefix{\centi}{\mscrc}{-2}
\begin{document}
{\mathversion{asana}\(3\,\mscrm\mscrl=3\,\mscrc\mscrm^3\)}

{\mathversion{pagella}\(3\,\mscrm\mscrl=3\,\mscrc\mscrm^3\)}

{\mathversion{pagella}\(\SI{3}{\milli\litre}=\SI{3}{\cubic\centi\metre}\)}

{\(\mathversion{pagella}\SI{3}{\milli\litre}=\SI{3}{\cubic\centi\metre}\)}

{\(\SI{3}{\mathversion{pagella}\milli\litre}=\SI{3}{\cubic\centi\metre}\)}

{\(\SI[parse-numbers=false]{\mathversion{pagella}3}{\milli\litre}=\SI{3}{\cubic\centi\metre}\)}

\end{document}
josephwright commented 6 years ago

Working here in the v3 development code:

\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{Asana Math}
\setmathfont[version=asana]{Asana Math}
\setmathfont[version=pagella]{texgyrepagella-math.otf}

\usepackage{siunitx}
\DeclareSIUnit{\litre}{\mscrl}
\DeclareSIUnit{\metre}{\mscrm}
\DeclareSIPrefix{\milli}{-3}{\mscrm}
\DeclareSIPrefix{\centi}{-2}{\mscrc}
\sisetup{reset-math-version = false}
\begin{document}

{\mathversion{pagella}$3\,\mscrm\mscrl = 3\,\mscrc\mscrm^{3}$}

{\mathversion{pagella}\(\qty{3}{\milli\litre}=\qty{3}{\cubic\centi\metre}\)}

{\mathversion{asana}$3\,\mscrm\mscrl = 3\,\mscrc\mscrm^{3}$}

{\mathversion{asana}\(\qty{3}{\milli\litre}=\qty{3}{\cubic\centi\metre}\)}

\end{document}