[Tex/LaTex] Looking for Math Font to match IBM Plex Serif / Sans

fontsmath-fonts

The Question

Hi, I've recently decided to switch over to IBM Plex, and while computer modern is very nice, it doesn't go too well with Plex it seems, and I'm not sure what I can do with regards to maths fonts.

Edit: I'm using pdfLaTeX

I'm looking for either good alternatives from people who have seen / know more than me, and / or some way of finding out what's available. (Most of my google searches have returned results comparing \mathrm etc.)

Demos

Plex Serif

enter image description here

Plex Sans

enter image description here

Best Answer

Thanks to @Ross showing me mathastext I reckon I've got a working solution.

Solution

Math Symbols

\usepackage{fourier}

In my opinion, fourier's symbols matches better stylistically, however I don't want to keep the font-related changes so I add it first (so that the other font packages overwrite that).

Math Font

\usepackage{plex-serif}

I want to use a serif font for the math, so I add this after fourier so that it overwrites it, and before mathastext so that it's actually used for the maths

Apply the font to math

\usepackage[basic,italic,symbolgreek]{mathastext}

mathastext seems good, but to me it had a few issues when used without any options.

  1. Brackets for matrices, when multiline brackets were required mathastext just grabbed the [] characters used by the font, and didn't do anything to make them multiline. This was fixed by adding the basic option — though this also had the effect of no replacing a few other symbols (a worthwhile price in my mind)
  2. Non-italic math by default. This was an easy fix: italic
  3. Not using the greek letters from the font. Once again easy fix: symbolgreek
  4. Bad kerning / overlapping (or crammed) letters

To solve the last issue I used another command, seen at the end of this mini-section.

Text Font

\usepackage[sfdefault]{plex-sans}

After the serif variant has been set to be used in math by mathastext I change to the sans font I want to use for the rest of the document.

Spacing Issues

By default, the spacing was the same as italic/slanted text. Which is an issue for math because it can cause overlaps/cramping. To see this in action I drew vertical rules of width 0.1ex with \hspace{-0.1ex} after them, producing Demo For most letters adding 0.5mu of space either side fixed things up, however letters with 'tails' required some extra attention. After some tweaking I managed to get this: Fixed(sort of)

While I wouldn't consider this 'fixed' it's better. This is the code used (sans):

\makeatletter
\@for\@tempa:=a,b,c,d,e,h,i,k,l,m,n,o,q,r,s,t,u,v,w,x\do{%
\MTsetmathskips{\@tempa}{0.5mu}{0.5mu}}%
\makeatother

\MTsetmathskips{f}{2.5mu}{0.5mu}
\MTsetmathskips{g}{1.5mu}{0.5mu}
\MTsetmathskips{j}{2.5mu}{0.5mu}
\MTsetmathskips{p}{1.5mu}{0mu}
\MTsetmathskips{y}{1.5mu}{0.5mu}
\MTsetmathskips{z}{1mu}{0.5mu}

And then for the serif version:

 \makeatletter
 \@for\@tempa:=a,b,c,d,e,h,i,k,l,m,n,o,q,r,t,u,v,w\do{%
 \MTsetmathskips{\@tempa}{0.5mu}{0.5mu}}%
 \makeatother

 \MTsetmathskips{f}{4.5mu}{0.5mu}
 \MTsetmathskips{g}{2.5mu}{0.5mu}
 \MTsetmathskips{j}{4mu}{0.5mu}
 \MTsetmathskips{p}{2.5mu}{0mu}
 \MTsetmathskips{s}{1mu}{0.5mu}
 \MTsetmathskips{x}{1.5mu}{0.5mu}
 \MTsetmathskips{y}{3.5mu}{0.5mu}
 \MTsetmathskips{z}{1.5mu}{0.5mu}
Before

Before

After

After

It's minor but it's an improvement

All together

\usepackage{fourier}
\usepackage{plex-serif}
\usepackage[basic,italic,symbolgreek]{mathastext}
\usepackage[sfdefault]{plex-sans}

\makeatletter
\@for\@tempa:=a,b,c,d,e,h,i,k,l,m,n,o,q,r,s,t,u,v,w,x\do{%
\MTsetmathskips{\@tempa}{0.5mu}{0.5mu}}%
\makeatother

\MTsetmathskips{f}{2.5mu}{0.5mu}
\MTsetmathskips{g}{1.5mu}{0.5mu}
\MTsetmathskips{j}{2.5mu}{0.5mu}
\MTsetmathskips{p}{1.5mu}{0mu}
\MTsetmathskips{y}{1.5mu}{0.5mu}
\MTsetmathskips{z}{1mu}{0.5mu}

Result

Serif

\usepackage[sfdefault]{plex-sans}
\usepackage[basic,italic,symbolgreek]{mathastext}

Serif

Sans

\usepackage{plex-serif}
\usepackage[basic,italic,symbolgreek]{mathastext}

Sans

Mixed

\usepackage{plex-serif}
\usepackage[basic,italic,symbolgreek]{mathastext}
\usepackage[sfdefault]{plex-sans}

Mixed

Related Question