This site is going to need TeX markup to express mathematical symbols and formulas well.
-
$\begingroup$ Yep. They have it at Math Overflow, hence should be easy apply it here. $\endgroup$– RoyiCommented Jul 20, 2010 at 19:26
-
1$\begingroup$ For equations the site needs something besides image links. ∑∑∑∑ $\endgroup$– Chris SCommented Jul 20, 2010 at 19:35
-
$\begingroup$ @ShreevatsaR: I'm afraid this doesn't even get much attention at the main meta... But maybe if we all upvote there, we'd get more attention - I'll attach a bounty there, maybe that helps $\endgroup$– Tobias KienzlerCommented Jul 29, 2010 at 7:30
-
1$\begingroup$ Whatever we are using now chart.apis.google is pretty horrible and I hope we can switch to jsmath or mathjax :S $\endgroup$– anonCommented Jul 29, 2010 at 19:39
-
7$\begingroup$ We will continue to improve support for TeX - this is by no means the end. $\endgroup$– Geoff DalgasCommented Jul 29, 2010 at 19:39
-
5$\begingroup$ ~~~~~ yay! ~~~~~ $\endgroup$– BlueRaja - Danny PflughoeftCommented Jul 29, 2010 at 19:40
-
$\begingroup$ @Geoff: I'm not clear on this...what exactly was done? I'm not seeing any change...I still see all kinds of $blah$ type stuff. $\endgroup$– BeskaCommented Jul 29, 2010 at 20:56
-
$\begingroup$ ~-~-~-~- YAY! -~-~-~-~ $\endgroup$– Mateen UlhaqCommented Apr 5, 2011 at 0:34
17 Answers
I have already started using TeX in my markup.
The way that Math Overflow does it is to surround the TeX with dollar signs, using the jsMath library.
I suggest we stick with that convention, so that when we have support for it, our old posts will "light up".
EDIT:
I have created a quick-hack grease monkey script to get this done in the mean time:
http://userscripts.org/scripts/show/81977
EDIT2:
I have updated the script to work on Stats.stackexchange.com, and have added in transparency, and options to use other services, as well.
EDIT3:
I have incorporated Isaac's changes, and added an additional rendering service.
-
$\begingroup$ @John: Is it ok to copy your script for the stats.stackexchange.com? $\endgroup$– Srikant VadaliCommented Jul 21, 2010 at 19:28
-
$\begingroup$ @Srikant: I would rather have you just link people to my code, but the source is open. $\endgroup$ Commented Jul 22, 2010 at 1:00
-
$\begingroup$ @John: Will the script work as is for stats.stackexchange.com? If yes, I will be more than happy to point to your script to users over there. A second question: On what browsers does the script work (only firefox + greasemonkey installed?)? $\endgroup$– Srikant VadaliCommented Jul 22, 2010 at 2:29
-
1$\begingroup$ @Srikant: I got it to work on chrome without other plugins. It should work for any site by changing the @include to the corresponding domain (idk if @namespace have to be changed) $\endgroup$– Chao XuCommented Jul 22, 2010 at 3:27
-
$\begingroup$ @Mgcl: Thanks. @John: The image is not showing up in chrome but working in firefox. BTW, should we take discussions reg the script to userscripts.org? $\endgroup$– Srikant VadaliCommented Jul 22, 2010 at 13:10
-
$\begingroup$ @John: something in your update broke the script for me in Chrome--it was working last night and now produces broken images. $\endgroup$– IsaacCommented Jul 22, 2010 at 14:15
-
$\begingroup$ @John: Please see my modifications to your current (4th) version, posted at pastebin.com/uVB1rEdf and described below (meta.math.stackexchange.com/questions/2/183#183). $\endgroup$– IsaacCommented Jul 23, 2010 at 4:34
-
$\begingroup$ @Isaac: Thanks, I have incorporated your changes. $\endgroup$ Commented Jul 24, 2010 at 14:24
-
-
-
1$\begingroup$ Thanks for your contribution @John - we have incorporated it as a plugin on Math / Stats / Tex and all related meta sites for the good of the community. $\endgroup$ Commented Jul 29, 2010 at 19:37
-
$\begingroup$ Great to have this on the math/stats/TeX sites. However, it is occasionally giving odd results. For example, see the answer of PaulHurleyuk at stats.stackexchange.com/questions/213/…. The problem is that the R code includes a dollar sign. Can the script by modified to fix this? $\endgroup$ Commented Jul 30, 2010 at 13:03
-
$\begingroup$ @Rob: Yes, easily. There is a list of tag names to ignore, and we can just add 'pre' and 'code' to the list. Also, we won't be able to entirely get away from weirdness, because the code is not an actual parser. $\endgroup$ Commented Jul 30, 2010 at 15:02
-
$\begingroup$ apologies for hijacking this thread, but I was wondering how we might get this enabled on the new CS theory SE site (cstheory.stackexchange.com) as well ? $\endgroup$ Commented Aug 17, 2010 at 3:49
The developers should come and ask the moderators of MathOverflow (e.g. me) about this, and we'll happily help out!
By the way, I'd recommend actually using MathJax, the brand new replacement for jsMath. It's still not quite as fast as jsMath, but it's the way of the future. MathOverflow will switch soon.
-
6$\begingroup$ MathJax is written by the same guy, only it's built with the future (HTML5) in mind and supports LaTeX and MathML. $\endgroup$– NickCommented Jul 20, 2010 at 20:10
-
2$\begingroup$ HTML5 is not the future. It's a kludgy hack made by lazy software manufacturers who don't want to bother complying with XHTML2. $\endgroup$– 97832123Commented Jul 21, 2010 at 19:45
-
1$\begingroup$ Future proof is important. I hope they'll use MathJax. Thanks. $\endgroup$– RoyiCommented Jul 22, 2010 at 7:45
-
5$\begingroup$ XHTML2 is dead, the group working on it was made redundant. $\endgroup$ Commented Jul 23, 2010 at 21:14
Temporary workarounds:
Images can be embedded in questions and answers with ![](http://www.example.com/image.png)
like so:
![](http://mathurl.com/2azr28f.png)
becomes
Combine this with:
http://mathurl.com/ - type in latex, get a minified image url to link to in your posts
http://www.codecogs.com/latex/eqneditor.php - as above, but no minification, and you have to rightclick to get the image url.
For simple formulas, where LaTeX is not needed:
You can use <sup></sup>
to write superscripts and <sub></sub>
for subscripts:
y<sub>1</sub>=x<sup>2</sup>+3
becomes y1=x2+3
-
2$\begingroup$ +1 for mathurl.com I never know about it. $\endgroup$– LazerCommented Jul 28, 2010 at 13:56
-
$\begingroup$ +1. IMO this is the preferable workaround. $\endgroup$ Commented Jul 29, 2010 at 19:23
I've posted a walk-through of how we've implemented math rendering on MathOverflow on meta.SO. As Scott said, we'll be switching to MathJax in the near future, so it probably makes sense for new SE sites to just use MathJax from the get-go. Once we switch, I'll try to remember to update that answer to reflect the changes.
We have added MathJax to support TeX equations based on feedback. MathJax is on the cusp of a 1.0 release and we will update this library once it's final.
Three Four Five observations:
If one escapes a latex fragment using backticks (this is frequently needed in order to arbitrate between Markdown and the latex rendered) the latex piece gets colored in gray due to the stylesheet in a rather unsightly way.
Display math using
$$
does not seem to work.It would be immensely useful if the preview of answers rendered latex too.
Something's amiss with things like \mathbb{Z}/3\mathbb{Z}, which gets rendered as $\mathbb{Z}/3\mathbb{Z}$. (Hmm, here it looks fine, but in Group With an Endomorphism That is "Almost" Abelian is Abelian. it doesn't)
Editing a comment kills everything within dollar signs.
-
$\begingroup$ TeX markup is implemeted by making calls to chart.apis.google.com... I wonder why that is better than having the client render? $\endgroup$ Commented Jul 29, 2010 at 21:17
-
$\begingroup$ It's not. I hope they switch to mathjax. I do see your 2 and 4: math within $$ ... $$ doesn't work (it keeps a dollar sign on each side and just displays inline), and on the question you linked to, even the / and 3 are in blackboard. $\endgroup$ Commented Jul 29, 2010 at 21:21
-
$\begingroup$ Okay, this question shows the behavior you describe for
$$
. But you can use$\displaystyle ... $
for now as Qiaochu did here. $\endgroup$ Commented Jul 29, 2010 at 23:55
If the formula is not complicated, besides <sup> and <sub> I also use character entities in html. Some examples:
bold ∏ displays as ∏
bold ∑ displays as ∑
in general, Greek letters are displayed by writing &letter; other symbols are
ℵ ℵ
∀ ∀
∃ ∃
∈ ∈
∩ ∩
∪ ∪
Look here for the complete list of allowed characters. I know that this is not enough to write decent mathematics, but it's a start.
-
$\begingroup$ wow that works great. I've never thought that you can use html encoded symbols in stackexchange. I though only some tags like pre, sup, sub, br... work here $\endgroup$– phuclvCommented Feb 3, 2015 at 5:18
-
$\begingroup$ @mau: that link does not work anymore ... $\endgroup$ Commented Dec 31, 2015 at 13:33
-
$\begingroup$ I updated the link, this time using Wikipedia: en.wikipedia.org/wiki/…. I hope this helps! $\endgroup$– mauCommented Dec 31, 2015 at 18:50
I do believe that this is of utmost urgency, and should be first priority for any developers working on this site.
-
$\begingroup$ I doubt anything will happen during the beta, unless a lot of betas want the facility. $\endgroup$ Commented Jul 21, 2010 at 11:29
-
1$\begingroup$ MathOveflow already has this feature, and I suspect that it shouldn't be very hard to make it work here as well. $\endgroup$– AnonymousCommented Jul 21, 2010 at 20:30
Is this thing on?
$\begin{equation}
\sum_{i=1}^{\infty}x_{i}
\end{equation}$
...yep!
$\begin{tabular}{r|c|l} symbol & read as & example \ \hline $\to$ & ``maps to" & $f:\mathbb{R} \to \mathbb{Z}$ \ $\forall$ & "for all" & $\forall x \in E$ \end{tabular}$
... what environments are going to work here? (clearly not tabular
)
EDUT Oh, didnt read the comments. Thanks guys for working on this!
I vote for MathJax to be used instead of jsMath if a Javascript library is decided over a server-side LaTeX image generator.
Equation rendering is exceptional over jsMath, and all major browsers are supported. (Even IE6!! See Browser Compatibility.) Most operating systems and browsers anti-alias the LaTeX, and the equations seem to fit in to the native look, whatever browser that may be.
Agreed. I think everyone is begging for this feature. It's been requested numerous times on Meta StackOverflow, the latest one specifically for Area 51/StackExchange being here.
Personally I would like to see jsMath implemented on StackExchange sites. It's virtually trivial, a script reference simply needs to be added to the page.
In the meantime, there's Google Chart.
edit: except that it doesn't appear to show up. :P
-
$\begingroup$ See my answer, I have added a script that uses the Google Chart API to some success. $\endgroup$ Commented Jul 21, 2010 at 18:58
LaTeX rendering is needed, but I would like to see a server-side solution rather than a client-side solution such as jsMath. The biggest problem for me with jsMath is that it takes such a long time to completely load a web page on some popular MathOverflow questions. Often I have to simply disable jsMath or else the web browser consumes so much memory that my computer starts swapping pages of RAM to the disk.
What about adding a toolbar button to convert a LaTeX expression to an image using the mathURL service?
I am running John Gietzen's awesome Greasemonkey script in my browser and everyone's TeX is showing up great - but I am having a problem composing TeX. Specifically, I seem to be completely unable to include addition signs in my formulas. This makes zero sense to me, can somebody explain?
For example: "P of x equals a x squared plus bx plus c" looks like: $P(x)=ax^2 + bx + c$
I have typed $</code><code>P(x)=ax^2 + bx + c</code><code>$
EDIT: Isaac has fixed the script, it looks like it's working pretty good now.
-
$\begingroup$ I was just experiencing the same problem. I haven't looked into the script yet, but I suspect that it's because a + in url-encoding is an encoded space (i.e. there's some missing encode/decode step). $\endgroup$– IsaacCommented Jul 23, 2010 at 4:18
-
1$\begingroup$ Here's my modified version of the script: pastebin.com/uVB1rEdf --I think I've fixed the plus-sign issue and I've also excluded the script from running on the edit page (which, at least for me, was making all TeX markup vanish entirely in the edit box). $\endgroup$– IsaacCommented Jul 23, 2010 at 4:32
-
$\begingroup$ @Isaac, @John Gietzen: Thanks to you both for implementing this hugely important workaround. $\endgroup$ Commented Jul 23, 2010 at 4:48
-
$\begingroup$ @Isaac: The line "name == 'textarea'" is supposed to prevent it from interfering with the edit window... $\endgroup$ Commented Jul 23, 2010 at 14:38
-
1$\begingroup$ @John: I didn't read through it enough to catch that. For some reason, though, on Mac Chrome it was still eating the TeX in the textareas, which is why I added the exclude. The change from
escape
toencodeURIComponent
was the more important change, though. $\endgroup$– IsaacCommented Jul 23, 2010 at 14:41 -
$\begingroup$ How do I install this after downloading greasemonkey? $\endgroup$– CasebashCommented Jul 24, 2010 at 6:00
-
$\begingroup$ @Casebash: My answer at the top has a link to the Userscripts.org page. There should be a big green "Install" button. $\endgroup$ Commented Jul 25, 2010 at 14:59
As mentioned before, one option that doesn't involve a third party rendering service is MathJax, the spiritual successor to jsMath. Here is a small userscript that inserts MathJax (currently hosted on my own web server, but presumably would be hosted by stack exchange on a permanent basis) into the head of math and meta.math.
You can use a number of math formats for display, like regular ol' TeX markup:
$P(x)=ax^2 + bx + c$
Or some more complex TeX formatting:
$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$
And eventually, if Stack Exchange allows MathML to be inserted into pages, code like this:
<math display='block'><mrow><mi>x</mi><mo>=</mo><mfrac><mrow><mo>−</mo><mi>b</mi><mo>±</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo>−</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></mrow></math>
(something seems a little slow when loading MathJax here - it may be a configuration problem on my end. I will look into it later today. Reference the official preview page if you want a better idea of the latency with translating lots of TeX on a page with javascript - it's quick)
-
$\begingroup$ Installed in Chrome, worked for about 1 minute (rendered beautifully, if slow on the first load), then stopped working. Page loads generate the initial "Loading" message at the bottom, briefly, but no subsequent messages and none of the TeX is rendered. $\endgroup$– IsaacCommented Jul 24, 2010 at 17:57
-
$\begingroup$ It didn't even occur to me to check in Chrome, doing so now... $\endgroup$– NickCommented Jul 24, 2010 at 18:25
-
$\begingroup$ Did you have any luck with it in Chrome? $\endgroup$– IsaacCommented Jul 28, 2010 at 22:55
-