• ## Discussion Feed

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

1.

We've just setup some LaTeX support, thanks to the great work of "OlegK", the author of the "SELaTeX" project, and John Forkosh, the author of the mathtex project.

You'll see a sidebar on the right, which allows you to type LaTeX and provides a real-time preview. When you're done, you can copy and paste the code over to your post. The code it produces is MarkDown syntax for an image tag. It generates alt-text containing the original LaTeX, so you can edit and see other people's source if you need to.

We've modified the original SELaTeX code in order to use our own LaTeX renderer, rather than the one over at codecogs.com. It's possible we'll have issues with this, so please report any problems.

We are well aware of the insufficiencies of this solution. In particular, it would be lovely to provide MathML to browsers that can handle it, but for now that's beyond us. It would be great to be able to write LaTeX inline in your post, rather than having to jump to the sidebar, but that will have to wait on support from FogCreek, the makers of the StackExchange software. Anyway -- perfect is the enemy of good, so for now we're going with this.

2.

Known bug: the sidebar doesn't appear while you're editing an answer.

3.

It looks a little wonky if you use latex with a sentence: http://mathoverflow.net/questions/4062/can-homgpg-h-fail-to-be-representable-for-affine-algebraic-groups.

4.
Also, if you use latex more than once in a line it gets screwy. Try pasting the following into "ask question".

