# add LaTeX support to Markdown/WMD

I'm planning a (the?) StackExchange site for mathematics. I think it will be awesome, but there is one major difference between mathematicians and programmers which will be a source of friction in the UI: mathematicians will need LaTeX support.

(Edit: I want to clarify that this isn't meant to be a StackExchange question. I realize that nobody can answer any StackExchange questions at this point. The above paragraph is backstory so that you know why I want to do what I want to do. This is a question about Markdown/WMD. I posted on Meta because I want to modify a tool to be almost like the thing that SO uses. Perhaps this question more properly belongs on SO.)

(More Edit: I was under the impression that SE feature-requests were frowned upon since SE "doesn't exist" yet, but SO podcast 64 suggests otherwise. Since LaTeX support would be useful to any SE site with a math or science focus, I'd like to make this a feature request. Could somebody with the rep please change [support] to [feature-request]?)

Answers to this question have lots of good solutions, but I really need them to be seamless. For example, I really like the latex.codecogs.com editor, so I would like an input like this

For a morphism $f\colon T\to X$, consider the curve over $T$
corresponding to the composition
$T\xrightarrow{f}X \xrightarrow{g} \mathcal{M}_{g,n}$.

to be automatically converted into something like this1

For a morphism
![f\colon T \to X](http://latex.codecogs.com/gif.latex?f\colon%20T\to%20X),
consider the curve over ![T](http://latex.codecogs.com/gif.latex?T)
corresponding to the composition
![T\xrightarrow{f}X \xrightarrow{g} \mathcal{M}_{g,n}](http://latex.codecogs.com/gif.latex?T\xrightarrow{f}X%20\xrightarrow{g}%20\mathcal{M}_{g,n}).

which should produce output like this (but doesn't for some reason ... nevermind that).

For a morphism , consider the curve over corresponding to the composition .

Is this trivial or difficult to implement? How would I go about doing it? I tried checking out the WMD source, but none of it is actually available yet, and the repository hasn't changed in over a year.

1 Of course, I wouldn't want to swamp latex.codecogs.com with requests, so I'd want to get their engine running on the site server. My understanding is that they would be cool with this, but I can't tell for sure. Anyway, there is surely some open source engine I can use.

Update (2010/02/04): People still seem to be looking at this post (it just got a couple of upvotes), so I'll briefly describe the solution we've used on Math Overflow. In contexts other than WMD, the text $f\colon T\to X$ is served as-is, and is converted by jsMath, which is loaded in the footer. In the context of WMD, a "preview math" checkbox is inserted under the wmd-input field and tied to a cookie. We use a (very slightly) customized version of wmd.js which processes the math in the live preview if the box is checked. The customized wmd.js incorporates the jsMath processing time into the delay algorithm, but the preview still gets kind of slow for some people, in which case they can uncheck the box. There are still occasional issues (e.g. $\{a_n\}$ doesn't work correctly because Markdown removes the backslashes), but the solution is pretty good. Once it's out, we'll switch to MathJax, the successor to jsMath.

-
see meta.stackexchange.com/questions/6048 and meta.stackexchange.com/questions/6647 for discussion of required tags – Timothy Carter Aug 5 '09 at 18:58
Because on Meta it is hoped that all posts will fall into one of those standard buckets and then allow for the proper steps to be taken for each one. If it's a feature request, evaluate the request. if it's a bug, try and figure out if it's reproducible, etc. If it is discussion, just let it sit there. This is mostly to assist with the overall organization of this site as both a bug tracker and as a feature request area along with being a discussion area about stackoverflow and the rest of the trilogy. – TheTXI Aug 5 '09 at 18:58
@Ian Elliott: Good point, but where can I find non-minified WMD so that I can actually look at it? – Anton Geraschenko Aug 6 '09 at 2:58
Ian Elliott seems to have turned into Barack Obama. – Anton Geraschenko Aug 6 '09 at 6:49
I retagged it on your request, but you should have been able to do this yourself - what sort of problems were you having? – Kyle Cronin Aug 7 '09 at 15:26
@Kyle Cronin: I just didn't see the Tags box when I made the edit ... it seems plain as day now. Thanks. – Anton Geraschenko Aug 7 '09 at 16:51
Google Charts can render LaTeX (or at the very least a decent chunk of it?) - chart.apis.google.com/chart?cht=tx&chl=%5CLaTeX - it's ran by Google, and entirely intended to be embedded on other sites, so may be a better candidate? – dbr Dec 1 '09 at 3:12
This is still desperately needed for Maths, Physics and more at Area 51 – Tobias Kienzler Jul 29 '10 at 8:53
scripts-blockers: allow cdn.mathjax.org – bernard paulus Jan 3 '13 at 10:43

The (non-minified) source for WMD can be found in Dana Robinson's GIT repository, as Jeff pointed out here. That should keep me busy for a while.

-

But I see now that mathoverflow did acquire latex presentation.

-

I think you should be able to add a syntax easily enough, but is Stack Exchange even at a point where anyone could answer this yet?

Edit: assuming you add the syntax support, it might be better to add the LaTeX generator to your own server, so that you don't have an external dependence on what would be a core functionality for a "MathOverflow" site. (DivideByZero might be a good name... just saying...)

-
It isn't really a StackExchange question. I assume that StackExchange will be flexible enough to accommodate this kind of thing. The question is, "what exactly is it that they need to accommodate?" – Anton Geraschenko Aug 5 '09 at 19:10
I actually really like the name "mathoverflow". It pays tribute to SO, but makes sense by itself. Among other things, it should be a place where mathematicians send their overflow ideas which are too random to go into a paper or blog post, but others might find useful. – Anton Geraschenko Aug 5 '09 at 21:38
"Mathlexic" would be a better name. – donnacha Aug 12 '09 at 9:31