Siunitx font weight detection with Roboto

The problem is that the code of siunitx tries to work in math and text mode in a similar way. In math there is basically only normal and bold and so also in text mode siunitx more or less only tries to detect if bold is active and if not it uses the normal series, which means here the light font. One way to get around is, is to locally reset the default series. The following examples needs a current LaTeX 2020-02-02:

\documentclass{article}
\usepackage[light,medium]{roboto}
\providecommand*\lseries{\mdseries}
\usepackage{siunitx}
\sisetup{detect-all=true}
\begin{document}
\sffamily
1\,mV \SI{1}{\milli\volt} \textbf{1\,mV}

{\DeclareFontSeriesDefault[sf]{md}{m}\mdseries
1\,mV \SI{1}{\milli\volt}}

1\,mV \SI{1}{\milli\volt} 
\end{document}

enter image description here

There is another problem hidden here: siunitx detects bold by looking if the current series is b or bx. But with your setup it is bx for the roman font, but sb for the sans serif, and so detecting the weight in sans serif fails:

\documentclass{article}
\usepackage[light,medium]{roboto}
\providecommand*\lseries{\mdseries}
\usepackage{siunitx}
\sisetup{detect-all=true}

\begin{document}
1\,mV \SI{1}{\milli\volt}

{\bfseries \makeatletter f@series is: \f@series. \quad
 1\,mV \SI{1}{\milli\volt}}


\sffamily
1\,mV \SI{1}{\milli\volt} 

{\bfseries \makeatletter f@series is: \f@series. \quad 
 1\,mV \SI{1}{\milli\volt}}
\end{document}

enter image description here

Tags:

Fonts

Siunitx