167

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...

4

5 Answers 5

81

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}

8
  • 1
    Just to make this complete, an online TEXT editor: codecogs.com/latex/eqneditor.php Commented Jan 28, 2011 at 17:42
  • 1
    This doesn't work well when you have more than 1 formula. Commented Jan 28, 2011 at 19:40
  • @Yochai I just tried it in an edit; what issue are you having? Commented Jan 28, 2011 at 19:49
  • tried to put 4 formulas, only the first showed. Commented Jan 28, 2011 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
    Commented May 28, 2013 at 7:26
  • 2
    This answer is now outdated, Stack Overflow now accepts LaTeX Phrases. (See Mehrad's answer)
    – Jan Moritz
    Commented May 27, 2014 at 19:35
  • 9
    @JanMoritz Stack Overflow still doesn't. Certain topic sites like Physics and Math Exchange do.
    – user200500
    Commented Jun 13, 2017 at 4:58
  • 1
    I guess this is an outdated answer; I found that I can follow the instructions here math.meta.stackexchange.com/questions/5020/… for stat stack Exchange site Commented Feb 19, 2020 at 5:35
75

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

4
  • 5
    Unfortunately, the result is not as good as directly from LaTeX...
    – brimborium
    Commented Aug 10, 2012 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? Commented Nov 30, 2013 at 4:35
  • 3
    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. Commented Dec 19, 2016 at 17:44
  • chart.googleapis actually doesn't support full LaTeX, just some simple subset. -- on the other hand, images from https://latex.codecogs.com/gif.latex?<formula> (for example) doesn't display well in stack overflow's dark mode.
    – user202729
    Commented Jan 6, 2021 at 4:37
40

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.

5
  • 43
    It doesn't work on stackoverflow. Commented Sep 6, 2015 at 16:16
  • It works on a lot of stackexhange sites such as cross-validated, which are math intensive.
    – user350459
    Commented Dec 15, 2017 at 16:54
  • 1
    It works on mathematics stack as well.
    – lenhhoxung
    Commented Mar 6, 2019 at 16:27
  • It works, but how can I get the formula inlined, right now it comes out as block display, but when you want to refer in the text to variables with index or overline or simple terms, you want them inlined, not display block presented. How to do that? Commented Dec 7, 2019 at 2:47
  • 1
    Funny, it doesn't work even on... tex.stackexchange.com :-/ :-/
    – Antonello
    Commented Feb 4, 2020 at 13:52
21
  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

6

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

3
  • 1
    This is awesome..
    – user350459
    Commented Dec 15, 2017 at 16:35
  • Is this a opensource project? Based on neovim or something? i couldnt find information on github etc..
    – user350459
    Commented Dec 15, 2017 at 16:40
  • Tis is a formula $\psi .\psi ^{\ast }$
    – Mercury
    Commented Sep 19, 2021 at 21:04

You must log in to answer this question.

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