Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

r - Change font of numbers *only*

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_^_{23} f(y)dy = 462$

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...