# Why does TeX require such elaborate MWE:s

Compared to StackOverflow, where you basically can post code snippets and ask questions about them, this community seems to require more or less the entire document to be posted. Why so, is it the nature of TeX, that have way too much in global scope, or is it just a different policy on this site?

• Demanding MWE's is not a policy but many, many times a requirement. Often the behaviour of code snippets depend depends on the document class, on loaded packages, on user defined code which is missing, even on package versions… This means that in the vast majority of cases help isn't even possible without a MWE. MWE does not mean you have to post your whole document, though. The M stands for minimal for a reason: include just enough for everybody else to reproduce the issues you're having. The entire document is never needed! – clemens Aug 16 '15 at 16:40
• @clemens So it is a lack-of-scope issue – user877329 Aug 16 '15 at 16:50
• @user877329 If you are asking a tex-core or similar 'programming level' question then it's much rarer to need a MWE than if you are asking a 'document level' question. SO is rather more similar in to programming level here. – Joseph Wright Aug 16 '15 at 20:42
• A part of this is that it makes the answerer's life easier (and the asker's responses better and more numerous) if a minimum compilable document is given. Then I can just copy and paste the code and I can have exactly what you've got and I can compile it and see exactly what you see. I don't have to reconstruct a document around your snippet before I even start work on the problem. And, of course, as has been said I have no idea what kind of preamble you might have and then I could easily miss the problem or else waste my time writing a solution which doesn't work because you're using x – Au101 Aug 17 '15 at 0:01
• See, just for example, the history of this question: tex.stackexchange.com/questions/258946/remove-space-symbol/… Where the question as posed was answered and then, only later, did the OP come back and clarify something which made a big difference and meant going back and revising the answer. Which is obviously frustrating for the answer author and the questioner. All of that hassle could have been avoided if the proper context had been present – Au101 Aug 17 '15 at 0:02
• Your question about how to add a custom field to a bst uses a large, private library (the bst) and I find it rather curious that you expected an answer without showing this library. – Ulrike Fischer Aug 17 '15 at 9:16
• @UlrikeFischer I do not think it helps, since going through that code would take a day or so. – user877329 Aug 17 '15 at 9:23
• If moeve would offer you a solution, could you assess it without your library? Nobody needs to go through all the code but to test a solution the library must be there. – Ulrike Fischer Aug 17 '15 at 9:38
• I'm always amused by the asking of a "Minimal Working Example", when what people are really asking for is "Minimal Example". If it was already working, there would be no reason to ask the question in the first place, right? – morbusg Aug 17 '15 at 11:08
• @morbusg: "working" refers to the example being a "complete" or "compilable" example document, not just a snippet (which is what "minimal example" sounds like to me). – Jake Aug 17 '15 at 13:10
• @Jake: I know, but often the example is not compilable (so, not "working"), hence the question. So maybe "Minimal Complete Example" would be a more apt name. – morbusg Aug 17 '15 at 15:08
• Since nobody has mentioned it, I'd like to point out the quality of questions on this site. I believe the boilerplate 'need an MWE' comment does produce better questions in the end. Just look at how many downvoted unanswered questions there are on SO that amount to 'why it no worky'. – Sean Allred Aug 19 '15 at 15:25
• Also, a small note: "that have way too much in global scope" --> note that there isn't as much in the global scope as you might think there is. The problem is the scope is highly cascading; the behavior of one level is very much dependent on the state of higher levels. This is why we need a MWE to determine the state of the shallower levels before we can diagnose an issue in the deeper levels. – Sean Allred Aug 19 '15 at 15:27
• I find dumping the entire document into an MWE just as annoying as posting a code snippet which leaves out the document class and packages. That and using graphics files not available in general. If the user would actually construct an MWE by removing everything not relevant he might solve the problem himself. – John Kormylo Aug 23 '15 at 16:21
• I find dumping the entire document into an MWE just as annoying as posting a code snippet which leaves out the document class and packages. Then it's a WE, not a MWE. – jub0bs Aug 24 '15 at 11:17

Just to make an example, look at europecv stack exceeding which cannot be answered in the current form, as

\documentclass{europecv}
\usepackage[T1]{fontenc}
\usepackage[magyar]{babel}

\begin{document}
x
\end{document}


gives no error whatsoever.

In the .../tex/latex subtree of TeX Live there are currently 2066 directories, which correspond to more than 2000 packages. A question about a problem depending on one of these packages must, at least, mention what package is necessary. Also knowing the document class is often needed, because some classes redefine some commands such as \title, \maketitle or \chapter: think to memoir that introduces a second optional argument for \chapter and the other sectional commands; instead, scrbook introduces a key-value syntax for the same set of commands.

Not to mention that some packages are pairwise incompatible, or should be loaded in a particular order with respect to others. Knowing the list of needed packages is therefore essential in most cases. Another case that comes to mind is that of a tikzpicture that uses features only available in additional libraries: these should be mentioned. Playing hide and seek is fun, but limits the chances to get an answer.

Consider that adding a suitable document preamble around a code snippet that doesn't mention the necessary class/packages requires a non-trivial effort from people trying to help: in several cases it's really impossible to prepare an answer, if information is insufficient.

It's not really different from C snippets that depend on unspecified libraries and I'm quite sure that such questions would be fast closed on StackOverflow.

This doesn't mean posting the entire document, but only a “compilable abridged version” that exhibits the issue, particularly when errors or unexpected output is concerned. It often happens that trying to make the MWE helps the questioner in pinpointing the problem.

