2

I want to include some formulas in my HTML document, like this:

<h1>Embedded formula</h1>
<p>And here it goes!</p>
<p><span class="latex">x^n+y^n=z^n</span></p>

MathML seems a bit too complex for this task (and I already have a plenty of complex formulas in latex), so using latex seems to be a better route.

There is a similar question on stackoverflow, yet it is a bit outdated (many things changed in the last two years), and I would like for such html not to require connection to the Internet.

It seems that it is possible to implement jQuery plugin that will in some way interact with texlive.js + pdf.js and perform the task in question, yet I would refrain from writing such a new library if some solution already exists.

Community
  • 1
  • 1
penartur
  • 9,792
  • 5
  • 39
  • 50
  • 1
    Convert formulas by bash script and put into html png files instead. – Eddy_Em Jun 19 '13 at 11:54
  • If you think an existing question is outdated, you should try to have its answers improved, instead of intentionally posting a duplicate. – Jukka K. Korpela Jun 19 '13 at 17:35
  • @JukkaK.Korpela, MathJax is very slow javascript-based tool, I think, it's not good to use it in serious things; the only good thing is making png-images from formulae and pasting them into html. An ancient tool `latex2html` don't work in common cases (but sometimes it helps). Another tool `tex4mk` is even worse. Regrettably there's only one common way to convert latex into html: by hands! – Eddy_Em Jun 20 '13 at 05:00

2 Answers2

3

If you want to be able to write LaTeX code in your HTML and have it rendered well, you probably want MathJax. It requires Javascript, but the results are very good. It's running on the Mathematics StackExchange site as well as lots of other sites.

Community
  • 1
  • 1
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • MathJax seems to be the perfect answer; I wonder why I haven't found it earlier – penartur Jun 19 '13 at 12:02
  • @penartur You can try it out on the [demos page](http://www.mathjax.org/demos/), too. It's really quite impressive, although, since it just does math, not full fledged LaTeX, strange workarounds are sometimes necessary. E.g., in [this answer](http://math.stackexchange.com/questions/417935/equivalence-relation-using-tableaux/422719#422719) I had to use a whole bunch of nested arrays, where I think a cleaner solution would be available in raw LaTeX. – Joshua Taylor Jun 19 '13 at 12:10
  • Hope it will be enough to satisfy my needs. The obvious problem is that it does not support latex packages (except for ones bundled with it such as **amsmath**) I believe; texlive.js+pdf.js combo, from the other hand, should support these. – penartur Jun 19 '13 at 12:59
  • as the side note, it is a weird coincidence that I asked this question to prepare a presentation for my thesis which also deals with the formula equivalence (though in form of "\phi \vdash \psi" AND "\psi \vdash \phi"). – penartur Jun 19 '13 at 13:03
  • @penartur I haven't looked at texlive.js and pdf.js much, but the quick look I just had made it look more like those were still for compiling PDFs, no? – Joshua Taylor Jun 19 '13 at 13:17
  • Yes, texlive.js is for compiling tex to pdf in javascript, and pdf.js is for rendering the resulting pdf in browser. – penartur Jun 19 '13 at 15:20
  • @penartur Doesn't that mean that you're not really embedding LaTeX formulae in HTML anymore, but PDF in HTML? – Joshua Taylor Jun 19 '13 at 15:27
  • I mean it is possible to create a jQuery plugin that will replace all LaTeX formulas used in HTML with the `` that will display PDF. The same thing **MathJax** does except that **MathJax** does not use `` and PDF (and does not support LaTeX packages etc) – penartur Jun 20 '13 at 10:41
1

You may use jsMath http://www.math.union.edu/~dpvc/jsMath/welcome.html

Or, MathML that is a w3c standard, but it is currently not very well supported by browsers.

Adrian Maire
  • 14,354
  • 9
  • 45
  • 85