# SIunitx error when using lighter weight

Using the SIunitx package with montserrat package doesn't produce the desired result:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[defaultfam,light,scale=0.85]{montserrat}
\usepackage{siunitx}
\sisetup{%
mode = math, % Same error if mode = text is used
% detect-all, % When, uncommented, the error described below occurs
% detect-weight,  % When, uncommented, the error described below occurs
}

\begin{document}
This is the weight and family of text desired but when siunitx shows heavier weight: \SI{75}{\micro\metre}
\end{document}


Produces:

When options detect-weight or detect-all are used, the following error is produced:

[no file]:18: Undefined control sequence. [...hows heavier weight: \SI{75}{\micro\metre}]
[no file]:18: Undefined control sequence. [...hows heavier weight: \SI{75}{\micro\metre}]


The PDF, notwithstanding the compilation error, the PDF shows the desired result:

The log file indicates:

Package: siunitx 2018-05-11 v2.7q A comprehensive (SI) units package


and reports the following error:

! Undefined control sequence.
\__siunitx_font_weight: ->\lseries

l.18 ...hows heavier weight: \SI{75}{\micro\metre}

• Do you need mode = math? With mode = text it works without errors. Jul 4 '19 at 14:52
• @RalfStubner If you uncomment detect-weight and set math = text in the MWE, the same error occurs. I have updated the MWE to indicate this. Jul 4 '19 at 14:57
• Indeed. But there is no error and the right fonts if you only use mode = text without any of the detect-* options. Jul 4 '19 at 14:58
• @RalfStubner your suggestion works. Jul 4 '19 at 15:00
• @RalfStubner - There may be valid reasons (which the OP hasn't pointed out so far) for setting mode=math. (See, e.g., p. 77 of the user guide of the siunitx package.) The work-around for this contingency is set set detect-mode (but certainly not detect-all) when loading siunitx.
– Mico
Jul 4 '19 at 15:02

Provide a definition for the missing command:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[defaultfam,light,scale=0.85]{montserrat}
\usepackage{siunitx}
\sisetup{%
mode = math, % Same error if mode = text is used
detect-all, % When, uncommented, the error described below occurs
%detect-weight,  % When, uncommented, the error described below occurs
}

\DeclareRobustCommand\lseries{\fontseries{l}\selectfont}

\begin{document}
This is the weight and family of text desired but when siunitx shows heavier weight: \SI{75}{\micro\metre}
\end{document}


You need to load siunitx with the option detect-mode. (Please see the bottom of p. 17 and the top of p. 18 of the user guide of the siunitx package for the differences between detect-mode, detect-weight, etc.)

\documentclass{article}
\usepackage{geometry} % optional
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[defaultfam,light,scale=0.85]{montserrat}
\usepackage{siunitx}
\sisetup{ mode = math , detect-mode }

\begin{document}
This is the weight and family of text desired. siunitx now shows the correct, i.e, thin weight: \SI{75}{\micro\metre}
\end{document}


You could use mode = text without any any detect-* options giving you the same output even when the unit is used in math mode:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[defaultfam,light,scale=0.85]{montserrat}
\usepackage{siunitx}
\sisetup{ mode = text }

\begin{document}
This is the weight and family of text desired but when siunitx shows
heavier weight: \SI{75}{\micro\metre} $\SI{75}{\micro\metre}$
\end{document}