Question

When I use MathJax $\sum_{i=0}^n {n \choose i} D(i)$ gets converted into markup.
MathML still effectively uses Computer Modern - standard LaTeX font - whenever you want to render an equation.

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <munderover>
    <mo>&#x2211;<!-- ∑ --></mo>
    <mrow class="MJX-TeXAtom-ORD">
      <mi>i</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>n</mi>
  </munderover>
  <mrow class="MJX-TeXAtom-ORD">
    <mrow>
      <mo>(</mo>
      <mfrac linethickness="0">
        <mi>n</mi>
        <mi>i</mi>
      </mfrac>
      <mo>)</mo>
    </mrow>
  </mrow>
  <mi>D</mi>
  <mo stretchy="false">(</mo>
  <mi>i</mi>
  <mo stretchy="false">)</mo>
</math>

Are there ways to specify which font to render tokens like <mi> or <mo>. Let's say I'd like to use Kite One for the variables in my font, so as not to clash with the rest of my web site.

http://content.altfonts.com:81/img/K/I/Kite-Onea.png

Actually, the fonts look really nice. But how could I customize MathML if I needed to?


EDIT: I seem to be asking if Cascading Style Sheets exist for MathML

This question as considered off-topic for tex.stackexchange it may be a question for StackOverflow at this point

Was it helpful?

Solution 2

Sure. You just have to use the !important attribute in your CSS, as MathJaX will override it otherwise.

Example:

<!DOCTYPE html>
<html>
  <head>
    <title>MathJax TeX Test Page</title>
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
    </script>
    <script type="text/javascript"
        src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
    </script>
    <style type="text/css">
      .mi {
      font-family: 'Helvetica' !important;
      }

    </style>

  </head>
  <body>
    When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
    $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
  </body>
</html>

OTHER TIPS

While !important is technically a solution, it is not officially supported by MathJax and will not work reliably.

The only webfont officially supported in MathJax up to v2.2 (see bottom for >v2.2) is its own MathJax webfont (derived from Computer Modern), see http://docs.mathjax.org/en/latest/options/HTML-CSS.html.

If you override this, MathJax will not be able to typeset correctly (though it will try its best). This has to do with several technical limitations.

  • browser limitations: necessary font metrics are not accessible via JavaScript (so MathJax has to ship them)
  • font limitations (most fonts do not contain suitable glyphs for mathematics)
  • standards limitations (some glyphs used for stretchy characters have no unicode equivalent, math fonts often use Microsoft's OpenType math tables but this is not officially part of OpenType. Also, no browser supports math tables).

That being said, the upcoming MathJax v2.3 release will add a more font options.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top