TeX - LaTeX Asked by slacy on August 15, 2021
I’m looking for something equivalent to MathJax, but that does the conversion(s) from MathML or LaTeX to HTML-CSS on the server backend as my site is rendering the page, rather than relying on something client-side like a traditional install of MathJax. Ideally, this would be written in Python, but other languages or commandline tools would be acceptable as well.
There seem to be some out there (latex2html, plastex) but the output quality is much, much lower than what’s produced my MathJax.
I’ve seen some mumblings of node.js + MathJax for this purpose, but with much grumblings from the MathJax maintainers.
You're probably looking for tex4ht
. See my answer to this post.
Answered by raphink on August 15, 2021
I wrote the below, then reread the question, and realised that you want to convert to HTML+CSS. I originally thought you meant to MathML or HTML+CSS and answered appropriately. However, the bit about converting from MathML to SVG might be relevant. Also, I'd strongly advise you not to convert from MathML to HTML+CSS. The right way to put maths on the web is with MathML.
(Yes, that's just my opinion ... but it happens to be the right opinion!)
Usually when people talk about "LaTeX to ?ML" then they mean "LaTeX mathematics to ?ML". I'm going to assume that you mean that. If you want a more full conversion then tex4ht is the best bet. However, tex4ht not suitable for a system where the content is generated on demand.
The server-side conversion software that I know of is itexToMML. The input format is a subset of LaTeX mathematical syntax (there's a link of that page of the commands). It can be integrated with Markdown to produce a nice convertor from something a human might type to XHTML+MathML.
The original itexToMML is a C++ library. The current author has developed it in to a ruby extension which is used in the Instiki wiki software (see the nLab for an example). I worked out the correct makefile options to build extensions for PHP, Perl, and Python. I also figured out the correct place to hook it in to PHP Markdown to make that work. I don't know much python so I haven't tried to do the same with python's implementation of markdown but I would really like this to be done, partly because there's a python library for converting MathML to SVG which means that one can serve MathML, SVG, or PNG depending on the browser, thus satisfying everyone (well, probably not everyone). This is what the nForum does.
My version of the itexToMML code is in a BZR repository at http://www.math.ntnu.no/~stacey/code/itexToMML. It's not documented yet - that's on my TODO list. It also needs merging the latest changes from the main itexToMML source - it's a little behind the times.
Oh, and the original itexToMML comes as a ruby gem so it is super easy to install if you use ruby.
Answered by Andrew Stacey on August 15, 2021
tex4ht does a reasonable job translating latex to html; it does allow you to supply a *.cfg
file with css instructions, e.g.
Css{%
div.document{font: Verdana,Tahoma,Arial,sans-serif;}
div.document { margin-left: 80px; margin-right: 80px;
padding-top: 3ex;
padding-bottom: 5ex }
div.quote{background: linen;}
p.quote{background: red;}
}
but it does convert equations to images
Answered by prettygully on August 15, 2021
I would believe it is possible to use Mathjax on the server side, here is how.
You are done.
Of course, the main reason to use MathJax is to be cross browser capable. This allows you to work for only one browser.
Answered by Chao Xu on August 15, 2021
As of September 2015, there is a MathJax-node project that includes the full MathJax renderer in a format that can be used from Node.js (or, with a little bit of wiring, from any other server language or framework).
Answered by bdesham on August 15, 2021
I am working on a similar problem that utilizes the following tools:
The configuration has been a bit challenging (still working on getting matplotlib's mathtext rendering functions to recognize the full power of the underlying LaTeX engine), but the output quality is decent (I too still favor MathJax output quality at this point though).
I'm currently using this solution for LaTeX-to-bitmap image conversion, which isn't quite where you wanted to get, but maybe you'll find it to be a workable interim solution?
Answered by SO1804 on August 15, 2021
KaTeX can render equations on the server side:
require("katex").renderToString(
"x^2+y^2=z^2",
{throwOnError: false}
);
For example, you could create a PostHTML plugin that calls KaTeX.
Answered by Jouni K. Seppänen on August 15, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP