mathjax 相关问题

MathJax是一个开源JavaScript引擎,可以轻松地在网页上嵌入数学方程式,符号和公式。还有一个服务器端版本,它为MathJax提供命令行和nodejs接口。

SVG 路径大小和位置不正确

我正在生成一个 SVG 文档,并且有一个从 LaTeX 生成 SVG 的库。 我正在生成一个 SVG 文档,并且有一个从 LaTeX 生成 SVG 的库。 <svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" width="500px" height="300px" id="svgSurface"> <svg viewBox="0 -883.9 1186.6 883.9" x="0" y="0" width="100"> <defs> <path id="MJX-1-TEX-N-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path> <path id="MJX-1-TEX-N-48" d="M128 622Q121 629 117 631T101 634T58 637H25V683H36Q57 680 180 680Q315 680 324 683H335V637H302Q262 636 251 634T233 622L232 500V378H517V622Q510 629 506 631T490 634T447 637H414V683H425Q446 680 569 680Q704 680 713 683H724V637H691Q651 636 640 634T622 622V61Q628 51 639 49T691 46H724V0H713Q692 3 569 3Q434 3 425 0H414V46H447Q489 47 498 49T517 61V332H232V197L233 61Q239 51 250 49T302 46H335V0H324Q303 3 180 3Q45 3 36 0H25V46H58Q100 47 109 49T128 61V622Z"></path> </defs> <g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1,0,0,-1,0,0)"> <g data-mml-node="math"> <g data-mml-node="msup"> <g data-mml-node="mi"></g> <g data-mml-node="TeXAtom" transform="translate(33,413) scale(0.707)" data-mjx-texclass="ORD"> <g data-mml-node="mn"> <use data-c="31" xlink:href="#MJX-1-TEX-N-31"></use> </g> </g> </g> <g data-mml-node="mtext" transform="translate(436.6,0)"> <use data-c="48" xlink:href="#MJX-1-TEX-N-48"></use> </g> </g> </g> </svg> </svg> 它本质上是一个引用 defs 中路径的组。我希望能够调整整个嵌入 SVG 部分的大小。我设置了 x 和 y,没有任何反应,我将宽度设置为 100 并且它调整大小,不是 100 而是 90。什么并且也改变了高度?我知道 <g> 填充了它的容器,但它似乎也影响了容器? https://jsfiddle.net/thk9cago/ 我希望嵌入 SVG 中的内容能够根据 x、y 和宽度属性调整大小和位置。 首先要注意的是,嵌入的 SVG 有一个 viewBox 属性,这会带来几个后果。首先,这意味着如果您指定其尺寸之一而不是另一个,那么第二个尺寸将被缩放以保持纵横比,就像图像一样。因此,当您将宽度设置为 100 时,高度也会缩放。 其次,这意味着嵌套SVG的定位由preserveAspectRatio属性决定。这说明了如何在周围的 SVG 中放置和缩放嵌套的 SVG。默认值为 xMidYMid,它应将嵌套的 SVG 置于外部 SVG 的中心。然而,显然,设置 width 会覆盖 x 定位,并且最终会左对齐(同样,设置 height 将覆盖默认的 y 定位)。您可能需要使用 preserveAspectRatio="xMinYMin" 将嵌套的 svg 放置在左上角: <svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" width="500px" height="300px" id="svgSurface" style="background-color: yellow; border: 1px solid black"> <svg viewBox="0 -883.9 1186.6 883.9" x="0" y="0" width="100" preserveAspectRatio="xMinYMin"> <defs> <path id="MJX-1-TEX-N-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path> <path id="MJX-1-TEX-N-48" d="M128 622Q121 629 117 631T101 634T58 637H25V683H36Q57 680 180 680Q315 680 324 683H335V637H302Q262 636 251 634T233 622L232 500V378H517V622Q510 629 506 631T490 634T447 637H414V683H425Q446 680 569 680Q704 680 713 683H724V637H691Q651 636 640 634T622 622V61Q628 51 639 49T691 46H724V0H713Q692 3 569 3Q434 3 425 0H414V46H447Q489 47 498 49T517 61V332H232V197L233 61Q239 51 250 49T302 46H335V0H324Q303 3 180 3Q45 3 36 0H25V46H58Q100 47 109 49T128 61V622Z"></path> </defs> <g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1,0,0,-1,0,0)"> <g data-mml-node="math"> <g data-mml-node="msup"> <g data-mml-node="mi"></g> <g data-mml-node="TeXAtom" transform="translate(33,413) scale(0.707)" data-mjx-texclass="ORD"> <g data-mml-node="mn"> <use data-c="31" xlink:href="#MJX-1-TEX-N-31"></use> </g> </g> </g> <g data-mml-node="mtext" transform="translate(436.6,0)"> <use data-c="48" xlink:href="#MJX-1-TEX-N-48"></use> </g> </g> </g> </svg> </svg> 您的 x 和 y 属性正在工作,但它们相对于默认位置(在您的情况下是左齐平并垂直居中)。使用 xMinYMin 设置时,它们相对于左上角,如下例所示: <svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" width="500px" height="300px" id="svgSurface" style="background-color: yellow; border: 1px solid black"> <svg viewBox="0 -883.9 1186.6 883.9" x="150" y="75" width="100" preserveAspectRatio="xMinYMin"> <defs> <path id="MJX-1-TEX-N-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path> <path id="MJX-1-TEX-N-48" d="M128 622Q121 629 117 631T101 634T58 637H25V683H36Q57 680 180 680Q315 680 324 683H335V637H302Q262 636 251 634T233 622L232 500V378H517V622Q510 629 506 631T490 634T447 637H414V683H425Q446 680 569 680Q704 680 713 683H724V637H691Q651 636 640 634T622 622V61Q628 51 639 49T691 46H724V0H713Q692 3 569 3Q434 3 425 0H414V46H447Q489 47 498 49T517 61V332H232V197L233 61Q239 51 250 49T302 46H335V0H324Q303 3 180 3Q45 3 36 0H25V46H58Q100 47 109 49T128 61V622Z"></path> </defs> <g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1,0,0,-1,0,0)"> <g data-mml-node="math"> <g data-mml-node="msup"> <g data-mml-node="mi"></g> <g data-mml-node="TeXAtom" transform="translate(33,413) scale(0.707)" data-mjx-texclass="ORD"> <g data-mml-node="mn"> <use data-c="31" xlink:href="#MJX-1-TEX-N-31"></use> </g> </g> </g> <g data-mml-node="mtext" transform="translate(436.6,0)"> <use data-c="48" xlink:href="#MJX-1-TEX-N-48"></use> </g> </g> </g> </svg> </svg> 宽度也起作用,但请注意,缩放的是 viewBox,而不是内容的边界框,内容可能更大或更小。请注意,在您的情况下,看起来您使用了类似 {}^1\mathrm{H} 的内容,因此上标 1 之前有一点空格,因为 TeX 在底数(甚至是空的)和上标之间放置了一点空格。您可以在下面的示例中看到这一点,该示例只有带有背景颜色的内部 SVG。 <svg viewBox="0 -883.9 1186.6 883.9" width="100" style="background-color:red"> <defs> <path id="MJX-1-TEX-N-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path> <path id="MJX-1-TEX-N-48" d="M128 622Q121 629 117 631T101 634T58 637H25V683H36Q57 680 180 680Q315 680 324 683H335V637H302Q262 636 251 634T233 622L232 500V378H517V622Q510 629 506 631T490 634T447 637H414V683H425Q446 680 569 680Q704 680 713 683H724V637H691Q651 636 640 634T622 622V61Q628 51 639 49T691 46H724V0H713Q692 3 569 3Q434 3 425 0H414V46H447Q489 47 498 49T517 61V332H232V197L233 61Q239 51 250 49T302 46H335V0H324Q303 3 180 3Q45 3 36 0H25V46H58Q100 47 109 49T128 61V622Z"></path> </defs> <g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1,0,0,-1,0,0)"> <g data-mml-node="math"> <g data-mml-node="msup"> <g data-mml-node="mi"></g> <g data-mml-node="TeXAtom" transform="translate(33,413) scale(0.707)" data-mjx-texclass="ORD"> <g data-mml-node="mn"> <use data-c="31" xlink:href="#MJX-1-TEX-N-31"></use> </g> </g> </g> <g data-mml-node="mtext" transform="translate(436.6,0)"> <use data-c="48" xlink:href="#MJX-1-TEX-N-48"></use> </g> </g> </g> </svg> DOM 检查器可能会为您提供内容的宽度,而不是 viewBox,后者约为 91 像素。 最后,请注意,如果您同时提供 width 和 height 属性,则会保持长宽比(按照默认 preserveAspectRatio 设置的要求),因此即使 svg 元素具有不同的大小,内容也会保持不变。将具有原始纵横比,并将缩放至适合 width 和 height 设置的最大尺寸。例如: <svg viewBox="0 -883.9 1186.6 883.9" width="75" height="150" style="background-color:red"> <defs> <path id="MJX-1-TEX-N-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path> <path id="MJX-1-TEX-N-48" d="M128 622Q121 629 117 631T101 634T58 637H25V683H36Q57 680 180 680Q315 680 324 683H335V637H302Q262 636 251 634T233 622L232 500V378H517V622Q510 629 506 631T490 634T447 637H414V683H425Q446 680 569 680Q704 680 713 683H724V637H691Q651 636 640 634T622 622V61Q628 51 639 49T691 46H724V0H713Q692 3 569 3Q434 3 425 0H414V46H447Q489 47 498 49T517 61V332H232V197L233 61Q239 51 250 49T302 46H335V0H324Q303 3 180 3Q45 3 36 0H25V46H58Q100 47 109 49T128 61V622Z"></path> </defs> <g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1,0,0,-1,0,0)"> <g data-mml-node="math"> <g data-mml-node="msup"> <g data-mml-node="mi"></g> <g data-mml-node="TeXAtom" transform="translate(33,413) scale(0.707)" data-mjx-texclass="ORD"> <g data-mml-node="mn"> <use data-c="31" xlink:href="#MJX-1-TEX-N-31"></use> </g> </g> </g> <g data-mml-node="mtext" transform="translate(436.6,0)"> <use data-c="48" xlink:href="#MJX-1-TEX-N-48"></use> </g> </g> </g> </svg> 如果要独立缩放两个维度,则需要使用preserveAspectRatio="none"。 <svg viewBox="0 -883.9 1186.6 883.9" width="75" height="150" preserveAspectRatio="none" style="background-color:red"> <defs> <path id="MJX-1-TEX-N-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path> <path id="MJX-1-TEX-N-48" d="M128 622Q121 629 117 631T101 634T58 637H25V683H36Q57 680 180 680Q315 680 324 683H335V637H302Q262 636 251 634T233 622L232 500V378H517V622Q510 629 506 631T490 634T447 637H414V683H425Q446 680 569 680Q704 680 713 683H724V637H691Q651 636 640 634T622 622V61Q628 51 639 49T691 46H724V0H713Q692 3 569 3Q434 3 425 0H414V46H447Q489 47 498 49T517 61V332H232V197L233 61Q239 51 250 49T302 46H335V0H324Q303 3 180 3Q45 3 36 0H25V46H58Q100 47 109 49T128 61V622Z"></path> </defs> <g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1,0,0,-1,0,0)"> <g data-mml-node="math"> <g data-mml-node="msup"> <g data-mml-node="mi"></g> <g data-mml-node="TeXAtom" transform="translate(33,413) scale(0.707)" data-mjx-texclass="ORD"> <g data-mml-node="mn"> <use data-c="31" xlink:href="#MJX-1-TEX-N-31"></use> </g> </g> </g> <g data-mml-node="mtext" transform="translate(436.6,0)"> <use data-c="48" xlink:href="#MJX-1-TEX-N-48"></use> </g> </g> </g> </svg> 我希望这能澄清您所经历的情况。

