# How to globally ensure siunitx units are upright using a math font?

I am using mtpro2 as the math font in my document (exam class). When I type a quantity using the siunitx package, it displays the unit using italics. I do not want this; instead, I want the units to be upright.

Units are italicized. Undesired.

Units are upright. Desired.

Code that results in italic units.

\documentclass[twoside,11pt]{exam}

% standard document packages
\usepackage[top=0.7in,bottom=0.7in,left=0.36in,right=0.36in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[subscriptcorrection,slantedGreek,nofontinfo,mtpcal,mtpfrak,mtphrb]{mtpro2}
\usepackage[english]{babel}

% chemistry packages
\usepackage{siunitx}
\sisetup{math-rm=\ensuremath,inter-unit-product=\ensuremath{\cdot},per-mode=symbol}

% math packages
\usepackage{amsmath}

% exam class settings
\renewcommand{\choicelabel}{(\thechoice)}
\renewcommand{\choiceshook}{\setlength{\leftmargin}{18pt}}

\begin{document}
\begin{choices}
\choice \SI{1.5}{\hour}
\CorrectChoice \SI{2.5}{\hour}
\choice \SI{3.5}{\hour}
\choice \SI{4.0}{\hour}
\end{choices}
\end{document}


So far, the only "solution" I can determine is to use \text to wrap around the unit. All other attempts have failed, including modifications to \sisetup.

\begin{document}
\begin{choices}
\choice \SI{1.5}{\text{\hour}}
\CorrectChoice \SI{2.5}{\text{\hour}}
\choice \SI{3.5}{\text{\hour}}
\choice \SI{4.0}{\text{\hour}}
\end{choices}
\end{document}


This "solution" is tedious and inelegant as it would require me to go through every inch of my exam and type \text in the units. I would like to use mtpro2, but I need the units to be upright.

How can I redefine the unit in the siunitx package to use upright text globally when implementing mtpro2? Can I define the unit (e.g., hour) to be in baskervald while having the value (e.g., 1.5) remain in mtpro2? The siunitx documentation states quantities are defined as including both value and unit, so this makes me think otherwise.

## Edit 1

I included another picture here to demonstrate the problem I have when I leave out \math-rm=\ensuremath. If I leave this code out, the magnitude of the quantity changes from mtpro2 to baskervald, which is undesired. In this case, it does not matter whether I add \unit-mode=text or omit it because the magnitude is in baskervald, not mtpro2.

Leaving out \math-rm=\ensuremath produces the magnitude in baskervald, not mtpro2. Undesired.

Keeping \math-rm=\ensuremath forces siunitx to use mtpro2 as the font from what I can tell. Adding \unit-mode=text changes the unit from italics to upright since I am guessing it reverts the font from mtpro2 to baskervald specifically for the unit while ignoring the magnitude. Using \unit-mode=text with \math-rm=\ensuremath creates the desired output.

Magnitude in mtpro2 and unit upright. Desired output.

## Edit 2

It seems several people disagree with using \math-rm=\ensuremath in combination with \unit-mode=text to create this effect. Is there a more appropriate way to achieve the desired output without \math-rm to use mtpro2?

## Question

What is the most appropriate way to ensure that the magnitude (e.g., 1.5) of a given quantity is in any desired font while the unit (e.g., h) is in any different desired font using siunitx? Is it possible to make this distinction without using \math-rm?

• Does adding option mode=text to sisetup render you the desired output? – gusbrs Jun 20 '18 at 0:08
• what's the intention of math-rm=\ensuremath ? the default is \mathrm which is an upright font.... – David Carlisle Jun 20 '18 at 0:11
• Adding that particular option changes the font of the entire quantity to baskervald. Although it makes the unit upright, the magnitude (e.g., 1.5) is no longer in mtpro2, which is undesired. I want to have the magnitude in mtpro2, so using math-rm=\ensuremath creates that desired effect. – TheModernShakespeare Jun 20 '18 at 0:13
• the \ensuremath simply wrong: it specifies to use math italic as the font for things that should be set in roman. that is, it is the cause of the problem that you ask about. – David Carlisle Jun 20 '18 at 0:31
• @DavidCarlisle If I understand this correctly, siunitx will detect the font currently in use and when using math-rm it \ensure(s)math. So, if I agree with you as to not understanding why this is there, I'm not so sure this is the cause of the problem at hand. – gusbrs Jun 20 '18 at 0:35

You can select \mathnormal in place of \mathrm with for example
unit-math-rm = \mathnormal

This is a documented possibility: some fonts don't have quite the right set up for \mathrm to work.