<!DOCTYPE html>
<html>
<head>
    <title>LaTeX to SVG Converter</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
    <h1>LaTeX to SVG Converter</h1>
    <form>
        <label for="latex-input">LaTeX Code:</label><br>
        <input type="text" id="latex-input" name="latex-input" size="50"><br><br>
        <button type="button" onclick="convertLatexToSVG()">Convert</button>
    </form>
    <br>
    <div id="svg-output"></div>
<pre><code>&lt;script&gt;
    function convertLatexToSVG() {
        var latexInput = document.getElementById(&quot;latex-input&quot;).value;
        var svgOutput = document.getElementById(&quot;svg-output&quot;);

        svgOutput.innerHTML = &quot;&quot;; // Clear previous outputs

        var options = {
            ex: 16, // Font size (adjust as needed)
            display: true,
            em: 16, // Font size (adjust as needed)
            containerWidth: 80, // Width of the SVG container (adjust as needed)
            containerHeight: 80 // Height of the SVG container (adjust as needed)
        };

        var svg = MathJax.tex2svg(latexInput, options);
        svgOutput.appendChild(svg);
    }
&lt;/script&gt;
</code></pre>
</body>
</html>
<p>这个网页的基本结构包括一个标题、一个LaTeX输入框、一个转换按钮和一个SVG输出区域。当用户在LaTeX输入框中输入代码并点击'Convert'按钮时,JavaScript函数<code>convertLatexToSVG()</code>将被调用。此函数获取LaTeX代码并使用MathJax库将其转换为SVG图像。然后,将生成的SVG图像附加到SVG输出区域中。</p>
<p>请注意,此代码需要通过网络加载MathJax库。</p>
在线LaTeX转SVG图片工具 - 将数学公式轻松转换为矢量图

原文地址: https://www.cveoy.top/t/topic/qrys 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录