3

Now and again, when I've written some new 'code' (plain text, equations, special commands etc.) in my LaTeX editor and I compile the file, I get an error. Normally when I get an error, I check the code that has subsequently been highlighted by the editor. However, in the case of these 'unexplained errors', no code highlighted (and as with all 'red' errors, the code doesn't compile). So, I compile again and... it works. Normally I just carry on writing but this time I thought I'd try to find out if anyone else has experienced this and if anyone know why it happens.

Edit 1 Here's a screenshot of the error:

enter image description here

Mensch
  • 65,388
User 17670
  • 4,722
  • 3
    What errors do you get? – Martin Schröder Feb 16 '13 at 23:04
  • I do realise that if there is a legitimate error in the code, then the best way to find out why your document hasn't compiled is to read the error message. However, in this case (which is very infrequent I should add, say, 1/100 compilations), there seems to be nothing wrong with the code, because hitting compile a second time makes it work. In this case, wouldn't the error message be nonsense?

    To answer your question, I do not have the error message because I have since compiled my document (and the document loaded perfectly with no changes to the code).

    – User 17670 Feb 16 '13 at 23:13
  • It's hard to answer your question without an actual error message, the code that caused it and more information about your environment (OS, IDE, distribution). As it is, your question is a perfect example of "too localized". – Martin Schröder Feb 16 '13 at 23:17
  • Right, OK. My idea was to see if anyone else had experienced a similar problem, and to see if they knew why 'this kind of error' occurs. If, as you say, the question is essentially unanswerable, then I will delete it and return with an error message the next time I have 'this type of error'. – User 17670 Feb 16 '13 at 23:22
  • 3
    It is possible to get errors that go away upon subsequent re-run. Every time you run LaTeX temporary files are generated which are read upon a subsequent run. If the prior run did not complete for some reason it is possible that the temporary files are corrupt so you get an error next time you run it. But during this run, those temporary files are rewritten so that a subsequent run will run without errors. – Peter Grill Feb 16 '13 at 23:23
  • 1
    @User17670 next time take a screenshot or save the .log file so that you can help us to help you. watch the Joy of tex errors.you can notice latex bug status here – texenthusiast Feb 16 '13 at 23:24
  • 1
    @User17670: A suggestion: Change your username to something more telling than "user17670". – Martin Schröder Feb 16 '13 at 23:25
  • Ah, thanks Peter. That may be the issue. And thanks for suggestion texenthusiast, I will do that next time. – User 17670 Feb 16 '13 at 23:26
  • 1
    @User17670: Please don't delete it: This discussion might be of value for others in similar situations. – Martin Schröder Feb 16 '13 at 23:27
  • @MartinSchröder Why change my name? – User 17670 Feb 16 '13 at 23:27
  • @MartinSchröder Exactly, I don't understand why this legitimate question got a downvote. – User 17670 Feb 16 '13 at 23:28
  • @User17670: Because as it currently is it is unclear. – Martin Schröder Feb 16 '13 at 23:29
  • @User17670 name change is your wish of course. But Martin tells you to change so as to give the community a feeling of connectedness and a human profile/ avatar creates more friendly/trusty nature of discussion. Final call is yours of course. – texenthusiast Feb 16 '13 at 23:41
  • Where do I find the log file, or is it not needed in this case? – User 17670 Feb 17 '13 at 00:06

1 Answers1

4

It could happen that errors (or their descriptions) sometimes have no relation to where or what the error points to. Probably in its simplest form, although not really errors, is LaTeX's \label-\ref system. You document is perfect, yet the references show up as ?? when you compile. "Suddenly", when you compile again, the references appear as expected. Similarly for a Table of Contents; it always seems to be one step behind, or causes errors "out of nowhere."

If this seems to be the case, always start fresh by deleting an auxiliary files (.aux, .toc, ... see File extensions of LaTeX-related files and/or Egad! What are all those files?) and compile again, at least twice (sometimes more) since references and other things may take a couple of runs to settle.

Typical errors related to compilation usually stem from content left in the .aux from the previous run. Common packages that cause this is hyperref and tikz/pgf, since they write actual command definitions in there (of course, attempts by the package authors are made to avoid this). That is, upon a removal of these packages, the first re-compile still processes an .aux containing definitions that are completely unsupported, and might cause problems in your document.

Knuth describes TeX as an "eating machine" (chapter 7 How TeX Read What You Type, p 38):

It is important to understand the idea of token lists, if you want to gain a thorough understanding of TeX, and it is convenient to learn the concept by thinking of TeX as if it were a living organism. The individual lines of input in your files are seen only by TeX's "eyes" and "mouth"; but after that text has been gobbled up, it is sent to TeX's "stomach" in the form of a token list, and the digestive processes that do the actual typesetting are based entirely on tokens. As far as the stomach is concerned, the input flows in as a stream of tokens, somewhat as if your TeX manuscript had been typed all on one extremely long line.

To put it bluntly, it may be that TeX has already gobbled some of your content and only developed the stomach problems at a completely different/later stage.

For some TUMS*, see

* A possible remedy for TeX's Unknown stoMach problemS

David Carlisle
  • 757,742
Werner
  • 603,163