Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I find here that MathJax supports only math-mode macros (such as \sqrt{}) and not text-mode macros (such as \begin{align}). I am currently building a small wiki that will host mathematics articles, and so expect that both kinds of macros will be desirable. The page linked above recommends a TeX to HTML converter, but (unless I'm misunderstanding) these all seem to be alternatives to MathJax.

What is a good solution to get the attractive rendering of mathematical symbols (as in MathJax) combined with the standard text-mode alignment environments found in LaTeX?

share|improve this question
1  
There is no current solution to text based TeX or LaTeX macro rendering in HTML pages. Suggest to emulate with good CSS. Remember, that HTML 5 will allow unknown tags, which browsers will render as tags. For example you can have a <section></section> tag, which you can then decorate with appropriate CSS. I found this the easiest on something similar that I am working with. –  Yiannis Lazarides Aug 28 '11 at 20:00
    
@Yiannis: Consider posting this as a solution (perhaps noting that MathJax is aimed at a subset of LaTeX just for math material). –  Joseph Wright Aug 28 '11 at 20:03
    
@Joseph Wright Thanks, just did. –  Yiannis Lazarides Aug 28 '11 at 20:13
add comment

4 Answers

up vote 2 down vote accepted

There is no current solution to text based TeX or LaTeX macro rendering in HTML pages and MathJax is only aiming at a subset of TeX (it only emulates the Mathematical engine).

I Suggest to emulate with good CSS. Remember, that HTML 5 will allow unknown tags, which browsers will render as tags. For example you can have a tag, which you can then decorate with appropriate CSS. I found this the easiest on something similar that I am working with.

<style type="text/css">
...
section{font-size:1em;
        font-weight:bold;}
</style>
<body>
...
<section>A section</section>
  ... text
  ... maths
share|improve this answer
    
Thank you for your advice. I will look into writing some custom tags. I am particularly interested in emulating the align environment from TeX. My solution needs to be such that someone familiar with TeX can easily make use of this new tag in the wiki environment. Do you have any suggestions about how I might do this? –  Austin Mohr Aug 28 '11 at 20:35
    
@Austin have a look at mediawiki.org/wiki/Extension:MathJax –  Yiannis Lazarides Aug 28 '11 at 20:41
add comment

MathJax does handle \begin{align}...\end{align} as part of its AMSmath extension, since this is a math environment. It does not do text-mode macros or environments (like \begin{enumerate}...\end{enumerate}). You can see a complete list of supported macros and environments that can help you figure out which ones you can use.

In terms of the "other options" suggested on the page you site, some of these (e.g., tex4ht) have a MathJax output mode so that the math will be handled by MathJax but the text by the preprocessor, so these are not necessarily alternatives to MathJax, but can work together with it.

Andrew suggests saving the output of MathJax and serving that statically, but this is not a good idea. MathJax's output is dependent on the browser being used, and on a number of factors related to the reader's browser (fonts available on their system, default font size, etc.), and so the HTML generated for one reader may not be the same as that for another. So doing as he suggests will mean that not all readers will get a good view of your mathematics. You would also need to save the CSS that MathJax creates dynamically, and that also is browser-dependent. The upshot is, caching the output of MathJax will not work well, in general. It is best to use MathJax as outlined in the documentation.

share|improve this answer
    
To be clear, I don't suggest saving the output of MathJaX. I suggest converting the TeX-like syntax to MathML on the server, sending that to the browser, and then using MathJaX to ensure that the MathML is converted to something suitable for the browser (for those that don't understand MathML). Your second paragraph is one implementation of what I was suggesting. My apologies for not being sufficiently precise in my answer. –  Andrew Stacey Aug 30 '11 at 17:57
add comment

MathJaX can be configured to convert MathML in to something readable by the browser. If the user/browser likes MathML then it passes it through, if the user/browser prefers HTML+CSS then MathJaX converts it. Thus you can get the "attractive rendering of mathematical symbols (as in MathJax)" by using a TeXish-to-MathML converter and then having MathJaX on top of that.

There are certain advantages of this, the main one being that for those enlightened enough to prefer MathML then MathJaX does nothing meaning that the pages render super-fast (compared to the time it takes when MathJaX has to convert from TeX-like syntax). Thus the "MathJaX or converters" is not necessarily an exclusive or.

In addition, the "attractive rendering" that you attribute to MathJaX is actually due to your browser. MathJaX's role is to present the material in a manner that the browser can understand and, of course, it does so so that it is "attractively rendered". But since it the browser that does the rendering, if you present a static page with the same information then it will be rendered just as attractively (and with considerably less overhead and faster load times).

With regard to a wiki with good maths support, I can heartily recommend Instiki. This is the wiki used by the nLab and there's a lot of mathematics on those pages! The maths conversion is done by a program called itextomml. Specifically to your question, it supports the aligned environment so the equivalent of \begin{align} ... \end{align} is $$\begin{aligned} ... \end{aligned}$$ (which is perfectly good in AMSMath as well).

In addition, I'm a TeX addict and find writing wiki-pages a little arduous, especially when they go over about what would be a page in TeX. So I've written a LaTeX class which does its best to convert genuine LaTeX to the right syntax to be inputted to Instiki, or wordpress, or blosxom, or ... you name it, it could be adapted to that. As an example, the article at this nlab page is the result of converting a LaTeX document (written by someone else, and written before it was thought to include it in the nLab). All of my blog posts on our TeX-SX blog are actually LaTeX documents that were converted to a format appropriate for Wordpress. As it is actually a LaTeX class, it can cope with user-defined macros and other stuff which is hard for a non-TeX-based converter to deal with.

share|improve this answer
add comment

It can set with using the TeX notation $$...$$. Here is an example: http://latex.userpage.fu-berlin.de/math.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.