# Why can't TeX.SE compile my TeX code?

(This might have been asked before, but I could not find it.)

A lot of questions and answers on this site have some piece of code (to be compiled with one of the standard engines) and a screenshot. As many online services prove, it is very easy to get TeX running on a server. So why do we not have a compilation engine built into this site, that you can use to compile your document and save a screenshot to be used in the question? (note: only if you explicitly ask it to, see the edit below). Obviously, there are concerns, like which part of the document should be on the screenshot, but that is a matter of letting the author specify this. Also, there are questions and answers that will not be compatible with such a feature, and will still require manual compilation and screen-capture; but those are, IMO, a minority.

EDIT: How could it concretely work: There are several formats (plain, LaTeX, ConTeXt), several engines (pdfTeX, LuaTeX, XeTeX). We just need to support those; then it is up to the user to specify how they want their document to be compiled. A greater concern is that TeX changes, the packages get updated, and some of the old code on the site might not compile anymore. Well, this is obviously only an issue if we would like to ensure that people can recompile old code if they would like to update an old question. If we do want to ensure backwards compatiblity, then we might use TeX Live, and include the version from each year. Then the user could specify that they would like to use, say, the 2014 version. This will not work for all questions (like questions about extremely new versions of packages not yet included in the newest TeX Live version), but many of them. So in the majority of cases, I am confident the system would work; and for those that do not work, people can always stick to the good old manual solution.

EDIT: This question is not a duplicate of Automatic rendering of code provided in questions/answers?; that question (at least in its original statement) asks for a MathJax-like solution like the one found on Math.SE and Phys.SE. That was not what I referred to; rather, I want an engine to automatically compile MWEs using standard TeX engines. That being said, the question was modified to sound more like the present one. However, nobody answered the question in that form. In other words, that question did not "solve my problem".

EDIT: People appear to have gotten the wrong impression that the feature would be forced upon you, that it would compile your code even if you didn't want it to. This is not what I meant; it should only compile your code if you explicitly ask it to. That's what buttons are meant for.

