29

Is any painless solution out there to include LaTeX formulas in a Stack Overflow post?

Of course I could render the every formula manually, make a picture (lets say a jpeg) out of it, upload it to some image hoster and then post the image but this is far too much of a hassle..

For example writing about filtering or clustering algorithms, complexity stuff, neural networks, is really a pain without LaTeX formulas.

This is not a duplicate of "There's seriously no reason why LaTeX markup via MathJax shouldn't be enabled on SO". I am not asking to include LaTeX on Stack Overflow. I am asking if anyone knows a more or less painless alternative to manually render a LaTeX formula and upload it to some image hoster and then include the image.

4
  • 1
  • 1
    @theB: It's definitely not a dupe, but it's related. It's not a dupe since it's not asking the same thing ("Why can't we use LaTeX on Stack Overflow" vs. "How do I embed a LaTeX formula on Stack Overflow?").
    – Makoto
    Commented Nov 1, 2015 at 21:54
  • 1
    Why should this be a duplicate? I am not asking for includig MathJax to SO or enable direct LaTeX support in SO. I am asking if anyone knows a more or less painless alternative to manually rendering and including the image of a formula then.
    – daniel451
    Commented Nov 1, 2015 at 21:55
  • Note that you do not have to upload any image to a separate image host. Stack Overflow has an "insert picture" button in the editor which allows you to upload images. They are then hosted under a Stack Overflow Imgur account. Commented Nov 3, 2015 at 14:41

2 Answers 2

13

In the very niche scenarios I've had to write TeX, I've found the Online LaTeX Equation Editor to be a nice compromise. You still have to embed the image on the site, which isn't as cool as just rendering MathJax or TeX, but it'll get the job done in a pinch.

In scenarios in which you do find yourself writing copious amounts of TeX, you should also consider if the question is more math-oriented than programming oriented, and would thus be on-topic for Mathematics.SE.

10
  • 9
    Of course math-oriented stuff should be posted on mathematics.se, but I think most guys on meta.so forget about Data Mining, Artificial Intelligence, Big Data stuff, specific algorithms and their complexity, Graph processing, ... Basically nearly all science-related programming tasks highly include math but would not fit on mathematics.se because mainly it is a computer science question. Computer science is highly math related but an own discipline at there are many questions on SO that are primarily about computer science. Just my 2 cents.
    – daniel451
    Commented Nov 1, 2015 at 22:04
  • 1
    Oh. Well if it's really geared towards Comp-Sci, there's a site for that, too.
    – Makoto
    Commented Nov 1, 2015 at 22:05
  • @ascenator More likely than Mathematics, a math-heavy programming-related question may be more suitable for Computational Science or Computer Science or Signal Processing, or Cross Validated or Data Science -- all of which have MathJax enabled.
    – user3717023
    Commented Nov 1, 2015 at 22:05
  • Yeah...I think this is very ambiguous. Basically one has to decide whether the question is more about "practical" programming / implementation or more science related. I would think that most times the realization is more of a problem and therefore more questions on SO appear.
    – daniel451
    Commented Nov 1, 2015 at 22:09
  • 1
    Also in the computer graphics related tags I can see big potential for equations. It is often hard to explain to a user why his code isn't working without explaining the math behind it.
    – BDL
    Commented May 29, 2017 at 12:25
  • 3
    -1 for "very niche scenarios". Just had to use a bunch of equations to make a combinatorial point to a newbie asking a programming question.
    – einpoklum
    Commented Dec 12, 2018 at 15:57
  • @einpoklum: And how many times have you done that over the last six years?
    – Makoto
    Commented Dec 12, 2018 at 16:20
  • 1
    @Makoto: I've often wanted to include formulas, and have resorted to backticked latex-like code, or some <sub>'s and <sup>'s. This happens to me, on average, I guess once every 6 to 10 answers or so. This time was an exception in that I was replying to a question which itself wasn't stated very clearly, so I wanted more rigor.
    – einpoklum
    Commented Dec 12, 2018 at 16:27
  • @einpoklum: Are you sure the questions you're answering are even on topic for the site? Your most recent answer starts with the line "this is not a programming problem" which implies that the problem is more rooted in math than programming, and would be suitable for a math-oriented network site. It also doesn't help matters much that the question you answered reads like an overly broad requirements dump, either...
    – Makoto
    Commented Dec 12, 2018 at 16:33
  • @Makoto: Yes, I am sure.
    – einpoklum
    Commented Dec 12, 2018 at 17:21
11

You can use the Google Chart API and embed the result as an image (![](URL)). The syntax for using the API is as follows:

https://chart.googleapis.com/chart?cht=tx&chl=<url-encoded-content-here>

The Tex content needs to be percent-encoded which can be done online at for example https://www.urlencoder.org/.

This is an example of an equation rendered by using the Chart API:

Example

1
  • 1
    googleapis isn't available for China users like me, so the images aren't showing for everybody. But I guess we can feed the url to the Stack Imgur upload API.
    – Cœur
    Commented Oct 10, 2018 at 17:31

You must log in to answer this question.

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