4

Question

I am trying to use the package siunitx in combination with the Opensans Light font. To make siunitx detect the font weight, I pass \sisetup{detect-weight}. However, the document fails to compile. Can anyone reproduce this behavior? Is there a workaround?

Thank you!

Minimal example

\documentclass{minimal}

\usepackage[default]{opensans}
\usepackage{siunitx}
\sisetup{detect-weight}

\begin{document}

\fontseries{l}\selectfont This is quite light: \SI{1}{\milli\gram}

\end{document}

Edit 1

To clarify: replacing \fontseries{l} with \fontseries{m} or \fontseries{b} works as expected

4

The problem is that siunitx assumes that for packages providing a 'light' font, the command \lseries will be defined in the same way as for \mdseries. Here, that is not the case. A suitable patch for text mode printing is

\documentclass{minimal}

\usepackage[default]{opensans}
\usepackage{siunitx}
\usepackage{xpatch}

\ExplSyntaxOn
\xpatchcmd{\__siunitx_detect_font_weight_text:}
  { \lseries }
  { \fontseries{l} \selectfont }
  {}{}
\ExplSyntaxOff
\begin{document}
\sisetup{detect-weight, mode = text}
\fontseries{l}\selectfont This is quite light: \SI{1}{\milli\gram}

\end{document}
  • Or, maybe, \DeclareRobustCommand\lseries{\not@math@alphabet\mdseries\relax\fontseries{l}\selectfont} – egreg Mar 10 '14 at 21:15
  • @egreg Yes, perhaps that but I guess the package should be robust against this! – Joseph Wright Mar 10 '14 at 21:18
  • @egreg Any ideas for dealing with math mode in such a case? – Joseph Wright Mar 10 '14 at 21:18
  • I suppose you need to define a math version. – egreg Mar 10 '14 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.