• Several factors come to mind. First up, this would be one for the 'powers' not the TeX-sx regulars, and for the 'powers' it would only benefit one site (so effort vs. outcome is perhaps not great). Then we have the issue of multiple engines, package versions, etc.: quite often it's important to know exactly what the OP sees with their own system as it may not be the same as what someone else sees. Then there's the technical stuff: which bits of a question get compiled, how to pick up different engines, plain vs. LaTeX vs ConTeX vs ...
– Joseph Wright Mod
Apr 22 '15 at 15:01
• BTW, I'm not sure what an answer might look like here: the back end is down to the Powers, so presumably this requires an answer from the staff.
– Joseph Wright Mod
Apr 22 '15 at 15:05
• True, that was the point of the last few sentences. Well, whether to use plan, LaTeX or ConTeXt, or to compile using pdfTeX, XeTeX, or LuaTeX is something that could be built into the interface. But yes, if the question is "how do I get this working using TeX Live 2013", then we have to use the manual solution. But as mentioned, I'm confident that for the majority of all questions and answers, it would not be an issue. Apr 22 '15 at 15:07
• Yes, there is the matter that old questions would perhaps not work with the most recent package versions. But then again, that could be solved by using, say, TeX Live and manually specifying which year's version I want to use. Apr 22 '15 at 15:09
• @Gaussler I think you don't know the site well yet. A lot of issues are related to minor changes to this or that package, another bunch of stuff is a MWE, but doesn't compile because of some minor whatever wherever, a lot of Q don't have a full MWE at all.
– yo'
Apr 22 '15 at 15:10
• @yo', for your first concern, those questions would just not be supported by this system; the point from the very beginning was that it would not work for all cases, just the vast majority. Regarding questions lacking a full MWE, then they just have to provide one (like they should), or stick to the manual solution. Apr 22 '15 at 15:12
• We're not speaking about "not all", we're speaking about "minority", at least from what I view.
– yo'
Apr 22 '15 at 15:14
• Suppose we had one. We need write access which a server needs space for it that goes away. We need --shell-escape hence a framework. That goes away too. We need facilities to convert the resulting pdf to png hence external tools that goes away too. Note that even the screenshots are saved by imgur thanks to a special collaboration with SE network hence needs to be saved to imgur server because SE doesn't hold them. That needs a proper sandbox way further than a TeX server. All in all what you are left with is bunch of questions hence not worth it. Apr 22 '15 at 15:19
• @percusse "It is not worth it, too much work." How every new, brilliant idea is drowned in this world. Apr 22 '15 at 15:41
• @Gaussler Not worth it in the sense of should we support windows vista?. Not in the sense of should we design a new OS? to the latter the answer is always yes and to the former always a no. Apr 22 '15 at 15:45
• In addition to what I said earlier, I think it's notable that some questions need a screenshot while others need only code or indeed just a description (yes, such questions do exist!). For those that need a screenshot (i.e. where one is essential not just 'nice') there's usually a reason, and often that is of the form 'Can you post a screenshot as I don't seem to get what you describe?'. Those cases don't necessarily get addressed by any automation.
– Joseph Wright Mod
Apr 22 '15 at 15:52
• In my opinion, there is no need to downvote this question!
– user31729
Apr 23 '15 at 11:51
• @ChristianHupfer agreed there is nothing wrong with the question, even if the answer is that it would not be at best a not so useful feature Apr 23 '15 at 15:30
• @MartinSchröder hmm question is exactly a duplicate (but I haven't voted) that question is rather old and the state of online tex servers has changed radically since then, so the discussion here is rather more relevant today, if they are to be merged I'd rather see the mods take action to reverse the duplication, closing the older one. Apr 24 '15 at 8:40
• @ChristianHupfer: Note that Meta tends to differ slightly from the main site, most likely fuelled by the lack of reputation. A downvote could indicate that the reader does not agree with the suggestion as opposed to considering it a poorly constructed post.
– Werner Mod
Apr 24 '15 at 12:58

I'd be against this really.

Apart from any technical issues about setting it up, I post a lot of answers and a lot of those have images but almost never do I post a complete document.

For a multipage document I take a conscious decision which page or pages to show, and for a single page I usually crop to the area that I want to highlight in the answer. I also often need to state explicitly what tex distribution I'm using (TL2015 pretest currently).

I can not see how having TeX run remotely rather than locally helps achieve any of those things.

As someone who posts answers rather than questions, I think it would adversely affect me as I think that it would tend to lower the quality of the examples as it encourages people to post their entire thesis rather than working to make a 6 line example they can post inline into a question.

Encouraging the OP to make a useful example is the main technique for being able to post useful answers and so I'm against anything that seems to lead in the opposite direction (I know that isn't the intention of the proposed change but human nature being what it is, I think it would be the result)

• Regarding cropping the document, notice that support for this was part of my suggestion. Also, I didn't say that you had to post the entire code in an answer just in order to use the feature. Apr 22 '15 at 16:55
• @Gaussler you had a vague reference to it, but I don't see how that would work: if I only supply the tex and the site back end produces the image, where would I specify cropping? But the whole thing seems of very limited use since presumably people have tex available. Apr 22 '15 at 16:59
• How would it work? Simply by making an interface. I didn't say you just had to supply the code and sit back; you could specify the coordinates, either in numbers or by marking the area on a screen. It should be possible to do in a browser; I'm not saying it's extremely simple to implement, but it is certainly possible. Apr 22 '15 at 17:05
• @Gaussler anything's possible but it's work and I see no advantage over doing it locally. Apr 22 '15 at 17:38
• Did you notice that there even was a downvote for your answer? :-((
– user31729
Apr 23 '15 at 14:59
• @ChristianHupfer no, I hadn't :-) Apr 23 '15 at 15:28
• If it helps you to know, my question got a downvote, too. :-) Apr 24 '15 at 6:59

I would not be fond of such a feature at all, but this is a personal point of view, I know, but there are some non-personal issues too!

The technical obstacles are

• Providing the engine behind the post to compile and display the result is possible (as online TeX editors prove), but not so easy to include into the SX engine at all
• When is the code compiled? Once when the post is edited? Each time a user lands on the post?
• You have to introduce a possibility to upload/provide extra files, say .bib or graphics, let alone one of the presumably 10^12 thesis.cls floating around in the TeX world --> more overhead and where are those extra files stored?

Apart from technical issues, I don't like entering code online. I often copy it from my local editor and paste it into the TeX.SX post window (as I am just doing right now)

• Dear unknown Downvoter: Could you explain why. Downvoting without notice is... well, you know ;-)
– user31729
Apr 23 '15 at 7:05
• The code is supposed to be compiled when the post is edited; the other solution is not feasible, it would be too slow. Apr 24 '15 at 6:48
• Regarding .bib files, this itself should be possible, but it wasn't actually a part of my idea. There are, in many cases, workarounds that do not involve creating extra files; and in the cases where there are none, you can always stick to local compilation. Apr 24 '15 at 6:50
• @Gaussler: I acknowledge your clearifications. If this is ever added to TeX.SX, I would request the possibility to switch this feature off ;-)
– user31729
Apr 24 '15 at 6:51
• There is nothing to turn on and off :-) . I never meant that the engine is supposed to just compile the code in your post, whether you want it or not. It should only do so if you explicitly ask it to. :-) Apr 24 '15 at 6:54

