MathOverflow has an awesome engine where you can embed LaTeX in questions, answers, and comments. Can we get something like this going on Stack Overflow?

I think it’d be appropriate as I at least pretty often want to write something like n^2 and would benefit greatly from prettier markup.

closed as off-topic by Glorfindel, Nathan Tuggy, Robert Longson, rene, Sonic the Reinstate Monica-hog Oct 15 '18 at 11:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question's topic is only applicable to one specific site in the Stack Exchange Network. Questions on Meta Stack Exchange should relate to features or policies that commonly apply to the network or the software that drives it, within the guidelines defined in the help center. You should ask this question on the meta site where your concern originated." – Glorfindel, Nathan Tuggy, Robert Longson, rene, Sonic the Reinstate Monica-hog
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    +1. Though in a "programming", instead of math, environment, it seems this issue comes up less often and programmers are used to dealing with it when it does. Plus complex formulas aren't needed nearly as often. (How often do you think you'd be misunderstood on SO writing n^2 and n**2?) – Gnome Nov 22 '09 at 2:20
  • 41
    That's true, but just because we're used to something bad doesn't mean we shouldn't attempt to improve it =). – Claudiu Nov 22 '09 at 2:41
  • I like the idea in principal. However, it should be as intuitive as possible. I've looked at LaTeX for typesetting and decided to stick with QuarkXPress as I found it more intuitive. (shudder) – Jason D Nov 29 '09 at 23:59
  • 8
    I think this is a good idea. It would be very helpful for the more computer sciency sort of questions. I think LaTeX makes the most sense; it's standard in academia. – user138665 Dec 17 '09 at 1:42
  • svgkit.sourceforge.net/tests/latex_tests.html or similar might help. Think "preview bit" below answer. – Aiden Bell Jan 14 '10 at 16:11
  • Maybe this is just my personal problem, but I cannot read set theory notation or Sigma notation, even though I easily understand the related concepts they embody. Those would probably be the first things commonly used on the site. As much as I want arithmetic to have the proper symbols, I would not want the rest that comes with it. – Merlyn Morgan-Graham Nov 19 '11 at 1:09
  • 6
    I would argue that programmers see a lot of complex math, it just depends on what you are programming. I do research in intelligent controls, for instance, and most of my programs are heavy on both the programming stuff and the math. LaTeX in SO would be extremely helpful. – Engineero Jun 9 '13 at 17:12
  • @minitech Do you have an example for when you would use this on SO? – Undo - Reinstate Monica Sep 10 '13 at 17:28
  • @Undo: Not on hand. Anything regarding algorithms. This advice is an important part, by the way. – Ry- Sep 10 '13 at 17:29
  • 4
    @minitech If you need math formatting, there's a good chance that your question is off-topic and you should ask it on Computer Science instead. There are plenty of exceptions, of course, but I've found it to be a good rule of thumb for deciding between Stack Overflow and Computer Science. (You could even add a third wheel: code → Stack Overflow, math → Computer Science, neither → Software Engineering, but I don't know how accurate that one is.) – Gilles 'SO- stop being evil' Sep 10 '13 at 17:50
  • 5
    @Gilles: Sure. If it’s not, however… I just don’t see the harm in adding something that already works elsewhere for the specific exceptional cases. – Ry- Sep 10 '13 at 17:51
  • The FAQ link for latex now redirects to the tour page. – Stevoisiak Jul 18 '17 at 13:24
  • A good suggestion that should never have been closed, and if you could just edit it to say "SO and selected other SE network sites", then it should be reopened ASAP. – smci Dec 10 '18 at 3:15

This is implemented on http://math.stackexchange.com -- you can check it out there. It will never be on Stack Overflow, though, as it is an extremely heavy dependency. (See also Nick's investigations about impact in November 2013.)

Info here: TeX math markup is sorely needed

  • 11
    Well, you could conditionally enable it accross stackexchange, enabling consistent markup (question migration). By that I mean that you check the question and all answers if there is LaTeX block and if so, you load this "extremely heavy dependency". There are questions that would hugely benefit from that. – Rok Kralj Jun 26 '12 at 17:07
  • 57
    As it works just fine on math.stackexchange.com how is it too heavy? – donroby Aug 12 '12 at 16:54
  • 11
    Also on physics SE. – Calmarius Aug 16 '13 at 14:52
  • 1
    (@donroby, I know more than a year passed, but if you still wonder about impact and missed it: see Nick's investigations. Just the messenger!) – Arjan Dec 12 '13 at 20:22
  • 12
    -1 it should be enabled on any site that might use math. See stackoverflow.com/a/15966238/125507 for example – endolith Feb 25 '14 at 19:44
  • 13
    If Wikipedia guys (#5th website on Internet and non-commercial) had same point of view, I suppose we would never had math in Wikipedia as well. "It would never be on StackOverflow" is too strong a statement. Sure it can be enabled purely on client side and limit to only those posts. This is 2014 and StackOverflow was supposed to be THE website. Programming is mathematics. Knuth would have been disgusted not seeing expression O(n) rendered via LaTeX. – Shital Shah Dec 27 '14 at 7:11
  • 1
    How about moving the making of the decision to render LaTeX to the client side, so that it's the browser that will trigger the rendering? Would this negatively affect page load times for pages that don't use LaTeX? – Erik Allik Mar 9 '15 at 12:13
  • 1
    Any change in this for the likes of jqMath or KaTeX? Both of which seem to be much faster than MathJax – Toby Mar 23 '17 at 13:16
  • 2
    Funny that Puzzling, Physics, Chemistry, Crypto, and TONS of other network sites have LATEX, but it will "never be on Stack Overflow". Is is because they have less traffic? Or do they just have terrible load times and noone cares because they are less important? – NH. Oct 19 '17 at 23:13

enter image description here

As a workaround, you can easily embed LaTeX by generating an image of the equation using the following WYSIWYG editor: https://codecogs.com/latex/eqneditor.php.

enter image description here

  • 37
    Holy crap, this is useful. – Makoto Jan 20 '13 at 5:06
  • I know it's too late to ask, but is there an alternate to codecogs? This website has been giving a 503 - Service Not Available since past few days. – Ranveer Feb 15 '14 at 21:40
  • 3
    @Ranveer Daum Equation Editor – Anant Feb 20 '14 at 17:17
  • 5
    Images are discouraged across all SE, because they are impossible to search. – vonbrand Apr 26 '14 at 15:16
  • 2
    This is the only solution other than adding Math.SE style LaTeX support that's adequate to the problem, which is spelled out in @datenwolf's answer. Most of the comments and answers don't realize what sort of mathematics can be needed. With this solution, however, not having LaTeX support in SO is acceptable. Otherwise the lack of LaTeX support would limit SO to problems that don't require comparison of code with halfway complex mathematical specifications. Such problems are not common on SO, but if they couldn't be adequately be handled in SO, that would be sad. – Mars Oct 28 '14 at 5:00
  • instead of pasting image, you can just use the api url as the image, see my answer on stackoverflow – Mark Mikofski Sep 24 '15 at 18:25
  • 2
    Could we get something like LaTeX Equation Editor hosted by StackExchange itself? I don't like to link content of another site. [It would even give them a (strongly limited) ability to track users on this site.] – JojOatXGME Mar 6 '16 at 4:24
  • 3
    Not only they are impossible to search but they’re also not accessible to e.g. screen reader users. – bfontaine Nov 16 '16 at 15:01
  • 1
    Images are not selectable by parts, so not a good workaround – HackerBoss Oct 14 '18 at 22:44

Having LaTeX support on Stack Overflow would be great. After all SO is about programming, which covers algorithms. And some algorithms are easier explained if one can typeset math. For example whenever it comes to complicated transformation issues regarding 3D graphics, being able to typeset those matrices would be a huge benefit.

  • For 3D stuff, you should be at GameDev.SE anyways. LaTeX will take up CPU (on your computer and on SO's servers), and I believe it'll be only needed in 1/1000 questions or answers. And most of those questions could probably go over to Math.SE, or GameDev.SE. – Mateen Ulhaq Apr 16 '11 at 4:31
  • If you're really desperate, you can render the image, and then simply include the image in your question/answer. – Mateen Ulhaq Apr 16 '11 at 4:33
  • 4
    @muntoo: 3D isn't limited to gaming – I admit, that my 3D experience mostly results from developing a 3D engine. However it's as important in programming engineering tools (CAD/CAM), scientific visualization, modern user interfaces, etc. – datenwolf Apr 17 '11 at 8:50
  • @datenwolf I think physics simulation fits in to GameDev.SE, even if it's for a NASA rocket, and not just a game with a NASA rocket. GameDev.SE probably has a higher ratio of knowing "3D stuff" to number of [active] users than any other SE site. You don't have to tell them that you're going to be using it for a "game" or not. – Mateen Ulhaq Apr 17 '11 at 18:14
  • For stuff that doesn't fit into GameDev.SE, you could go to CSTheory.SE or Math.SE. (Or any of the other LaTeX enabled sites.) – Mateen Ulhaq Apr 17 '11 at 18:16
  • 5
    @muntoo, we don't get to choose where the questions go, and often the subject matter belongs on SO. – Adam Jun 14 '11 at 7:14
  • 1
    @muntoo if it is used in 1/1000 of the questions, it will affect SO's servers only in 1/1000 of the time... – vonbrand Apr 26 '14 at 15:19
  • I think you're wrong about SO being for algorithms. SO is for calls to library functions which implement algorithms. Questions and answers about algorithms themselves are normally downvoted or answered with library function calls. – sh1 Jul 31 '16 at 18:28
  • 1
    @sh1: To properly use a library one must understand the underlying principles that are to be achieved with doing these calls. Take computer graphics programming for example. A recurring question is, why normal vectors muse be transformed using a different set of operations (i.e. library calls) than regular vertex positions. Another recurring question is, why a separate tangent space transformation is required for normal map bump mapping. Just giving the recipe is only half the answer. It's also essential to understand "why". And the most concise way to explain the "why" is through math. – datenwolf Aug 2 '16 at 14:28
  • 1
    @sh1: Some of the mathematical notation, for the most part linear algebra can be typeset using unicode symbols. But already something as mundane as superscripts or subscripts is impossible with just markdown and unicode. Sometimes you want to typeset a partial differential equation, that can be found in a book or a paper about a particular graphics rendering technique and want to explain how to translate that into library calls. – datenwolf Aug 2 '16 at 14:31
  • 1
    @sh1: And then there's of course the broader issue that, thanks to the Curry–Howard correspondence writing a program is technically the same thing as writing a mathematical proof. So stating that programming and asking questions on StackOverflow is about how to call library functions is highly ignorant. And given that some languages (like Coq which allows you to write mathematical proofs and translate it into programming language source code), yes math typesetting is absolutely required. – datenwolf Aug 2 '16 at 14:35
  • Well in my experience, when I'm idle and take the time to look at new questions as they're asked; if anything interesting and algorithmic does come up or if it requires any thought at all then it's downvoted and eventually closed or deleted. SO only accepts questions that help game the system for reputation, and that's a matter of familiarity with libraries where you can spit out an answer quickly for the reputation avalanche of being first responder. – sh1 Aug 2 '16 at 15:34
  • 2
    @sh1: Two of my most highly voted answers are quite heavy on the math: stackoverflow.com/a/6661242/524368 and stackoverflow.com/a/5257471/524368 – both of them are lacking in the quality of the mathematical typesetting. In case of the "how to calculate normals" answer I was able to make use of Unicode to somehow typeset it. The answer on how to derive a tangent space mapping tries to use ASCII art to typeset matrices and fractions, but it looks ugly (in fact it's that later answer, which lack of proper math typesetting which made me ask about adding support for TeX/LaTeX at SO). – datenwolf Aug 2 '16 at 16:24
  • @sh1 Easy counter-example to your claim: there is a bug on Spark MLlib implementation of an algorithm that results in an error. I want to show the algorithm it were intending to implement: without any details about the why of it. That is squarely an SO question - but at the present time the algorithm / equation itself would have to be an unsearchable image. – javadba Jan 6 '17 at 17:11

Although I'm a big LaTeX fan, I don't think the work would be justified for Stack Overflow.

Since Stack Overflow is one of the sites on the web that gets Unicode right, you can do standard things like

K ⊆ A



anyway. And <sub> and <sup> are whitelisted, so you can even do more complicated things like




  • 23
    that seems way more complicated doing O(n<sup>2</sup>) than O(n^2) for the same thing... – tzenes Feb 23 '10 at 5:09
  • 2
    @tzenes: Pick your examples right. O(n^2) is still more than O(n²). But again, I love Latex, and I wouldn't have a problem with it being implemented on SO. I just feel that the work necessary to do that isn't justified by the few times this is actually needed. – balpha Feb 23 '10 at 8:04
  • 2
    Well I came onto this subject when writing this answer: stackoverflow.com/questions/2315987/… It took me a long time to get all the tags right, especially considering how much easier latex would have been... – tzenes Mar 11 '10 at 4:20
  • Expressions featuring summation, integrals, products, roots ... would be nice examples. E.g. ∑<sub>i=0</sub><sup>n</sup> just doesn't look right. I don't know wether it justifies the work for the few questions that need it though. – Georg Fritzsche Aug 4 '10 at 18:52
  • 3
    About justifying "the work" that'd need to be done - since mathoverflow has it working perfectly, it seems like it would be a simple matter – Claudiu Mar 6 '11 at 17:52
  • 1
    @Claudiu: Yes, it's done client-side via JavaScript. This requires every single user visiting the site to download gigabytes of JavaScript (okay, slightly exaggerating) for something that's interesting for at most a tiny amount of posts. – balpha Mar 6 '11 at 17:57
  • 3
    While this is a fair suggestion, I'd certainly rather have people download excess code than suggest that people learn to use Unicode for formatting. Wasting a few bytes for some users isn't quite the same as wasting brain cells. Nonetheless, mentioning Unicode points to gradual evolution in browsers, and perhaps a future version of HTML or browsers will make this question irrelevant. – Iterator Nov 18 '11 at 21:53
  • @balpha can you provide a link on how to use <sub> etc and also how do you generate the unicode characters?Through a char-map and then copy and paste or is there some nice shortcut? – Dan Jan 14 '14 at 10:51
  • @Iterator, yep. It's called MathJax ;-) – vonbrand Apr 26 '14 at 15:17
  • There isn't any "work" involved. They already have it working on every other stack exchange site – endolith Sep 11 '18 at 15:31
  • @endolith Note that this answer is from 2010. – balpha Sep 11 '18 at 15:47

It would be fantastic to have this. There are times when a statistical programming question arises where either Stack Overflow or Cross Validated would be an appropriate site (maybe Stack Overflow will have the edge), but I would rather see it on Cross Validated simply, because one can have LaTeX formatting.

The use case is pretty simple: Joe comes along with a question about how to do X in R (or MATLAB, Python, whatever), and there's an issue with his math and his implementation. For example: the two don't match. Another scenario is that of this question, where we could Q&A on the mathematical inverse, and a good way to code the transformation. It is irritating to address the mathematics within an environment where the formatting support is weak. Both sites (Stack Overflow and Cross Validated) have adequate support for presenting code, so the winner is the site that supports the formatting of mathematics. The same is true for $\textrm{computational math} \setminus \textrm{statistics}$ and the Stack Exchange site Mathematics. ;-)

To that end, I hope that moderators will accept some flags that suggest that a question is better for Mathematics or Cross Validated based on topic, audience, etc. and the ease of answering the question with the available formatting tools.


For simple math, you may use this user script. It adds a math bar to the editor for some commonly used symbols:

enter image description here


While I think that most questions asked on SO where it would be useful to use math formatting are probably off-topic and more appropriate for CS Stack Exchange, it would still be much easier in many cases just to answer the question on SO than to try and migrate it. I don't see how having the math formatting on SO would conflict with anything else. Some people simply don't know about CS Stack Exchange, and so it is easier to ask a question on SO.

I know I have answered questions on SO where the math notation would have been useful. There are instances where you want to talk about algorithm complexity while working with code in a particular language.

As another note, why the heck can't I get code coloring on CS Stack Exchange? Since CS Stack Exchange is smallish and there is a decent amount of overlap between CS Stack Exchange and SO, I really think we ought to just merge them and support math typesetting in SO.

Basically, BOO to the people that declined to implement this. It shouldn't be hard, since it is already in place on other sites, and it wouldn't really conflict with anything. If I knew more about how the sites worked, I would do it myself.

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