ลาเท็กซ์การกำหนดค่า Mathjax อยู่ตรงกลาง

ฉันกำลังพยายามใช้ mathjax-node ใน javascript

อย่างที่คุณเห็นในภาพ ฉันต้องการทำให้ข้อความอยู่ตรงกลางโดยไม่เหลือ

นี่คือภาพที่เรนเดอร์

มีการกำหนดค่าใด ๆ บน mathjax-node หรือไม่?

ฉันลองจัดแนวข้อความและแสดงจัดตำแหน่งให้อยู่กึ่งกลาง แต่ก็ไม่ได้ผล

function convert(tex, options, callback) {
    mathjax.typeset({
        width: options.width,
        ex: 10,
        math: tex,
        format: "TeX",
        // style: "text-align: center;",
        svg: true, // SVG output
        linebreaks: true,
    }, function (data) {
        if (data.errors) return callback(data.errors);
        callback(undefined, data.svg);
    });
}


const mathjax = require('mathjax-node');
mathjax.config({
    TeX: {
        extensions: ["color.js"]
    },
    MathJax: {
        displayAlign: "center",
        // 'text-align': "center"
        extensions: ["TeX/color.js"],
        'fast-preview':{disabled:false}
    },
});
mathjax.start();

นี่คือโค้ดของ mathjax.typeset และ config


person Seung Cheol Lee    schedule 07.01.2021    source แหล่งที่มา
comment
คุณต้องการให้ TeX เป็นแบบอินไลน์หรือบล็อกหรือไม่?   -  person koder613    schedule 07.01.2021
comment
เอิ่ม มันมีความแตกต่างไหม?   -  person Seung Cheol Lee    schedule 07.01.2021
comment
นี่คือขั้นตอนในลาเท็กซ์ถึง svg   -  person Seung Cheol Lee    schedule 07.01.2021


คำตอบ (1)


เมื่อเขียน MathJax ในโหมดการแสดงผล MathJax จะจัดโค้ด MathJax ให้อยู่ตรงกลางโดยอัตโนมัติ

หากต้องการพิมพ์สมการของคุณในโหมดการแสดงผล ให้ใช้ตัวคั่นตัวใดตัวหนึ่งต่อไปนี้: [ ... ], \begin{displaymath} ... \end{displaymath} หรือ \begin{equation} ... \end{equation} $$ ... $$ ไม่สนับสนุนเนื่องจากอาจทำให้มีการเว้นวรรคไม่สอดคล้องกัน และอาจใช้งานได้ไม่ดีกับแพ็คเกจทางคณิตศาสตร์บางแพ็คเกจ

<p>
The mass-energy equivalence is described by the famous equation
\[ E=mc^2 \]
discovered in 1905 by Albert Einstein. 
In natural units (\(c = 1 \)), the formula expresses the identity
\begin{equation}
E=m
\end{equation}
</p>

<script type="text/javascript" async  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

ตัวอย่างและคำพูดข้างต้นได้มาจากที่นี่

นี่เป็นวิธีที่รวดเร็วมากในการตั้งศูนย์คณิตศาสตร์เนื่องจากไม่จำเป็นต้องมีการกำหนดค่าเพิ่มเติม

person koder613    schedule 07.01.2021