I think this feature is a brilliant idea. Somebody who has a new question just needs to drag'n'drop their latex folder onto the question, and it compiles automatically (if it does), provides a stacktrace (however useless), and provides the full output at a finger click.

New questions would always have some (at least) partially executable code, not just single lines of potential issues, without no knowledge which packages have been loaded. If the questioning party uses cloud based software, an API could provide integration, and it would make TeX.se more accessible. Just remember the number of questions which were impossible to answer without a long discussion as the person didn't mention they were loading hyperref first.

You would no longer need to copy code to your local machine, no more need to make sure you have the same versions installed just to reproduce the problem - instead you could work with the exact same version in the browser, inspect their sources, all at your fingertips. No more grep-ing for defs.

Of course there are technical challenges that need to be resolved, but in a day and age where most computations happen in a cloud far away where software like sharelatex supports automatic compilation form git repositories already, this cannot be too far away. Of course it will be a challenge, but it will make LaTeX more accessible for future generations and ensure that TeX.se will lead the way!

• Exactly my reasoning! Apr 24 '15 at 6:35
• Not convinced at all. I think the net result would probably just be that people didn't spend time thinking of good small examples that highlight the problem, but simply drag complete existing documents into the site making it less useful, and harder to answer the questions. You say "no more grep" but when answering questions I want to use grep and emacs and my debugging environment, I wouldn't want to debug code in an online document editor environment. So I'd expect to almost always download the files before answering even if such a feature was available to people asking questions. Apr 24 '15 at 8:35
• I'm not saying you have to debug in an online environment; I'm just asking the site to provide an easy way to generate screenshots online. Compiling locally, then screen capturing, and finally uploading the picture --- to me it sounds like a process that could be greatly simplified. Apr 24 '15 at 8:43
• But if people still prefer to use the local compilation, it is there for them; we're just talking about adding a feature which some (so far, at least me and one other) would appreciate. It is not forced upon you at all. Apr 24 '15 at 8:44
• @Gaussler as someone who posts answers rather than questions, I think it would be forced on me as I think that it would tend to lower the quality of the examples as it encourages people to post their entire thesis rather than working to make a 6 line example they can post inline into a question. Encouraging the OP to make a useful example is the main technique for being able to post useful answers and so I'm against anything that seems to lead in the opposite direction (I know that isn't the intention of the proposed change but human nature being what it is, I think it would be the result). Apr 24 '15 at 9:16
• @DavidCarlisle, I understand your concerns, and to me, it is a much more valid argument than the others I have heard. Well, a solution could be to simply ignore/close the questions where people post entire theses -- just to make it very clear that this is not what TeX.SE is meant for. Apr 24 '15 at 9:19
• @Gaussler hmm if that looks reasonable, I'll add it to my answer rather than it being buried in a comment Apr 24 '15 at 9:45
• To me it appears that this answer has a second name: Laziness. Sorry, I can't help this feeling.
– yo'
Apr 24 '15 at 20:33

If TeX.SE would compile code for you, then people could abuse the resources provided by TeX.SE for "outsourcing" the process of creating .tex-files for their documents:

Just start composing a new question containing a code-snippet which makes up the entire document that one is about to create. When one is done and the result is fine, then just copy the code snippet to text-file/.tex-file on one's own machine and abort the process of asking the question instead of submitting something.

After the weekend go to the computer center of your campus and compile the .tex-file in order to obtain the .pdf.

The 30000 character-limit and multifile-projects might be a problem.

Nevertheless I assume that it might come to abusing TeX.SE-resources this way in favor of maintaining a TeX-System on one's own machines.

• Thanks for opening up a 6 year old meta question. I think the proposal was scrapped quite early back then due to lack of support. ;-) Jun 7 at 13:22