【问题标题】:How to write equations in html? [closed]如何在html中编写方程式? [关闭]
【发布时间】:2012-09-08 00:30:37
【问题描述】:

我想在我的网页上写一些复杂的数学方程式。有什么插件或任何东西吗?

【问题讨论】:

    标签: html equation


    【解决方案1】:

    试试 mathjax http://www.mathjax.org/ 。我个人觉得很好。

    【讨论】:

      【解决方案2】:

      对于复杂方程,MathJax 是当前实用的解决方案。 MathML 原则上是一种结构性更强的方法,但对浏览器的支持相当有限,而且通常质量有问题。

      但是,复杂性是相对的。对某些人来说,E = mc² 或 ∂/∂t + v ⋅ ∇ 可能很复杂,在 CSS 的帮助下,仅使用 HTML 就可以很好地编写这样的结构;查看我的页面Math in HTML (and CSS)。

      【讨论】:

      • 我修复了链接。
      【解决方案3】:

      如果您不想在 HTML 中实现任何 JavaScript,可以使用 CodeCogs 的方程式编辑器工具 (http://www.codecogs.com/latex/about.php)。

      它真的很容易使用。您所要做的就是使用按钮界面来编写您的方程式,并立即生成一个 HTML 图像链接。当您运行 HTML 时,图像将在 CodeCogs 的服务器上生成并在您的站点中实施。这是一个非常舒适的工具。

      【讨论】:

        【解决方案4】:

        使用mathjax 的快速示例:

        加载 CDN:(确保指定 ?config= 选项,因为它不包含在 recommended cdn link 中 - default 工作正常):

        <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=default'></script>
        

        然后,在您的 html 中,只需将公式包含在 $$ {equation here} $$ 中

        例如$$ {J(\theta) =\frac{1}{2m} [\sum^m_{i=1}(h_\theta(x^{(i)}) - y^{(i)})2 + \lambda\sum^n_{j=1}\theta^2_j} $$

        它应该在页面上显示为一个方程。

        【讨论】:

        • 我可以用文本内联的方式编写我的方程式吗?
        【解决方案5】:

        你可以试试这个。有点过时了,所以不确定它是如何工作的:

        http://www.w3.org/Math/

        对于 Firefox,他们在 MathML 上有一篇描述性很强的文章

        【讨论】:

          【解决方案6】:

          我知道这有点晚了。但我想提一下 jqMath,我个人认为它比 MathJax 更简单、更轻量级。

          在此处查找详细信息:https://mathscribe.com/author/jqmath.html

          文件可以从https://mathscribe.com/downloads/mathscribe-win-0.4.6.zip下载

          要使用它,

          1. 解压下载的文件
          2. 找到文件 jqmath-etc-0.4.6.min.js 和 jqmath-0.4.3.css,并将它们包含在您的 html 中
          3. 确保您的 html 在 &lt;head&gt; 部分中有 &lt;meta charset="utf-8"&gt;。
          4. 在使用这些之前还包括 jQuery。

          现在您可以在 html 或网页中编写数学方程式和公式。

          访问以上链接了解更多关于如何使用 jqMath 编写数学公式的信息。

          【讨论】:

            【解决方案7】:

            您可以使用 KaTeX https://katex.org/。 只需复制并粘贴 head 标签中的内容并将其粘贴到您的 html 文件中。 身体内部进入乳胶内部\(latex code here\)。你可以在 GitHub 上查看它,它比 MathJax 更快。我参考了javascript Katex not rendering你可以在Github上查看。它适用于主要浏览器下面是带有自动渲染选项的示例代码。

            <!DOCTYPE html>
            <!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
            <html>
              <head>
                <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0-rc.1/dist/katex.min.css" integrity="sha384-D+9gmBxUQogRLqvARvNLmA9hS2x//eK1FhVb9PiU86gmcrBrJAQT8okdJ4LMp2uv" crossorigin="anonymous">
            
                <!-- The loading of KaTeX is deferred to speed up page rendering -->
                <script src="https://cdn.jsdelivr.net/npm/katex@0.10.0-rc.1/dist/katex.min.js" integrity="sha384-483A6DwYfKeDa0Q52fJmxFXkcPCFfnXMoXblOkJ4JcA8zATN6Tm78UNL72AKk+0O" crossorigin="anonymous"></script>
            
                <!-- To automatically render math in text elements, include the auto-render extension: -->
                <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0-rc.1/dist/contrib/auto-render.min.js" integrity="sha384-yACMu8JWxKzSp/C1YV86pzGiQ/l1YUfE8oPuahJQxzehAjEt2GiQuy/BIvl9KyeF" crossorigin="anonymous"
                    onload="renderMathInElement(document.body);"></script>
              </head>
              <body>
                  <p>\(x^2 = \sqrt{y}\)</p><br>
                  <p style="color:blue;font-size:25px;">\(\frac {-b\pm\sqrt{b^2 - 4ac}}{2a}\)</P>
              </body>
            </html>

            【讨论】:

              猜你喜欢
              • 2013-07-07
              • 2011-07-11
              • 1970-01-01
              • 2016-09-19
              • 2011-03-07
              • 2011-07-15
              • 2015-11-26
              • 2020-07-08
              • 2013-07-04
              相关资源
              最近更新 更多