• Perhaps also note that to get a snippet to run requires (for LaTeX/ConTeXt) a non-trivial amount of effort from people trying to answer? – Joseph Wright Aug 16 '15 at 20:39
• @JosephWright And a non-trivial amount of knowledge! In some cases, I've answered questions involving packages I've never used because the MWE let me figure out the problem. Without the required preamble, I'd have had no clue how \somemacroiveneverheardofbefore was defined or in which of the thousands of files in my installation (or not) it might lurk. – cfr Aug 17 '15 at 0:20
• "t's not really different from C snippets that depend on unspecified libraries and I'm quite sure that such questions would be fast closed on StackOverflow." There are tags for that. I am pretty sure I do not have to include a main function on SO. But indeed things may become horrible in C when there are a lot of macros. LaTeX may benefit from separate translation units. Then there would not be that hard to figure out what the problem is. – user877329 Aug 17 '15 at 12:58
• The example question mentioned the hungarian option and the europecv environment. Adding it gives that error. For convenience, I added the MWE for reproducing to my answer there. – Stefan Kottwitz Aug 17 '15 at 13:19
• @user877329: Ultimately you're here (on SE) to ask for help. The onus rests on your shoulders to spoon-feed your audience with as much detail as possible. This includes showing some effort on your part of what you may have tried. I've seen plenty of "it doesn't work" in my time, only to make up some small code and "it works". When you ask a question, put yourself in the shoes of someone else and use that as a frame of reference. Never assume that "[it] would not be that hard to figure out what the problem is". If that's the case, then you might as well figure out the problem yourself, yes? – Werner Aug 17 '15 at 14:47
• @werner "Never assume that "[it] would not be that hard to figure out what the problem is". If that's the case, then you might as well figure out the problem yourself, yes?" - the user likely means for experts, from the perspective of a newcomer, so I don't think 'figure out the problem yourself,yes?' is relevant. – Laua Aug 17 '15 at 16:36

Another very important thing to note is language, as in written language. LaTeX uses easy-readable commands in plain english, this is great but not my point.

Here at TeX.SX are people of many many nations helping each other. Describing a problem in words can be very hard in a different language, espeacially when a special nomentclature is in use. I have seen the word title in many questions, some meant the real title which is set with \title, some meant the page header, some meant the chapter title.

Imagine to be in a different country and your car breaks down without speaking the language. It will be very hard for you to explain to a mechanic what is wrong with the car, even more if your own knowledge of cars is limited and you don't know how the parts are called. Drag the mechanic to the car and use your finger to point.

Most LaTeX problems are purely mechanical as well. As you cannot drag us in front of your computer, and sending us a complete document isn't possible, boiling down the document (i.e. pointing with the finger) is an efficient way to get quick and personalized help.

• My problem is that I do not know how to pointing with the figure. So all I can do I give you what I want TeX to produce. – user877329 Aug 17 '15 at 13:38

Some remarks about the "global scope" in the question: Yes LaTeX (not TeX) needs quite some global code. You can't compile

  hello world


It gives the error

 ! LaTeX Error: Missing \begin{document}.


And adding only a document environment doesn't work either

\begin{document}
hello world
\end{document}


gives the error

! LaTeX Error: The font size command \normalsize is not defined:
there is probably something wrong with the class file.


So in most cases when I investigate a LaTeX problem -- may it be to find the cause of an error or to add some feature -- I work with complete documents and this means that a good question should contain all needed parts to create a complete document as test suite with as less fuss as possible. Such complete documents can be quite small, but there have been cases where a large graphic, or a large data file for a plot, or some other large file was either really necessary or couldn't be removed easily.

Another reason why minimal examples are often required (meaning "necessary to solve the problem" not "mandated by the site") is that errors in TeX are notoriously cryptic and the line number at which an error arises may be very far away from the actual source of the error. So, for example, someone gets an error and the posts the fragment of code that the log reports the error occurred at. But depending on the error, this fragment may be completely fine, but happens to be the first place at which the error state arises.

And new LaTeX users are particularly susceptible to this problem, since if they bother to read the log file at all, they would expect it to be helpful.

See ! Paragraph ended before \@optionaltemp was complete for a very concrete example of this problem along with a detailed explanation.

The effort to produce a minimal working example, in my case, almost always results in a solution and prevents me from posting a question on the site. Not that we want to discourage questions, but there is a lot you can do to debug a problem before you ask for help, and the MWE encourages that.

• since one of the goals of this site is to encourage learning, i'd say that the effect is precisely the desired one. even so, if the question you would have posted before you found the solution is one you think would help someone else in the future, then post it anyhow, and give a "self answer" after a day or so. – barbara beeton Aug 19 '15 at 16:27
• @barbarabeeton, this might not always be useful. When the above happened to me, it was very often that I discovered some totally idiotic mistake on my part. – vonbrand Aug 21 '15 at 13:56
• @vonbrand -- true enough (it happens to all of us), but sometimes the problem is one that is particularly elusive, or uncovers a bug, and in those cases it can be useful to make the result public. use judgment. – barbara beeton Aug 21 '15 at 14:18

Because in TeX, unlike other programming languages, the entire document to reproduce the problem is hardly ever longer than 30 lines long. And typing that much shouldn't be seen as a burden to get an answer from the community that is known to be very fast to respond already.

And most of the times, you find out the problem yourself while creating the minimal document because there is not enough places to escape (either package clash or wrong macro expansion order etc.).

Lastly specific to TeX and friends, the problems can be environment-aware that is, a particular preamble setup can cause errors in an otherwise perfectly viable document (document class quirks, package options and so on).

• "Rubber duck programming" is it called otherwise ;-) – vonbrand Aug 21 '15 at 13:55
• @vonbrand Starbucks coding is what I would say thanks to all Mac using hipsters every morning I see around. – percusse Aug 21 '15 at 15:03