回答 1 投票 0

用R闪亮的MathJax方程转换为word文档

我有一个闪亮的 R 应用程序,其中包含许多带有 withMathJax 包的方程。例如: 标签$div(HTML(" MathJax.Hub.Config({ tex2jax:{</desc> <question vote="0"> <p>我有一个闪亮的 R 应用程序,其中包含许多带有 <pre><code>withMathJax</code></pre> 包的方程。例如:</p> <pre><code> tags$div(HTML(&#34;&lt;script type=&#39;text/x-mathjax-config&#39; &gt; MathJax.Hub.Config({ tex2jax: {inlineMath: [[&#39;$&#39;,&#39;$&#39;]]} }); &lt;/script &gt;&#34;)), p(withMathJax(&#34;$$n_{\\sf egg_{\\it i}} \\sim {\\sf negative\\,binomial}(\\lambda_{\\sf fecund}, k_{\\sf fecund})$$&#34;), style=&#34;text-align: center; font-size:20px;&#34;), </code></pre> <p>退货</p> <p><a href="https://i.stack.imgur.com/5Egfv.png" target="_blank"><img src="https://cdn.txt58.com/i/AWkuc3RhY2suaW1ndXIuY29tLzVFZ2Z2LnBuZw==" alt=""/></a></p> <p>我需要在Word文档中重现所有方程。我可以手动重新创建所有这些,但以编程方式执行此操作会简单得多(特别是当方程发生变化时)。</p> <p>我希望使用pandoc将MathJax转换为LaTeX(类似这样的:<a href="https://stackoverflow.com/a/20501901/9096420">https://stackoverflow.com/a/20501901/9096420</a>),因为word似乎有一个LaTeX选项,但我不知道如何让它发挥作用。有人有更好的主意吗?</p> <hr/> <p>这是我尝试过的:</p> <p>我已经从这里安装了“pandoc-3.1.11.1-windows-x86_64.zip”<a href="https://github.com/jgm/pandoc/releases/tag/3.1.11.1" rel="nofollow noreferrer">https://github.com/jgm/pandoc/releases/tag/3.1.11.1</a>并将其解压缩到我选择的目录中。 按照这个答案对另一个问题(<a href="https://stackoverflow.com/a/29109007/9096420">https://stackoverflow.com/a/29109007/9096420</a>),我在PowerShell中设置了路径:</p> <pre><code>$PATH = [Environment]::GetEnvironmentVariable(&#34;PATH&#34;) $pandoc_path = &#34;C:\Users\UserName\Documents\Pandoc\pandoc-3.1.11.1\&#34; [Environment]::SetEnvironmentVariable(&#34;PATH&#34;, &#34;$PATH;$pandoc_path&#34;) </code></pre> <p>PowerShell 可以识别 pandoc,但在格式化时遇到问题。 我创建了包含一行的“MathJaxEquations.txt”:</p> <pre><code>n_{\\sf egg_{\\it i}} \\sim {\\sf negative\\,binomial}(\\lambda_{\\sf fecund}, k_{\\sf fecund}) </code></pre> <p>或包裹在<pre><code>$</code></pre>中。当我按照上面的答案并尝试时</p> <pre><code>pandoc -f MathJaxEquations.txt+tex_math_dollars+tex_math_single_backslash -t latex </code></pre> <p>我明白了</p> <pre><code>Unknown input format MathJaxEquations.txt </code></pre> <p>我可以在 R 中使用 regexpr 将我的代码转换为 pandoc 所需的任何内容(除了 R 之外,我从未使用过任何其他语言),但我不太确定如何找出 pandoc 正在寻找的格式(或者如果有更简单的方法)。我的另一个想法是尝试将这些 <pre><code>withMathJax()</code></pre> 行放入 Rmd 中并按照单词编织,但也不知道如何做到这一点。非常感谢任何为我指明正确方向的帮助。</p> </question> <answer tick="false" vote="0"> <p>RMarkdown 绝对可以将数学公式渲染到 Word 中。问题是它需要 LateX 风格的数学,而 MathJax 公式是不同的。上面的公式可以写成:</p> <pre><code>$$n_{ egg_{i}} \sim {\text{negative binomial}}(\lambda_{fecund}, k_{ fecund})$$ </code></pre> <p>如果将其放入 RMarkdown 文档中,它将毫无问题地呈现。问题是,您似乎想在闪亮的应用程序和 Word 文档中使用相同的公式,并且进行 mathjax-LaTeX 转换将至少向管道添加 [一个不同的 pandoc] [1] 步骤。</p> <p>幸运的是,<pre><code>withMathJax</code></pre>函数确实允许您为其提供 LaTeX 公式。因此,您可以仅使用 LaTeX 公式来保持一致。</p> <p>最后一个小问题——公式需要额外的 <pre><code>\</code></pre> 才能作为 R 代码块中的字符。 您可以使用 <pre><code>cat</code></pre> 打印它(无论是直接打印,还是如下所示作为 Shiny 输出的一部分),并告诉块输出 asis,然后您可以渲染到 word。</p> <pre><code>--- title: &#34;Untitled&#34; author: &#34;author&#34; date: &#34;2024-02-03&#34; output: md_document: default html_document: default word_document: default keep_md: yes --- This works in RMarkdown -- but `withMathJax` can&#39;t handle the single \ because it escapes the string $$n_{ egg_{i}} \sim {\text{negative binomial}}(\lambda_{fecund}, k_{ fecund})$$ ```{r echo =FALSE, results = &#39;asis&#39;} t &lt;- shiny::withMathJax(&#34;$$n_{ egg_{i}} \\sim {\\text{negative binomial}}(\\lambda_{fecund}, k_{ fecund})$$ &#34;) cat(t[[2]]) # for now, printing from list created above </code></pre> <pre><code> [1]: https://stackoverflow.com/questions/11338049/how-to-convert-html-with-mathjax-into-latex-using-pandoc </code></pre> </answer> </body></html>

回答 0 投票 0

在 MathJax 中写定理?

有没有办法在MathJax中创建类似amsthm定理环境的东西?我相信该包不受支持。 我在 default.html 中添加了 amsthm.js 但没有任何反应。 <question vote="2"> <p>有没有办法在 MathJax 中创建类似 <pre><code>amsthm</code></pre> 定理环境的东西?我相信该包不受支持。 </p> <p>我在 <pre><code>amsthm.js</code></pre> 中添加了 <pre><code>default.html</code></pre>,但没有任何反应。</p> <pre><code>&lt;script type=&#34;text/x-mathjax-config&#34;&gt; MathJax.Hub.Config({ TeX: { extensions: [&#34;amsthm.js&#34;, &#34;AMSmath.js&#34;,&#34;AMSsymbols.js&#34;, &#34;autobold.js&#34;], } }); &lt;/script&gt; </code></pre> </question> <answer tick="false" vote="3"> <p>不。好吧,从技术上讲,您可以编写一个扩展来执行此操作,但这不是 MathJax 的用途。</p> <p>引用 <a href="http://docs.mathjax.org/en/latest/tex.html#mathjax-tex-and-latex-support" rel="nofollow noreferrer">mathjax 文档</a></p> <blockquote> <p>请注意,TeX 输入处理器<strong>仅实现</strong> TeX 和 LaTeX 的数学模式宏,而不是文本模式宏。 MathJax 希望您使用标准 HTML 标签来处理页面文本的格式;它只处理数学。因此,例如,MathJax 不实现 <pre><code>\emph</code></pre> 或 <pre><code>\begin{enumerate}...\end{enumerate}</code></pre> 或其他文本模式宏或环境。您必须使用 HTML 来处理此类格式化任务。如果您需要 LaTeX 到 HTML 转换器,您应该考虑其他选项。</p> </blockquote> </answer> <answer tick="false" vote="0"> <p>手动插入HTML粗体和斜体字体;硬编码计数器。</p> <pre><code>&lt;b&gt;Theorem 1.1&lt;/b&gt; (Pythagoras) &lt;i&gt;The sum of the squares on the legs of a right triangle equals the square on the hypotenuse.&lt;/i&gt; &lt;i&gt;Proof:&lt;/i&gt;&lt;br&gt; Look it up. &lt;br&gt;&amp;#x25A1; </code></pre> <p><b>定理 1.1</b>(毕达哥拉斯)<i>直角三角形边上的平方和等于斜边上的平方。</i></p> <p><i>证明:</i><br/> 查一下。 <br/>□</p> </answer> </body></html>

回答 0 投票 0

如何左对齐 Mathjax 元素

Mathjax 元素默认居中对齐。 如何使 Mathjax 元素左对齐?

回答 13 投票 0

使用 MathJax SVG 的 HTML 代码在 XHTML 中不起作用

我有以下test.html: 我有以下test.html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> <title> Test </title> <style id="MJX-SVG-styles"> mjx-container[jax="SVG"] { direction: ltr; } mjx-container[jax="SVG"] > svg { overflow: visible; min-height: 1px; min-width: 1px; } mjx-container[jax="SVG"] > svg a { fill: blue; stroke: blue; } mjx-assistive-mml { position: absolute !important; top: 0px; left: 0px; clip: rect(1px, 1px, 1px, 1px); padding: 1px 0px 0px 0px !important; border: 0px !important; display: block !important; width: auto !important; overflow: hidden !important; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } mjx-assistive-mml[display="block"] { width: 100% !important; } mjx-container[jax="SVG"][display="true"] { display: block; text-align: center; margin: 1em 0; } mjx-container[jax="SVG"][display="true"][width="full"] { display: flex; } mjx-container[jax="SVG"][justify="left"] { text-align: left; } mjx-container[jax="SVG"][justify="right"] { text-align: right; } g[data-mml-node="merror"] > g { fill: red; stroke: red; } g[data-mml-node="merror"] > rect[data-background] { fill: yellow; stroke: none; } g[data-mml-node="mtable"] > line[data-line], svg[data-table] > g > line[data-line] { stroke-width: 70px; fill: none; } g[data-mml-node="mtable"] > rect[data-frame], svg[data-table] > g > rect[data-frame] { stroke-width: 70px; fill: none; } g[data-mml-node="mtable"] > .mjx-dashed, svg[data-table] > g > .mjx-dashed { stroke-dasharray: 140; } g[data-mml-node="mtable"] > .mjx-dotted, svg[data-table] > g > .mjx-dotted { stroke-linecap: round; stroke-dasharray: 0,140; } g[data-mml-node="mtable"] > g > svg { overflow: visible; } [jax="SVG"] mjx-tool { display: inline-block; position: relative; width: 0; height: 0; } [jax="SVG"] mjx-tool > mjx-tip { position: absolute; top: 0; left: 0; } mjx-tool > mjx-tip { display: inline-block; padding: .2em; border: 1px solid #888; font-size: 70%; background-color: #F8F8F8; color: black; box-shadow: 2px 2px 5px #AAAAAA; } g[data-mml-node="maction"][data-toggle] { cursor: pointer; } mjx-status { display: block; position: fixed; left: 1em; bottom: 1em; min-width: 25%; padding: .2em .4em; border: 1px solid #888; font-size: 90%; background-color: #F8F8F8; color: black; } foreignObject[data-mjx-xml] { font-family: initial; line-height: normal; overflow: visible; } mjx-container[jax="SVG"] path[data-c], mjx-container[jax="SVG"] use[data-c] { stroke-width: 3; } </style></head> <body> <span>This is some text followed by an equation: <mjx-container class="MathJax" jax="SVG" style="position: relative;"><svg style="vertical-align: -0.912ex;" xmlns="http://www.w3.org/2000/svg" width="3.619ex" height="2.509ex" role="img" focusable="false" viewBox="0 -705.8 1599.7 1108.8" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mfrac"><g data-mml-node="mi" transform="translate(612.8,394) scale(0.707)"><use data-c="1D44E" xlink:href="#MJX-TEX-I-1D44E"/></g><g data-mml-node="mrow" transform="translate(220,-345) scale(0.707)"><g data-mml-node="mi"><use data-c="1D44F" xlink:href="#MJX-TEX-I-1D44F"/></g><g data-mml-node="mo" transform="translate(429,0)"><use data-c="2B" xlink:href="#MJX-TEX-N-2B"/></g><g data-mml-node="mi" transform="translate(1207,0)"><use data-c="1D450" xlink:href="#MJX-TEX-I-1D450"/></g></g><rect width="1359.7" height="60" x="120" y="220"/></g></g></g></svg><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mi>a</mi><mrow><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mfrac></math></mjx-assistive-mml></mjx-container>.</span> <svg style="display: none;" id="MJX-SVG-global-cache"><defs><path id="MJX-TEX-I-1D44E" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"/><path id="MJX-TEX-I-1D44F" d="M73 647Q73 657 77 670T89 683Q90 683 161 688T234 694Q246 694 246 685T212 542Q204 508 195 472T180 418L176 399Q176 396 182 402Q231 442 283 442Q345 442 383 396T422 280Q422 169 343 79T173 -11Q123 -11 82 27T40 150V159Q40 180 48 217T97 414Q147 611 147 623T109 637Q104 637 101 637H96Q86 637 83 637T76 640T73 647ZM336 325V331Q336 405 275 405Q258 405 240 397T207 376T181 352T163 330L157 322L136 236Q114 150 114 114Q114 66 138 42Q154 26 178 26Q211 26 245 58Q270 81 285 114T318 219Q336 291 336 325Z"/><path id="MJX-TEX-N-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"/><path id="MJX-TEX-I-1D450" d="M34 159Q34 268 120 355T306 442Q362 442 394 418T427 355Q427 326 408 306T360 285Q341 285 330 295T319 325T330 359T352 380T366 386H367Q367 388 361 392T340 400T306 404Q276 404 249 390Q228 381 206 359Q162 315 142 235T121 119Q121 73 147 50Q169 26 205 26H209Q321 26 394 111Q403 121 406 121Q410 121 419 112T429 98T420 83T391 55T346 25T282 0T202 -11Q127 -11 81 37T34 159Z"/></defs></svg></body> </html> 在浏览器中打开它,我得到: 将文件扩展名更改为XHTML(test.xhtml)时,我得到: 方程式不再显示! 我的问题:为什么方程式不显示以及如何使其正确显示? 提前感谢您的帮助! 每个 svg 元素都需要指定其命名空间是 XHTML。你的第二个 svg 元素没有。添加一下就可以了。 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> <title> Test </title> <style id="MJX-SVG-styles"> mjx-container[jax="SVG"] { direction: ltr; } mjx-container[jax="SVG"] > svg { overflow: visible; min-height: 1px; min-width: 1px; } mjx-container[jax="SVG"] > svg a { fill: blue; stroke: blue; } mjx-assistive-mml { position: absolute !important; top: 0px; left: 0px; clip: rect(1px, 1px, 1px, 1px); padding: 1px 0px 0px 0px !important; border: 0px !important; display: block !important; width: auto !important; overflow: hidden !important; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } mjx-assistive-mml[display="block"] { width: 100% !important; } mjx-container[jax="SVG"][display="true"] { display: block; text-align: center; margin: 1em 0; } mjx-container[jax="SVG"][display="true"][width="full"] { display: flex; } mjx-container[jax="SVG"][justify="left"] { text-align: left; } mjx-container[jax="SVG"][justify="right"] { text-align: right; } g[data-mml-node="merror"] > g { fill: red; stroke: red; } g[data-mml-node="merror"] > rect[data-background] { fill: yellow; stroke: none; } g[data-mml-node="mtable"] > line[data-line], svg[data-table] > g > line[data-line] { stroke-width: 70px; fill: none; } g[data-mml-node="mtable"] > rect[data-frame], svg[data-table] > g > rect[data-frame] { stroke-width: 70px; fill: none; } g[data-mml-node="mtable"] > .mjx-dashed, svg[data-table] > g > .mjx-dashed { stroke-dasharray: 140; } g[data-mml-node="mtable"] > .mjx-dotted, svg[data-table] > g > .mjx-dotted { stroke-linecap: round; stroke-dasharray: 0,140; } g[data-mml-node="mtable"] > g > svg { overflow: visible; } [jax="SVG"] mjx-tool { display: inline-block; position: relative; width: 0; height: 0; } [jax="SVG"] mjx-tool > mjx-tip { position: absolute; top: 0; left: 0; } mjx-tool > mjx-tip { display: inline-block; padding: .2em; border: 1px solid #888; font-size: 70%; background-color: #F8F8F8; color: black; box-shadow: 2px 2px 5px #AAAAAA; } g[data-mml-node="maction"][data-toggle] { cursor: pointer; } mjx-status { display: block; position: fixed; left: 1em; bottom: 1em; min-width: 25%; padding: .2em .4em; border: 1px solid #888; font-size: 90%; background-color: #F8F8F8; color: black; } foreignObject[data-mjx-xml] { font-family: initial; line-height: normal; overflow: visible; } mjx-container[jax="SVG"] path[data-c], mjx-container[jax="SVG"] use[data-c] { stroke-width: 3; } </style></head> <body> <span>This is some text followed by an equation: <mjx-container class="MathJax" jax="SVG" style="position: relative;"><svg style="vertical-align: -0.912ex;" xmlns="http://www.w3.org/2000/svg" width="3.619ex" height="2.509ex" role="img" focusable="false" viewBox="0 -705.8 1599.7 1108.8" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mfrac"><g data-mml-node="mi" transform="translate(612.8,394) scale(0.707)"><use data-c="1D44E" xlink:href="#MJX-TEX-I-1D44E"/></g><g data-mml-node="mrow" transform="translate(220,-345) scale(0.707)"><g data-mml-node="mi"><use data-c="1D44F" xlink:href="#MJX-TEX-I-1D44F"/></g><g data-mml-node="mo" transform="translate(429,0)"><use data-c="2B" xlink:href="#MJX-TEX-N-2B"/></g><g data-mml-node="mi" transform="translate(1207,0)"><use data-c="1D450" xlink:href="#MJX-TEX-I-1D450"/></g></g><rect width="1359.7" height="60" x="120" y="220"/></g></g></g></svg><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mi>a</mi><mrow><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mfrac></math></mjx-assistive-mml></mjx-container>.</span> <svg style="display: none;" id="MJX-SVG-global-cache" xmlns="http://www.w3.org/2000/svg"><defs><path id="MJX-TEX-I-1D44E" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"/><path id="MJX-TEX-I-1D44F" d="M73 647Q73 657 77 670T89 683Q90 683 161 688T234 694Q246 694 246 685T212 542Q204 508 195 472T180 418L176 399Q176 396 182 402Q231 442 283 442Q345 442 383 396T422 280Q422 169 343 79T173 -11Q123 -11 82 27T40 150V159Q40 180 48 217T97 414Q147 611 147 623T109 637Q104 637 101 637H96Q86 637 83 637T76 640T73 647ZM336 325V331Q336 405 275 405Q258 405 240 397T207 376T181 352T163 330L157 322L136 236Q114 150 114 114Q114 66 138 42Q154 26 178 26Q211 26 245 58Q270 81 285 114T318 219Q336 291 336 325Z"/><path id="MJX-TEX-N-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"/><path id="MJX-TEX-I-1D450" d="M34 159Q34 268 120 355T306 442Q362 442 394 418T427 355Q427 326 408 306T360 285Q341 285 330 295T319 325T330 359T352 380T366 386H367Q367 388 361 392T340 400T306 404Q276 404 249 390Q228 381 206 359Q162 315 142 235T121 119Q121 73 147 50Q169 26 205 26H209Q321 26 394 111Q403 121 406 121Q410 121 419 112T429 98T420 83T391 55T346 25T282 0T202 -11Q127 -11 81 37T34 159Z"/></defs></svg></body> </html> 将 SVG 的命名空间添加到您的 svg 元素中,无论您的文件使用 .html 或 .xhtml 扩展名,您的 SVG 都将同样有效。 即改变 <svg style="display: none;" 到 <svg xmlns="http://www.w3.org/2000/svg" style="display: none;" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

回答 2 投票 0

在 Windows 上运行 Jemdoc

我正在我的新驱动器上重新安装 Jemdoc+MathJax,因为过去几年我一直用它来生成我的个人网站。这是一个Python程序,使用简单的标记语言来生成...

回答 1 投票 0

使用jekyll在github页面上加载MathJax而不覆盖布局

我有一个使用 Jekyll 设置的 GitHub Pages 站点:https://davidelegacci.github.io/Research/。我需要加载 MathJax 来显示数学内容,但这样做最终会覆盖布局,获得 st...

回答 1 投票 0

更改 mathjax 的字体大小

我在我的页面上使用 mathjax,并且我读过以下内容: MathJax.Hub.Config({ “HTML-CSS”:{规模:175} }); 应该使

回答 10 投票 0

Pelican 插件 render_math 在 markdown 中不起作用

我已在 VirtualBox 中运行的 Ubuntu 服务器上安装了 Pelican 它工作得很好!但是当我尝试数学方程时,它根本没有渲染它。 我检查了 Pelican 版本: $ 鹈鹕...

回答 1 投票 0

MathJax 未使用 ReactMarkdown 在 React 中渲染 LaTeX

我目前在 React 应用程序中面临 MathJax 和 ReactMarkdown 的问题。我已经设置了一个使用 better-react-mathjax 来渲染 Markdown 内容的组件,包括 LaTeX math express...

回答 1 投票 0

如何在react中提取单个字符串内乳胶表达式的开始位置和结束位置?

我正在尝试构建一个用于数学目的的聊天机器人,现在,我正处于第一步。 我正在尝试用动画文本显示来模拟聊天机器人的响应...

回答 1 投票 0

如何在 MathJaX 上“\dotfill”

我想制作这样的东西: MathJax 知道 \dotfill 的方法吗?

回答 1 投票 0

如何在GitHub中创建多线方程块?

GitHub 支持在 README 中插入类似 LaTeX 的代码。我想添加一些跨越多行的方程: 就像这张图片中一样 到目前为止我已经尝试过: 1. $$eqtn1 \ 等式2\ 等式3$$ $$e...

回答 1 投票 0

MathJax 元素不响应 HTML 中的 onclick 事件

我正在开发一个包含 MathJax 元素的网页,并且我已经使用某些元素的 onclick 事件实现了切换功能。切换非常适合常规 HTML

回答 1 投票 0

从使用 MathJax 渲染的 MathML 中检索输入

我想使用 HTML (MathML) 和 MathJax 制作练习表。练习表上会填满数字,输入的数字可以通过答案键检索和检查。我的问题是

回答 1 投票 0

jupyter 笔记本需要很长时间才能打开,然后页面无响应 - [MathJax] 问题

我正在尝试打开一个 jupyter 笔记本,这需要很长时间,我在底部看到它正在尝试加载各种 [MathJax] 扩展,例如chrome浏览器左下角写着: 加载...

回答 6 投票 0

如何配置 R Markdown 以使用“textmacros”MathJax 扩展进行 HTML 渲染?

我想配置我的 R Markdown 文档以使用 textmacros MathJax 扩展在 RStudio 中进行 HTML 渲染(编织)。我未能成功尝试应用 htt 提供的说明...

回答 1 投票 0

gollum-wiki mathjax.config.js 使用“<math>”和“</math>”来分隔

Gollum-wiki 已启动并运行。 对于某些数学公式,我想使用“”和“”作为分隔符。 这是完整的 mathjax.config.js 窗口.MathJax = { t...

回答 1 投票 0

无法在支持 mathjax 的 mkdocs 上渲染 .md 文件中的乳胶方程

我按照我可以在网上找到的说明(例如此链接或这篇文章中的说明)进行操作,但我无法在我的 mkdocs 网站中呈现乳胶公式。我还尝试下载 mathjax 并将其安装在本地...

回答 1 投票 0

将 html 中四开文档的矩阵中的数字与减号对齐

我想在 HTML 格式的四开文档的矩阵中将数字与减号对齐,类似于以下示例: $$egin{bmatrix} 3 & 4 \ -2 & 0 \ 1 和 2...

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.