5

I'm using mathspec with XeLaTeX to typeset documents in a system font (Fira Sans but I don't think it matters). When I include punctuation and certain other symbols in math mode, they come out in Computer Modern.

I gather from this answer that this is a known issue with mathspec, and I can use the code there to fix the issue for periods, commas, and the like.

But the fix doesn't seem to work for dollar signs. Here's an MWE:

\documentclass{article}

\usepackage{mathspec}
\setallmainfonts{Fira Sans Light}

\makeatletter
\DeclareMathSymbol{&}{\mathord}{\eu@LatinLowercase@symfont}{`&}
\DeclareMathSymbol{$}{\mathpunct}{\eu@LatinLowercase@symfont}{`$}
\makeatother

\begin{document}
Ampersands look good in text mode \& also in math mode: $A \,\&\, B$.\\
But dollar signs should look like thi\$, not thi$\$$.
\end{document}

My output looks like this: enter image description here

Heading

1 Answers1

1

If you can live with "Fira Sans" rather than "Fira Sans Light" then the new "Fira Math" font mentioned in the OP comments, can make things much simpler, as you don't need to use mathspec at all.

On my Mac, after I have installed a selection of Fira fonts from here and installed "Fira Math" from the link above, so that my FontBook shows these:

enter image description here

then I can typeset with Fira Sans as body and maths font with plain unicode-math:

\documentclass{scrartcl}
\usepackage{unicode-math}
\setmainfont{Fira Sans}
\setsansfont{Fira Sans}
\setmathfont{Fira Math}
\begin{document}

\section{Heading}

Ampersands look good in text mode \& also in math mode: $A \mathbin{\&} B$.

\bigskip
\noindent
Dollar signs should look like thi\$ in text, and this in math $A \mathbin{\$} B$.

\end{document}

to produce:

enter image description here

Thruston
  • 42,268
  • 1
    You don’t need to download and install Fira Sans from GitHub, since CTAN already has fira. My suggestion of \usepackage[sfdefault]{FiraSans} will automatically detect the compile engine and use OpenType under XeLaTeX/LuaLaTeX. – Ruixi Zhang Oct 19 '18 at 22:11