17
$\begingroup$

There will be occasions when it would be useful to be able to include a statistical formula within a question, answer, or comment. How is this supported?

$\endgroup$
13
$\begingroup$

jsMath would be awesome as it could allow dynamic previewing of mathematics in questions and answers.

As a stopgap measure, you can use a service that compiles markup, such as TeX, to an image and then link the image into your Question or Answer. Here's a list of some such services taken from a blog post by my good friend Cameron see his blog post for side-by-side comparisons.

It seems StackExchange scrubs image links that pass script parameters- which is unfortunate as these services can't be used directly from a post. However, you can download the generated image and rehost using a site like TinyPic.

$\endgroup$
  • $\begingroup$ I think the long term answer is what Colin suggested, i.e., to incorporate the jsMath library in the same fashion as mathoverflow. But since the site admins haven't indicated if that will happen or when it might happen, I'm going to accept your answer as correct, because it should work with the current system. If I'm breaking any protocols by doing it this way, just let me know. $\endgroup$ – A Lion Jul 20 '10 at 18:41
12
$\begingroup$

Is it possible to incorporate the latex javascript library that mathoverflow use?

$\endgroup$
  • 1
    $\begingroup$ We should definitely ask them about it. To my knowledge jsMath is the most feature-rich client-side solution and uses TeX-style notation which is a good lingua franca for expressing mathematical statements. $\endgroup$ – Sharpie Jul 19 '10 at 20:11
  • $\begingroup$ I don't know if he used it or not but John L. Taylor stats.stackexchange.com/users/39/john-l-taylor was able to include a formula in one of his answers stats.stackexchange.com/questions/2/what-is-normality/59#59 , so there is currently some type of support. Assuming it is the same as mathoverflow, should we add that as a FAQ? $\endgroup$ – A Lion Jul 19 '10 at 20:24
  • 1
    $\begingroup$ @A Lion: He just did what I did, when I found the equations I wanted on Wikipedia for this question: stats.stackexchange.com/questions/54/… and linked to them. $\endgroup$ – Amos Jul 19 '10 at 20:39
  • 2
    $\begingroup$ Yeah, it's an image. Reminds me, I think there's a pile of "turn-TeX-into-hosted-image" sites out there, I'll dig some up. $\endgroup$ – Sharpie Jul 19 '10 at 21:08
  • $\begingroup$ Yes it is. Look at mathoverflow.net . They use jsMath and it works excellent $\endgroup$ – Jonathan James Jul 20 '10 at 8:52
4
$\begingroup$

Latex support is now built-in. See this meta thread from math.SE: https://math.meta.stackexchange.com/questions/2/tex-math-markup-is-sorely-needed

I have made this answer CW in case you want to see what you have to do to get latex output.

A demo: $\alpha$

John Gietzen over at http://math.stackexchange.com has created a greasemonkey script which uses the Google Charts API to create images on the fly from latex. I have asked his permission to adapt it for our site. See his answer to this question: https://math.meta.stackexchange.com/questions/2/tex-math-markup-is-sorely-needed

Here is a demo of the script: $\alpha$

Ok, here is the script put together by John: http://userscripts.org/scripts/show/81977

Presently, I have it working for in firefox with greasemonkey installed. Apparently, it works in Chrome as well but I have not been able to get it to work. I will update this answer if I can resolve that issue.

Perhaps, we should start using tex + the above script. The advantage is that as and when we get tex support from the devs all our posts will look nice.

$\endgroup$
  • $\begingroup$ What about all the people using browsers other than Firefox or Chrome (like IE or Safari)? They will just see what looks like a bunch of line noise surrounded by dollar signs. It is probably best to pre-compile the TeX to an image and post a link to that. $\endgroup$ – Sharpie Jul 23 '10 at 6:55
  • $\begingroup$ Yeah, that is true. So, perhaps we wait till tex functionality is built-in and in the meantime use images only. $\endgroup$ – svadali Jul 23 '10 at 13:14
  • $\begingroup$ BTW, some users on math.stachexchange.com are using tex. If you are on that site as well and use chrome/firefox the above script will work. On firefox: greasemonkey + the script linked above On chrome: Just the script. $\endgroup$ – svadali Jul 23 '10 at 15:28
  • $\begingroup$ @Srikant: I believe that this script will work in IE using the GM4IE extension. $\endgroup$ – John Gietzen Jul 26 '10 at 20:21
  • $\begingroup$ @Sharpie Safari is close to Chrome, I think it should work there. $\endgroup$ – user88 Jul 29 '10 at 22:19
  • $\begingroup$ The script is causing problems with R code that includes a dollar sign. e.g., the answer by PaulHurleyuk at stats.stackexchange.com/questions/213/… $\endgroup$ – Rob Hyndman Jul 30 '10 at 12:54
  • $\begingroup$ @Rob I have taken the liberty of re-posting your comment on this meta thread: meta.stats.stackexchange.com/questions/218/… If not that is not ok please let me know and I will delete it. $\endgroup$ – svadali Jul 30 '10 at 14:24
3
$\begingroup$

Another option is to use http://mathurl.com/, and then link to the picture.

alt text

See this discussion.

According to the site's about section:

This short link will now forever refer to your equation!

$\endgroup$
  • $\begingroup$ The image is linked to mathurl.com. Will that link ever break in the distant future? $\endgroup$ – svadali Jul 27 '10 at 16:19
  • $\begingroup$ @Srikant: It shouldn't, no. Although that's a risk. $\endgroup$ – Shane Jul 27 '10 at 16:20
  • $\begingroup$ ok. I wonder when the devs will let us know their decision about the request to add latex support: meta.stackexchange.com/questions/57931/… That would be ideal. $\endgroup$ – svadali Jul 27 '10 at 16:25
1
$\begingroup$

In fact, you should be looking into using MathJax instead of/as well as jsMath. It's written by the same people, recently had its first release, and is much more stable and flexible. Right now, however, it's actually a little slower than jsMath, but they anticipate improving this soon.

$\endgroup$
0
$\begingroup$

The only time I've had to implement something like this was with a Moodle site where we made use of mimetex although this appears to have been superseded by mathtex which I haven't used. NRich make extensive use of jsMath very successfully and it probably isn't going to be as much of a nightmare to get working as mimetex was.

$\endgroup$
0
$\begingroup$

In my opinion, a solution should be found that displays the equations immediately, not after some seconds. Therefore, I vote for JS in the previews, but compiled tex when questions and answers are displayed!

$\endgroup$
0
$\begingroup$

I have to note that MathML support is available in Firefox 4b2. And while syntax does seem quite cumbersome:

<math>
  <mi>x</mi>

  <mo>=</mo>
  <mfrac>
    <mrow>
      <mo>&minus;</mo>
      <mi>b</mi>
      <mo>&PlusMinus;</mo>
      <msqrt>
        <msup>

          <mi>b</mi>
          <mn>2</mn>
        </msup>
        <mo>&minus;</mo>
        <mn>4</mn>
        <mo>&InvisibleTimes;</mo>
        <mi>a</mi>

        <mo>&InvisibleTimes;</mo>
        <mi>c</mi>
      </msqrt>
    </mrow>
    <mrow>
      <mn>2</mn>
      <mo>&InvisibleTimes;</mo>
      <mi>a</mi>

    </mrow>
  </mfrac>
</math>

It could be great if we could be allowed this tags.

x = − b ± b 2 − 4 ⁢ a ⁢ c 2 ⁢ a
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .