Can I add LaTeX packages to MathJax?

删除回忆录丶 提交于 2019-11-29 05:27:05

问题


I have some mathematical expressions written in LaTeX that I would like to put on a webpage. However, they use packages that don't seem to be included in MathJax (e.g. ytableau). They were sufficiently time consuming to write in the first place that I'd like to be able to use what I have, rather than figure out how to reproduce the results with the MathJax features I currently have access to.

I had thought that it may be easy to turn a LaTeX package into a MathJax extension as the extensions in the MathJax installation appear to be based on LateX packages, I looked at the cancel.sty LaTeX package and the cancel.js MathJax extension hoping it would give me some idea of how to do it but I can't see how they relate.

Is there a way of using LaTeX packages with MathJax? If so, how would I do this?

(First question, hope this is not deemed off topic.)


回答1:


Is there a way of using LaTeX packages with MathJax?

No. MathJax isn't LaTeX; it processes input that is LaTeX-like (as close as it reasonably can be to true LaTeX), but the way it works under the hood is very different. One difference in particular is that MathJax only implements the math-mode macros, not all the other text-mode or general processing macros and control sequences. So most of the tools used by LaTeX packages aren't there. That means you can not simply drop a LaTeX package into MathJax. The packages that MathJax supports have to be re-implemented in javascript, which is difficult for non-trivial packages (like the one you cite).




回答2:


Is there a way of using LaTeX packages with MathJax? If so, how would I do this?

  1. First the StackExchange site must support MathJax.

  2. You need to use the correct syntax for the particular site .

    Some sites require a backslash before the dollar sign, because when people try to write "it costs $10 shipping each time" they end up with "it costs $10 shippingeachtime", so to avoid excessive questions about why that happens the dollar sign must be escaped to use MathJax on some sites.

  3. You need to use $\require{\packagename}$ somewhere on the page, and it affects the whole page (including other people's posts).

  4. The site in question needs to support the extension. The official (but incomplete) list is here: "MathJax third-party extensions".

The most complete MathJax Tutorial and Links answer is over at QC.meta.SE.

Specific to your question, "ytableau" didn't work on the site where I tested these examples (physics.SE) but the other packages I demonstrate do work:

$\require{\AMScd}$

$$\begin{CD}
A @<<< B @>>> C\\
@. @| @AAA\\
@. D @= E
\end{CD}$$

$\require{\mhchem}$

$$\ce{Zn^2+  <=>[+ 2OH-][+ 2H+]  
$\underset{\text{zinc hydroxide}}{\ce{Zn(OH)2 v}}
$  <=>[+ 2OH-][+ 2H+] 
$\underset{\text{tetrahydroxozincate(II)}}{\ce{[Zn(OH)4]^2-}}$}$$

The mhchem example was obtained from the MathJax-mhchem webpage.

Test a short example to determine if and how it works. Worst come to worst you can compose on a supporting site, capture and crop a screenshot, then enclose the MathJax in HTML comments <!-- comment --> and upload the screenshot - if in the future MathJax is enabled the code will be available in your question or answer within the HTML comment.




回答3:


This page gives the answer, which is yes. http://math.stackexchange.com doesn't seem to honor \(\require{foo}\), but the above link tells you how to add any package to the configuration for your website.

If you're not the administrator of the site, of course you will have to convince the powers-that-be to install the package.



来源:https://stackoverflow.com/questions/21192606/can-i-add-latex-packages-to-mathjax

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!