【问题标题】:CSS for MathJaX?MathJaX 的 CSS?
【发布时间】:2013-10-16 21:12:03
【问题描述】:

当我使用 MathJax $\sum_{i=0}^n {n \choose i} D(i)$ 时,会被转换为标记。
MathML 仍然有效地使用Computer Modern - 标准 LaTeX 字体 - 每当您想要渲染方程时。

<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>

有没有办法指定要呈现标记的字体,例如&lt;mi&gt;&lt;mo&gt;。假设我想将Kite One 用于我字体中的变量,以免与我网站的其他部分发生冲突。

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

实际上,字体看起来很不错。但是如果需要,我该如何自定义 MathML?


编辑:我似乎在问 MathML 是否存在级联样式表

这个问题被认为是 tex.stackexchange 的题外话,此时可能是 StackOverflow 的问题

【问题讨论】:

    标签: javascript css fonts mathjax mathml


    【解决方案1】:

    虽然!important 在技术上是一种解决方案,但它并未得到 MathJax 的官方支持,因此无法可靠地工作。

    直到 v2.2(参见底部 >v2.2)在 MathJax 中官方支持的唯一 webfont 是它自己的 MathJax webfont(源自 Computer Modern),参见 http://docs.mathjax.org/en/latest/options/HTML-CSS.html

    如果您覆盖它,MathJax 将无法正确排版(尽管它会尽力而为)。这与一些技术限制有关。

    • 浏览器限制:无法通过 JavaScript 访问必要的字体指标(因此 MathJax 必须提供它们)
    • 字体限制(大多数字体不包含适合数学的字​​形)
    • 标准限制(一些用于可拉伸字符的字形没有等效的 unicode,数学字体通常使用 Microsoft 的 OpenType 数学表,但这不是 OpenType 的正式组成部分。此外,没有浏览器支持数学表)。

    话虽如此,即将发布的 MathJax v2.3 版本将添加更多字体选项。

    【讨论】:

    • 我有一个related question,说明使用特定字体执行此操作的后果。
    【解决方案2】:

    当然。您只需在 CSS 中使用 !important 属性,否则 MathJaX 会覆盖它。

    例子:

    <!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>
    

    【讨论】:

    • 我有一个related question,关于使用特定字体执行此操作的后果。
    • 来自未来的注意事项:cdn.mathjax.org 即将结束生命周期,请查看mathjax.org/cdn-shutting-down 以获取迁移提示(也许为未来的读者更新您的帖子)。
    猜你喜欢
    • 2014-03-02
    • 1970-01-01
    • 1970-01-01
    • 2014-01-06
    • 2015-07-09
    • 2013-04-04
    • 2020-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多