I was trying to change fonts in my document but run into some problems:

  1. It seems that the custom font I am using does not support numbers (and symbols) in math mode and instead the default font is being used.
  2. The same problems appears in the axes: ticks values are displayed in the default font and not in the custom font.

I know for sure that all the fonts in question (and especially Harding Text Web that I am using for maths) support all the symbols, greek letters, and numbers that I would ever need in my document.

My intention is to use some of the fonts I have installed on my computer. I am aware that I could e.g. swap my 'system' Roboto to the roboto TeX package. But this is impossible with some other fonts.
Something I noticed: using the ASCII symbol for e.g. sigma inside\mathrm works, but \sigma reverts to the default font anyway. I do not see myself looking up all the UTF/ASCII codes for all symbols and numbers...
I am using TeXShop with XeLaTeX.

Excerpt from the document

Notice how the zeros, infinity symbol, and the greek letters are in Computer Modern

My code:

\documentclass[12pt, oneside]{article}
\usepackage[a4paper, margin=1.5in]{geometry}

%----- Custom font -------------
\setmainfont{Harding Text Web}

%----- Include maths -----

%----- Sans math, math as text --------

%----- Custom commands -------------
\newcommand{\T}{\textrm{\sf T}}
\newcommand{\Gramian}{\textbf{W}_{\rm c}}



$$ \A_{\rm norm} = \frac{\A}{\lambda(\A)_{\rm max} + c} - \textbf{I} $$
where $\lambda(\A)_{\rm max}$ denotes the largest eigenvalue of $\A$ and $\textbf{I}$ is the identity matrix. 

\subsection*{Controllability Gramian}

$$ \Gramian = \int_{0}^{\infty} \exp(\A\tau)\B\B^\T \exp(\A^\T\tau) \de \tau $$
where $^\T$ denotes the transpose of a matrix.

Alternatively, we can obtain the controllability Gramian $ \textbf{W}_{\rm c} $ by solving the Lyapunov equation:
$$ \A\textbf{W}_{\rm c} + \textbf{W}_{\rm c}\A^\T + \B\B^\T = 0$$
limitation being that it can be only applied to stable systems.

  • 1
    math font setup and text font setup are two quite different things. Providing symbols is not enough: A math font needs a number of additional font dimension which are typically not present in a text fonts. While it is possible to exchange many of the math symbols by symbols taken from the text font, it is imho better to use a real math font with unicode math everywhere and stick to it. Jan 20, 2021 at 9:15
  • Okay, so I found a workaround: I took my .ttf and constructed a font family (.tfm, .fd, etc.) from scratch using this script: devnotcorp.wordpress.com/2011/06/10/…. Thanks for help! Jan 20, 2021 at 12:13
  • as far as I can see the script only creates a text font (T1-encoding), this won't help for various math symbols either. Jan 20, 2021 at 12:18
  • It solved the problem that the numbers in math mode were drawn from Computer Modern (in LaTeX). In XeLaTeX, I am getting a better support and range of symbols, but numbers and symbols are still in CM... However, when I use \textrm (or \textit) in math mode all numbers and symbols are drawn from the custom font and everything works. Perhaps I will just need a macro that will append \textit to all equations... Jan 20, 2021 at 12:47
  • Exchanging the numbers and other symbols are easier with unicode-math Jan 20, 2021 at 12:53

1 Answer 1


While I don’t have the fonts to test, the following usually works:


\setmainfont{Harding Text Web}[Scale=1.0]
\setmathfont{STIX Two Math}
\setmathfont{STIX Two Math}[range={scr,bfscr}, StylisticSet=1] % Set up \mathscr and \mathcal
\setmathfont{Harding Text Web}[range=up}
\setmathfont{Harding Text Web Italic}[range=it] % Or whatever the Italic font is called.
\setmathfont{Harding Text Web Bold}[range=bfup]
\setmathfont{Harding Text Web Bold Italic}[range=bfit]
% Similarly set sfup, sfit, bfsfup, bfsfit and tt if you need them.

You might find another math font that matches Harding Text better. In particular, it has a high x-height, a flared style, and avoids thin stems. You might try TeX Gyre Bonum Math, TeX Gyre Schola Math or TeX Gyre DejaVu Math.

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.