2

I am trying to render figure captions in a sans-serif font.

I have gotten as far as setting up the caption package to use the sf font for text (easy) and math (via the sansmath package).

I am struggling to make siunitx fit into this. \SI or \qty will render the number in the serif'ed font.

This is sort of a follow-up question. Note that I am using all of siunitx's switches to detect math mode, font family etc.

Example:

\documentclass[11pt,a4paper]{scrarticle}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[T1]{fontenc}

\usepackage{sansmath}

\usepackage[separate-uncertainty=true, multi-part-units=single]{siunitx}
\sisetup{
    mode = match,
    propagate-math-font = true ,
    reset-math-version = false ,
    reset-text-family = false ,
    reset-text-series = false ,
    text-family-to-math = true ,
    text-series-to-math = true
}

\parindent=0in

\begin{document}
\sansmath
\begin{tabular}{ll}
    1. Plain serif text:            & 123\,m                 \\
    \sffamily 2. Plain sans math:   & $123\,m$               \\ 
    \sffamily 3. Plain sans text:   & \sffamily 123\,m       \\
    \sffamily 4. siunitx sans text: & \sffamily\qty{123}{m}   \\
    \sffamily 5. siunitx sans math: & \sffamily$\qty{123}{m}$
\end{tabular}
\end{document}

Output:

output

I understand what is going on in all but the last one. Why are the figures serif'ed?

PS: BTW, if I leave out the last \sffamily then also the unit is set with serifs.

2
  • Okay, it seems to work as expected if I leave out the text-series-to-math option. Makes no sense to me though.
    – polwel
    Sep 1, 2021 at 15:30
  • Do not be deterred from posting an answer by my previous comment. It is not the solution here.
    – polwel
    Sep 1, 2021 at 18:56

1 Answer 1

2

As you observe, this comes about with text-series-to-math active. To understand what's happening, you need to know two things

  • Math mode and text mode work very differently in terms of fonts; in particular, the \mathversion is used to set \sansmath (a shape) as well as for example \boldmath (a series).

  • In v3, siunitx aims to format quantities to a 'standard' form, which looks like 123\,\mathrm{m} here, then applies transformations to get the desired output.

That leads to an odd outcome here as text-series-to-math finds that the text series is medium, so sets the \mathversion, but that zaps \sansmath. On the other hand, the part of the code that deals with \mathrm does stay active so uses \mathsf, and so the unit is unaffected.

I will think if there is any way to make this clearer or to better separate the different aspects of math version.


For the present, if you set

\sisetup{series-version-mapping / m = sans}

then things should be 'ok'.

1
  • I have a fix for this that will appear in v3.0.29: it goes with a few other things so I won't try to post a patch - expect an update in a day or so.
    – Joseph Wright
    Sep 2, 2021 at 6:48

You must log in to answer this question.

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