4

When writing numbers with units using the siunitx package, \SI{1064}{\um}, the numbers and units are noticeably smaller than the text, however the mu seems to be the correct size. I am using Verdana as the main text font and the default LaTeX font for maths. MiKTeX and compiled with LuaLaTeX.

MWE

\documentclass[10pt,a4paper]{article}
\usepackage{siunitx}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setsansfont{Verdana} % Setting sans font
\renewcommand*{\familydefault}{\sfdefault} % Making sans serif font the default
\linespread{1.16} % Increasing the linespacing
\usepackage{unicode-math}

\begin{document} 
This is some text \SI{1064}{\um} m $m$
\end{document}

Text without scaling

I try and scale using \defaultfontfeatures{Scale=MatchLowercase}

\documentclass[10pt,a4paper]{article} \usepackage{siunitx}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setsansfont{Verdana} % Setting sans font
\renewcommand*{\familydefault}{\sfdefault} % Making sans serif font the default
\linespread{1.16}        % Increasing the linespacing
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}

\begin{document}
This is some text with scaling \SI{1064}{\um} m $m$
\end{document}}

Text with scaling

The numbers and the m written in maths mode have become larger but the m in the units has not. I've tried \sisetup{detect-all} but that just changes everything written with \SI into Verdana which is not what I'm after. Is there a way to increase the size of the font in the units?

3
  • 1
    Just out of idle curiosity: Why do you run \setsansfont{Verdana} followed by \renewcommand*{\familydefault}{\sfdefault}? Why not just run \setmainfont{Verdana}? Please advise.
    – Mico
    Apr 16 at 17:01
  • @Mico No reason really. I'll change to your suggestion as it's a bit cleaner.
    – SockPile
    Apr 17 at 7:47
  • @Mico Actually after changing to \setmainfont{Verdana} the letters in the units change to Verdana
    – SockPile
    Apr 17 at 10:18

3 Answers 3

5

Your problem is that the math mode font is a different size to the body font. I've fix that by scaling, for example

\documentclass[10pt,a4paper]{article}
\usepackage{siunitx}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures = TeX, Scale = MatchLowercase}
\setsansfont{Verdana} % Setting sans font
\renewcommand*{\familydefault}{\sfdefault} % Making sans serif font the default
\usepackage{unicode-math}
\begin{document} 
This is some text \qty{1064}{\um}.
\end{document}
2
  • That works! Thanks.
    – SockPile
    Apr 17 at 7:59
  • This solution seems to make the Verdana font to match the maths font size, ie make the Verdana font smaller. Is there a way to make the maths font bigger while keeping Verdana at 10 pt?
    – SockPile
    Apr 18 at 11:47
3

My suggestion would be to load siunitx with the option mode=text. That way, the text font (here: Verdana) will be used automatically in \num and \unit directives.

enter image description here

% !TEX TS-program = lualatex
\documentclass{article} 

\usepackage{unicode-math}
\setmainfont{Verdana} % main font

\usepackage[mode=text]{siunitx}

\begin{document}
This is some text \dots\ \qty{1064}{\um}.
\end{document}
5
  • The OP said that they don't want Verdana unconditionally
    – Joseph Wright
    Apr 17 at 7:56
  • @Mico Is it better to have the numbers and units written in the main font (Verdana in this case)?
    – SockPile
    Apr 17 at 8:15
  • 1
    @SockPile - I guess the most important goal is to maintain notational consistency. As long as you use either an all-math font or an all-text font approach, your readers should be able to figure out easily what's going on. A separate issue: Given that Verdana (text) and Latin Modern (math) don't mesh all that well, optically/aesthetically speaking, you may want to think about switching to a math font family that's more compatible with Verdana.
    – Mico
    Apr 17 at 11:31
  • @Mico I agree and thanks for the comment. I did actually look at changing to a maths font that was more compatible with Verdana (LaTeX Font Calalogue for others who may read this) but wasn't sure how to decide and the MS Word template I'm copying uses Cambria Math so just left it as the default.
    – SockPile
    Apr 17 at 14:11
  • 1
    @SockPile - I guess it's a bit unfortunate that you're expected to mix and (mis)match a sans-serif text font face (Verdana) with a serif math font face (Cambria Math). I'd still give \setmathfont{Cambria Math}[Scale=MatchUppercase] a try (after loading unicode-math, of course).
    – Mico
    Apr 17 at 14:56
0

I initially marked @JosephWright's answer as the solution however this seemed to shrink the main font (Verdana) to match the maths font size.

So using his answer along with @Mico's comment on how to change the main maths font I have found a solution that seems to work:

\documentclass[10pt,a4paper]{article}
\usepackage{siunitx}
\usepackage{unicode-math}

\defaultfontfeatures{Ligatures=TeX}
\setsansfont{Verdana} % Setting sans font
\renewcommand*{\familydefault}{\sfdefault} % Making sans serif font the default
\setmathfont{Cambria Math}[Scale=MatchUppercase] % Setting the maths font and scaling to match Verdana size
\setmathrm{Cambria Math}[Scale=MatchUppercase] % Setting the upright maths font used by siunitx
\newfontfamily{\mufont}{Cambria Math} % Selecting the mu from the Cambria Math font...
\DeclareSIPrefix\micro{\ensuremath{\mufont μ}}{-6} % ...and the selecting it for use with siunitx and make it represent 10^-6

\begin{document}
This is some text \dots\ \qty{1064}{\um}.
\end{document}

I needed to set the upright maths font to Cambria Math and scale \setmathrm{Cambria Math}[Scale=MatchUppercase]

You must log in to answer this question.

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