如何在 html 文件中使用 MathJax 或 LaTex?

blo*_*ers 7 javascript latex mathjax

我无法让它工作,我不确定我做错了什么。

我已经下载了 MathJax.js,创建了一个 html 文件并将其适当地链接到 js 文件。我什至从这里复制并粘贴了之前回答的问题,然后将链接从 VPN(VPN 也不起作用,但问题和响应已经存在三年多了)更改为我机器上的 js 文件。

这是我的 html 中的内容:

<html>
   <head>
    <title>MathJax</title>
    <script type="text/x-mathjax-config">
    MathJax.Hub.Config({"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"] },
        tex2jax: { inlineMath: [ ["$", "$"], ["\\\\(","\\\\)"] ], displayMath: [ ["$$","$$"], ["\\[", "\\]"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno" },
        TeX: { noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } } },
        messageStyle: "none"
    });
    </script>    
    <script type="text/javascript" src="MathJax.js"></script>
    <script type="text/javascript" src="latest.js"></script>

  </head>
  <body>
     The definition of the Euler-Mascheroni constant is
     \gamma=\lim_{n\to\infty}\left(\sum_{k=1}^n\frac1k-ln(n)\right) 
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我将非常感谢任何帮助。

Pet*_*ger 5

有一些问题。

  • 如果不指定所谓的组合配置文件,则需要自己指定所有必需的组件。特别是输入、输出以及在您的情况下用于在页面中查找 TeX 标记的 TeX 预处理器
  • 如果您使用 TeX 输入,则需要将输入包装在您选择的分隔符中。

例如

    <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      jax: ["input/TeX", "output/HTML-CSS"],
      extensions: ["tex2jax.js"],
      "HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"] },
      tex2jax: { inlineMath: [ ["$", "$"], ["\\(","\\)"] ], displayMath: [ ["$$","$$"], ["\\[", "\\]"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno" },
      TeX: { noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } } },
      messageStyle: "none"
    });
    </script>    
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js"></script>

     The definition of the Euler-Mascheroni constant is
     $\gamma=\lim_{n\to\infty}\left(\sum_{k=1}^n\frac1k-ln(n)\right) $
Run Code Online (Sandbox Code Playgroud)

警告。我不知道latest.js应该做什么,而且您似乎正在使用本地安装,因此请务必检查文档,http://docs.mathjax.org/en/latest/installation.html