Let G and H be affine algebraic groups over a scheme S of characteristic 0 and let ![\textbf{Hom}_{S,gp}(G,H)](http://latex.mathoverflow.net/png?%5Ctextbf%7BHom%7D%5F%7BS%2Cgp%7D%28G%2CH%29) be the functor ![T \mapsto \text{Hom}_{T,gp}(G,H)](http://latex.mathoverflow.net/png?T%20%5Cmapsto%20%5Ctext%7BHom%7D%5F%7BT%2Cgp%7D%28G%2CH%29)

Edit (Scott): Dave was having trouble because it was typesetting *correctly* here. I told meta to "Format comments as Text", so the Markdown is no longer interpreted.
5.

I know this is just being really picky, but is it possible to call this something more accurate than "LaTeX"? It's LaTeX mathematics mode, so you don't need to put in the dollars, and ordinary text commands may or may not work, depending on whether or not they are valid in mathematics mode.

But apart from that, that's a great feature to have.

• CommentAuthorKevin Lin
• CommentTimeNov 4th 2009

@Andrew: You had also made some similarly pedantic remark in a previous thread. Does it really matter? I don't see what the big deal is.
6.

Yes and No. In the Grand Scheme of Things, then no, it doesn't really matter. In the scheme of trying to make the site as useful as possible, then yes, it does matter. You can't type arbitrary LaTeX syntax into that box, it doesn't work. You can type a simplified subset of LaTeX. Exactly what that subset is, I don't know. A little experimenting showed that it stripped out certain commands, but not others.

The preview feature mitigates this a little, since it's obvious that stuff isn't appearing as one would expect, but it's still not technically correct to say that you can use LaTeX input.

• CommentAuthorfedja
• CommentTimeNov 4th 2009 edited

I feel utterly stupid, but I cannot find the LaTeX box anywhere on the screen. Firefox 3.5.3, Windows XP.

Edit: I installed IE and it appears there, but not on FF. Seems like some common problem with javascript when these 2 browsers handle things differently. It would be nice if somebody looked into it.
7.

@David Brown: The problem is that the underscores in the alt text are special Markdown characters. When you have two underscores on a line, everything between them gets italicized. Since this is the "intended" behavior, I don't think Fog Creek will fix it, but we can. We just have to decide how to. The problem is that if we change the alt text (e.g. by escaping all the underscores and stars), then it becomes slightly harder to edit the source. I think this is a tolerable price to pay. I'll see if I can modify the javascript to escape underscores and stars. For now, you can escape them manually, like I did in your question.

@Andrew: I'd be happy to use a more accurate name. I get the same little twinge of annoyance every time I see (or use) the term "LaTeX", but I don't see a good way around it without constantly launching into explanations about how it isn't really LaTeX.

@fedja: sometimes, the box doesn't appear for me, but it appears after reloading the page. Does this work for you?

8.

That behaviour with the underscores shouldn't happen. That's a bug. It ought to get "protected" as it ends up inside the alt tag, and thus inside an HTML tag. However, a quick experiment shows that it's a "feature" (ie bug) in the original Markdown so you may be right about the difficulty of getting it fixed (though it really would be simplicity itself to fix). Escaping it just involves putting in backslashes, as I'm sure you're aware. However, I presume that this isn't a long-term solution (at least, I hope not!) and once something is integrated with the interpreter then irritations like this should disappear.

As for the name, why not simply "LaTeX-style equations"? That makes it clear that it might not be quite LaTeX (and I'd suggest a thread here where people can note common differences) and also makes it clear that it's for equations only. Otherwise someone might be tempted to write their whole answer in LaTeX!

• CommentAuthorrwbarton
• CommentTimeNov 4th 2009

I agree with Kevin Lin. Surely the fact that the output is not a DVI file makes it clear that this is not literally LaTeX. I don't see a problem with using the single word "LaTeX" wherever it is convenient to do so.
9.

My vote is also "LaTeX-style equations" in the help box. On the other hand I reserve the right to fudge the difference while discussing it further here. :-)

10.

Great work! Would it be possible to make it perfect by adding a button to paste text from the right box to the left in a single click?

11.

@Ilya, re: automatically pasting. This would require some ever so slightly deeper javascript magic. In principle I think I know how to do it, but won't unless someone comes by my office to do it with me. :-)

12.

Re: the underlying bug in Markdown for handling underscores and stars in the alt text.

Does anyone know how the Markdown code is maintained? Does FogCreek use a standard distribution of Markdown, or have they forked. Can we just submit bug reports and/or patches to someone further upstream than FogCreek?

13.

Do you know what language MO uses? That would give us a high probability of identifying the source of the markdown. Even if they've forked it, it's highly likely that they would implement upstream patches.

Actually, we can do a little detective work ... nope, none of the syntax in extended markdown seems to work which implies that it is plain, ordinary Markdown. In which case, you need to go to the top.

Edit: A little more detective work reveals that this might well be one of the bugs fixed in the latest version of PHP Markdown suggesting that they're not using this version. I'd need to experiment to see if this really is the same bug. Hang on, I can experiment here!

and a

(I guess you need to look at the alt tags to see what I'm testing, but if the bug was in PHP Markdown then the "and a" would be italicised)

14.

@Scott: here's the Javascript: document.getElementById("wmd-input").value += ' ' +document.getElementById("code-box").value + ' '

I wasn't able to paste a javascript link here, but you can prefix above with javascript: and put into your bookmarks. Clicking on this bookmark will copy text from the code box to the edit box. Tested: Safari 4.

15.

They forked the Markdown, see this SO blog post.

16.
Re the underscore problem, I think the best solution is to replace underscores with \sb (with a trailing space). If the rendering engine doesn't support \sb, then it should be fixed.
17.

Ah, so they've already spotted the dangers of underscores in the middle of words so they should be open to a bug report on underscores in images.

(curiously, there's one mention of PHP markdown in that discussion but it doesn't get taken up)

18.

@hanche Flott! Jeg viste ikke denne løsningen. Jeg lærer nye ting hver dag.

19.

I've changed the javascript to escape _'s and *'s in the alt text, so this problem should be alleviated. This is kind of hacky because it means that if you edit the source later, you have to manually unescape these characters. Markdown should really protect these characters when they are alt text. I found a bug report on meta.SO which was essentially declined (marked [status-bydesign]), and I posted a new bug report on meta.SE. If there is some kind of Markdown main project, we should file a bug report with them.

20.

I've just added a comment to the first link mentioning the issue and added the remark about it being fixed in PHP markdown to the second.

21.

I've commented over on the SO blog post Ilya pointed out, complaining that the upstream fix to MarkDown hasn't been merged.

22.
Following up on hanche's comment above (let's replace _ with "\sb " instead of \_), let's also just replace * with \ast instead of \*. As far as I can tell, this will produce identical renders, but leaves the source as actual LaTeX.
23.
Anton just implemented both of these fixes: _ and * shouldn't cause problems, because we replace them with their LaTeX equivalents \sb and \ast.
24.

Depending on which page I'm on, I either get the jsMath banner or the "LaTeX in the box" banner.

Also, what's the default: jsMath or LaTeX-via-images?

25.

For some reason, the system messages are heavily cached, so when I change it, you get a mix of the two. We're going to keep the LaTeX-via-images box for a few days while we're ironing out any jsMath issues that arrise, but I think jsMath is clearly far superior, so I think we should get rid of the LaTeX-via-images box as soon as we're pretty sure jsMath is stable.

26.
i'm having issues with _ , \sb{} , \left\{ , and, of course, \right\} . i tried the above, but it's not seeming to work...
27.

@Dave Penneys: can you explain what issues you're having? Are these problems with the LaTeX sidebar, or with jsMath (where you just put stuff between dollar signs)? What exactly did you try?

I'm guessing you're probably having issues with jsMath. The problem is the interaction between jsMath an Markdown. You can "solve" the problem by escaping special Markdown characters (like _, *, \, and {) with a backslash. Try using \_ and \left\\\{. In fact, you usually don't have to escape underscores and curly braces (but you do have to escape the backslash before a curly brace) because the server side implementation of Markdown is smarter than the javascript version that does the preview. See this post and the jsMath page for more details. I hope the preview will be better in the beta 5 version of the software. It looks like jsMath doesn't recognize \sb, but you should just be able to use underscores.

• CommentAuthorcdouglas
• CommentTimeNov 9th 2009

The latex does not display properly on Chrome (for Mac OS). Eg the post
http://mathoverflow.net/questions/4547/definitions-of-hecke-algebras
which displays perfectly in Safari, has the math oddly displaced in Chrome.
This could easily be Chrome's fault rather than MO's, but I thought it worth
reporting.
28.

@cdouglas: This question belongs on the "bugs with jsMath" thread, so I'll copy it there. I can reproduce this bug in chrome on linux.

29.

Images inserted from the side bar don't appear in the mathoverflow.net/questions page.

Example: look at this question. The author apparently used the sidebar to create the symbol C^infty. If you bring up the "all questions" page and scroll until you see this question (page 1 at the moment), you see

Given a compact smooth manifold $M$, it's relatively well known that $(M)$ determines $M$ up to diffeomorphism.

That symbol "(M)" should be "C^infty(M)".

30.

Good catch. Maybe this is the right time to get rid of the png image LaTeX support, since it's pretty clear that jsMath is superior. Weirdly, the asker actually wrote $C^\infty$ (instead of an image) in one spot.