用 AsciiMath 在瀏覽器上寫數學公式
asciidoc javascript math -<script >
MathJax = {
loader: {
load: ['input/asciimath']
},
asciimath: {
delimiters: [['\\$', '\\$']]
}
}
</script>
<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/mml-chtml.js"></script>
Why
大多數 AsciiMath 符號會盡量像他自己的樣子,比起 TeX 需要記憶一堆英文字母,可謂是直覺多了。
例如: oo ⇒ \$ oo \$ ,可參見: syntax。
How
在 asciidoc 文件中
你必須在文件的最上方加上 stem 屬性
:stem: asciimath|latexmath // (1)
-
內定是
asciimath
現在你只要使用 stem:[] 巨集,並將你要寫得方程式寫在 [] 之中,再利用
asciidoctor 產出 html 即可,asciidoctor 會自動將他處理成 AsciiMath 的表示方式。
例如:
stem:[ E = mc^2 ] // (1)
-
\$ E = mc^2 \$
在 html 文件中
在 head 中加入下列 js,讓瀏覽器利用 MathJax 幫你呈現數學公式。
<script >
MathJax = {
loader: {
load: ['input/asciimath']
},
asciimath: {
delimiters: [['\\$', '\\$']]
}
}
</script>
<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/mml-chtml.js"></script>