I want to change the math fonts from the standard latex fonts to a font that matches more closely to my text font (as I am using a custom font for the text). However, I do not want to use the text font in math mode because the text font has issues with overlapping etc...
I believe the solution is to just choose an existing math font that goes well with my text font. Here is a minimal example of how I am doing this:
\documentclass[a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage{mathspec}
\setmathfont(Digits,Latin,Greek){Latin Modern Math}
\begin{document}
Let $\mathbf{x} \in \mathcal{X}$, $\pi \in \Pi$, and $\gamma \in [0,1]$. Now, see the following example equation:
\begin{align}
J(\mathbf{x}) = \mathbb{E} \left[ \sum_{i=0}^{N-1} \gamma^i c(\mathbf{x}_i, \pi(\mathbf{x})) \right]
\end{align}
\end{document}
In the example, I use Latin Modern Math, but how do I see a list of the available fonts for mathspec?
Note: I am compiling using XeLaTeX using Overleaf.
mathspecis a package specifically for using text fonts for mathematics (As you already realized, this is always a bit problematic and it is better to use a real math font instead). If you want to use a math font for math, you should useunicode-mathinstead. – Marcel Krüger Jul 05 '21 at 16:45mathspecas I was able to get the math font to show properly. – Ralff Jul 05 '21 at 16:48{mathspec}with{unicode-math}and remove(Digits,Latin,Greek). (Latin Modern Math looks rather similar to the default math setup though, so it's not very obvious. But the font is not supposed to look like in yourmathspecexample where most operators come from other fonts and default letters are upright.) – Marcel Krüger Jul 05 '21 at 17:00