簡體   English   中英

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

[英]How can I use MathJax or LaTex in an html file?

我無法讓它工作,我不確定我做錯了什么。

我已經下載了 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>

我將不勝感激任何幫助。

有幾個問題。

  • 如果不指定所謂的組合配置文件,則需要自己指定所有必要的組件。 特別是,輸入、輸出以及在您的情況下是 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) $

警告。 我不知道latest.js應該做什么,而且您似乎正在使用本地安裝,所以一定要檢查文檔, http://docs.mathjax.org/en/latest/installation.html

這是我從文檔示例中構建的文件

 <html> <head> <!-- See http://docs.mathjax.org/en/latest/web/start.html#using-mathjax-from-a-content-delivery-network-cdn --> <script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"> </script> </head> <body> <p> From the <a href="https://www.w3.org/Math/MJ/Overview.html">overview docs</a>, in MathML: Let's consider <math><mi>a</mi><mo>≠</mo><mn>0</mn></math>. </p> <p> With <a href="http://docs.mathjax.org/en/latest/basic/mathematics.html">\\(\\LaTeX\\) input</a>: 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}.$$ </p> </body> </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM