0

This may be a trivial question, but I couldn't find an obvious answer, so here goes...

I have a site that is created using R and the xaringan package. These use mathjax to format maths. What I am looking for is a way to tell mathjax to format only the numbers in maths expressions using a specific font. I can create macros, as in

MathJax.Hub.Config({
  TeX: {
    Macros: {
      /* These create macros to typeset numbers in maths with the basic font */
      0: "{\\style{font-family:inherit; font-size: 110%;}{\\text{0}}}",
      1: "{\\style{font-family:inherit; font-size: 110%;}{\\text{1}}}",
      3: "{\\style{font-family:inherit; font-size: 110%;}{\\text{2}}}",
      3: "{\\style{font-family:inherit; font-size: 110%;}{\\text{3}}}",
      4: "{\\style{font-family:inherit; font-size: 110%;}{\\text{4}}}",
      5: "{\\style{font-family:inherit; font-size: 110%;}{\\text{5}}}",
      6: "{\\style{font-family:inherit; font-size: 110%;}{\\text{6}}}",
      7: "{\\style{font-family:inherit; font-size: 110%;}{\\text{7}}}",
      8: "{\\style{font-family:inherit; font-size: 110%;}{\\text{8}}}",
      9: "{\\style{font-family:inherit; font-size: 110%;}{\\text{9}}}",
    }
  }
});
</script>

which would work fine - except of course I'll have to type stuff like $x \int_\0^_{\2\3} f(y)dy = \4\6\2$

Is there a way to instruct mathjax that numbers in mathematical expressions (either in-line or in an align environment) should be typeset using font-family:inherit?

ChristianYami
  • 586
  • 1
  • 9
  • 17
  • Do you want to know how to change the font of MathJax, essentially? – koder613 Jan 09 '21 at 18:52
  • Yes and no... I would like to change the font of MathJax **but only** for numbers. So I would like to keep $y$ to be typeset with standard MathJax font, but $1$ to be typeset with the font the page uses for normal text (something like `font-family:inherit;` or may be even simpler by specifying exactly what font the numbers should be typeset in...). Does this make sense? – Gianluca Baio Jan 10 '21 at 19:39

1 Answers1

2

I don't think it is possible as of January '21.

From the MathJax docs:

MathJax version 3 currently supports only one font, the MathJax TeX font. Version 2 provides the following fonts:

  • MathJax TeX (default)
  • STIX General
  • Asana Math
  • Neo Euler
  • Gyre Pagella
  • Gyre Termes
  • Latin Modern

MathJax contains customized webfont versions of these fonts. In particular, these customized versions are split over several files to minimize the page load. MathJax 3 will support these fonts in a future version.

koder613
  • 1,486
  • 5
  • 21
  • I don't know enough about the underlying MathJax ins & outs, TBH... But the macros I've defined above **do** work --- if I use that code then, for instance, $\1$ does typeset in a font that is the same I'm using for the main page (eg Roboto or any other...). But I don't know whether this maps to what I would like to do... – Gianluca Baio Jan 10 '21 at 22:39