2
(/usr/share/texlive/texmf-dist/tex/latex/thmtools/unique.sty
Package: unique 2012/05/04 v63
\uniq@channel=\write6
\openout6 = `main.unq'.

)

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.334 ]{definition}

How can I go deep to find what the real error is? \begin{document} is there in main.tex, and the code compiled just fine this morning.

egreg
  • 1,121,712
juliohm
  • 3,452
  • 4
    LaTeX is telling you that you have something wrong in line 334, but this probably is not enough to find the error. If you type H at the prompt, LaTeX tells you a bit more (not enough as well, anyway). – karlkoeller Aug 25 '13 at 14:11
  • Something had to have changed. Can you post an MWE? – Sean Allred Aug 25 '13 at 14:15
  • Can you show a minimal example of code producing the error? – egreg Aug 25 '13 at 14:20
  • Did you try deleting main.unq before compiling? – karlkoeller Aug 25 '13 at 14:22
  • Thank you all, I've tried the H key, but to me it seemed useless. Found the error by bisection, commenting out huge amounts of code. – juliohm Aug 25 '13 at 14:22
  • Could someone please provide a MWE and follow the H button until the bug is found for illustration purposes? I would check it as an appropriate answer. – juliohm Aug 25 '13 at 14:28
  • Take a look at "What makes a good MWE" for how to build a MWE. It's not something we can do for you since the MWE should illustrate the problem you're having. – A.Ellett Aug 25 '13 at 14:31
  • @A.Ellett: I'm asking someone with free time to design a MWE with a bug in it, follow the H button and discover the exact line source it's located. My problem was already solved by brute force. – juliohm Aug 25 '13 at 14:35
  • 1
    I'm not sure such an example would be very useful. LaTeX does the best job it can to detect errors. But even after hitting "H", you may not get any better idea where the error is. Somewhere on this site, however, is a list of common things to look for when you have a particular kind of error such as "Missing \begin{document}" when, in fact, it's there. I'll see if I can find that resource and post it here. – A.Ellett Aug 25 '13 at 14:44
  • 1
    @juliohm you say you solved the problem by (tedious) by brute force: can you reveal what the problem actually was? it might help a future user scanning the site, saving the time of turn-around for a question. – wasteofspace Aug 25 '13 at 16:10
  • @wasteofspace, it's really specific: when declaring a new theorem environment with thmtools, we can't pass both numbered=unless unique and numberwithin=chapter. – juliohm Aug 25 '13 at 16:46
  • Without a MWE this question can get only generic answer. With no MWE in a short time, voting for closing it will be necessary. – egreg Aug 25 '13 at 19:56

1 Answers1

6

The error is on line 334 of some file, it is not possible to say which file it is from the fragment shown, you need to look in the log and match ( and ) the line number relates to the filepath shown by the currently open (.

The missing document error is shown if TeX tries to typeset a paragraph before \begin{document}, so you have a command

\foo[]{definition}

but \foo was not expecting an optional argument so took [ as the main argument leaving ]{definition} which was then taken as plain text, started a paragraph and generated the error message.

David Carlisle
  • 757,742