108

I want to ask something that contains a mathematical formula.

How can I write the equation? Is there a page that shows the syntax?

I thought there must be some syntax like in Wikipedia or something...

  • 1
    See meta.stackexchange.com/questions/73504/… - but I don't think the syntax is implemented on SO – ChrisF Jan 28 '11 at 14:52
  • 15
    It's strange that stackoverflow does not support math formulas directly, like MathExchange or CrossValidate. – qed Sep 1 '13 at 14:30
65

I'm not sure why Simon deleted his answer, but it was right, you can use the Google Chart API. For example, this:

![foo+bar](https://chart.googleapis.com/chart?cht=tx&chl=foo%2bbar)

becomes:

foo+bar


Second formula:

![\sqrt{foo}](https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7Bfoo%7D)

becomes

\sqrt{foo}

  • Just to make this complete, an online TEXT editor: codecogs.com/latex/eqneditor.php – Yochai Timmer Jan 28 '11 at 17:42
  • This doesn't work well when you have more than 1 formula. – Yochai Timmer Jan 28 '11 at 19:40
  • @Yochai I just tried it in an edit; what issue are you having? – Michael Mrozek Jan 28 '11 at 19:49
  • tried to put 4 formulas, only the first showed. – Yochai Timmer Jan 28 '11 at 20:03
  • I need to substitute ) with %29 to make it work in preview when I type the answer. But even if I do so, it doesn't work when I save it and view it. @YochaiTimmer 's answer works for me. – Haozhun May 28 '13 at 7:26
  • 1
    This answer is now outdated, Stack Overflow now accepts LaTeX Phrases. (See Mehrad's answer) – Jan Moritz May 27 '14 at 19:35
  • 3
    @JanMoritz Stack Overflow still doesn't. Certain topic sites like Physics and Math Exchange do. – Asad Saeeduddin Jun 13 '17 at 4:58
50

Ok, best combination I found is doing something like what Michael suggested.
But it's easier to reference the link at the bottom.
So, go to this site: Online LaTex Equation Editor
Create your formula. Use this site and encode it for URL safety: URL Encoder/Decoder

Take the result and prepend it with the following URL: https://chart.googleapis.com/chart?cht=tx&chl=

Then reference it to your post:

This is a formula ![formula][1]
Another formula: ![another][2]

  [1]: https://chart.googleapis.com/chart?cht=tx&chl=%5Csum_%7B23%7D%5E%7B43%7D
  [2]: https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7B%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20x%7D%7D

It will show like this:

This is a formula formula

Another formula: another

  • 1
    Unfortunately, the result is not as good as directly from LaTeX... – brimborium Aug 10 '12 at 10:26
  • +1 I was having trouble getting this to work using chart.googleapis.com although I was able to get this work using the URL encoded link from codecogs just fine. I was using it for this answer, any idea why? – Shafik Yaghmour Nov 30 '13 at 4:35
  • 1
    The latex editor you mentioned has an option for "URL (encoded)" that has been adequate to bypass the encoder for me so far. Saves one tab switch. – Mad Physicist Dec 19 '16 at 17:44
25

LaTeX Phrases

Some sites (mainly the scientific ones) use MathJax to render LaTeX. You can use single dollar signs to delimit inline equations, and double dollars for blocks:

The Gamma function satisfying $\Gamma(n) = (n-1)!\quad\forall n\in\mathbb N$ is defined through the Euler integral

$$ \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. $$

And you'll see the results as: enter image description here

To create a LaTeX phrase you can go to an online LaTeX Equation Editor.

  • 27
    It doesn't work on stackoverflow. – Mark Lakata Sep 6 '15 at 16:16
  • It works on a lot of stackexhange sites such as cross-validated, which are math intensive. – user350459 Dec 15 '17 at 16:54
  • 1
    It works on mathematics stack as well. – lenhhoxung Mar 6 at 16:27
13

1. Formulate your equation using the CodeCogs tool.

2. Right-click the generated image and select "Copy image location" or similar.

3. On Stack Overflow, insert the image as so: ![equation](imageUrl)

Thus:

![e=mc^2](https://latex.codecogs.com/gif.latex?e%3Dmc%5E2)

Becomes:

e=mc^2

5

Using WYSIWYG editor like Mathcha Editor

First, using this website to insert math equation (support import from latex)

Second, export to image/latex....to share Or login to the website and share without limitation (auto-generate a link). There is Mathcha Editor:

enter image description here

  • This is awesome.. – user350459 Dec 15 '17 at 16:35
  • Is this a opensource project? Based on neovim or something? i couldnt find information on github etc.. – user350459 Dec 15 '17 at 16:40

You must log in to answer this question.

protected by Community Jun 25 at 5:31

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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