4

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

  • Welcome to TeX.SX! Perhaps this related post regarding \% can help. It is also worth mentioning that Fira Math is now on CTAN, so an alternative would be \usepackage[sfdefault]{FiraSans}\usepackage{unicode-math}\setmathfont{Fira Math}. – Ruixi Zhang Oct 19 '18 at 2:37
  • But Fira Math might look a bit heavy with Fira Light.... – Thruston Oct 19 '18 at 9:07
  • Might try the workaround of \mathrm{\$}. – Davislor Oct 19 '18 at 20:47
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

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.