[Tex/LaTex] Montserrat as math sans serif font

fontsmath-modesans-serif

I'm using kpfonts in the thesis for its light variant. I don't really like its sans serif variant, though, since it's too bold and doesn't blend well with the light serif font. Looking for another sans serif font, I've found the Montserrat font, which is really nice in its light option, and looks really good for all caps titles in the extralight variant.

The problem is that the montserrat package does not provide any math support, so if I write any \mathsf in math formulas, I get the kpfonts sans serif math font. On the other hand, letters and numbers from Montserrat look very well also in math mode (in the rare cases one wants to render sans serif math).

Here is an example to see what I mean.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[light,onlyrm]{kpfonts}
\usepackage[light,scale=0.85]{montserrat}

\usepackage[sf,uppercase]{titlesec}

\newcommand*\elseries{\fontseries{el}\selectfont}

\titleformat*{\section}{\sffamily\elseries\large}

\begin{document}
  \section{Section Title}
  A little piece of text, \textsf{with some sans serif parts}, and some math:
  \begin{equation*}
  e^{i\pi}+1=0
  \end{equation*}
  Plus some sans serif math:
  \begin{equation*}
  \mathsf{e^{i\pi}+1=0}
  \end{equation*}
  Good looking sans serif math:
  \begin{equation*}
  \text{\textsf{e}}^{\text{\textsf{i}}\pi} + \text{\textsf{1}} = 
  \text{\textsf{1}}
  \end{equation*}
\end{document}

example

So, is there a way to fake math support and use montserrat glyphs for sans serif math, at least for numbers and latin letters? I'd prefer to stick to solutions that work with pdflatex.

EDIT: note that the Montserrat font itself does not appear to have greek glyphs not any math-related feature. However, if you look at the sans serif math font from kpfonts, you'll notice the only real difference is in numbers and latin letters, so greek letters and other symbols do not appear different in normal math mode and in \mathsf, and for me this is ok. So really to achieve what I want I only need to swap the glyphs for numbers and latin letters.

Best Answer

You can easily map \mathsf to montserrat. But apart from some math in section titles I don't see why you would want to write e.g. the numbers as sans serif.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[light,onlyrm]{kpfonts}
\usepackage[light,scale=0.85]{montserrat}

\usepackage[sf,uppercase]{titlesec}

\newcommand*\elseries{\fontseries{el}\selectfont}

\titleformat*{\section}{\sffamily\elseries\large}

\SetMathAlphabet{\mathsf}    {normal}{T1} {Montserrat-LF} {l}{n}


\begin{document}
  \section{Section Title}\makeatletter
  A little piece of text, \textsf{with some sans serif parts}, and some math:
  \begin{equation*}
  e^{i\pi}+1=0
  \end{equation*}
  Plus some sans serif math:
  \begin{equation*}
  \mathsf{e^{i\pi}+1=0}
  \end{equation*}
  Good looking sans serif math:
  \begin{equation*}
  \text{\textsf{e}}^{\text{\textsf{i}}\pi} + \text{\textsf{1}} =
  \text{\textsf{1}}
  \end{equation*}

   \begin{equation*}
  \mathsf{e}^{\mathsf{i}\pi} + \mathsf{1} =
  \mathsf{1}
  \end{equation*}
\end{document}

enter image description here