[Tex/LaTex] “There’s no line here to end” error when pages break at unfortunate locations

errorsline-breakingparagraphs

I'm recieving seemingly random There's no line here to end errors at different parts in my code. At first I thought they were truly random and that I had some weird configuration error somewhere, but after more thorough investigations I have found that the error occurs when a page break and an extra line break within a paragraph coincide.

For example, if I have a paragraph containing an eqnarray* environment, and the entire paragraph does not fit on the page (so that the page breaks in the middle of the paragraph, usually between a line of text and the eqnarray*), I get the error.

Does anyone have any idea why this happens?

Best Answer

It turned out this wasn't at all related to any code I had in my actual document, but to a header definition I use in a package I've authored myself. If some fields where empty, some parts of the header ended up with two \\ following directly on each other. The first page had \maketitle on it, and thus didn't print out the header area, so the error didn't occur until LaTeX tried to create the second page - completely unrelated to what was in the document at the pagebreak.

Lessons learned:

  • When things go wrong at page breaks, don't only check the document itself - also check the header and footer definitions.

  • When authoring your own packages, make sure they don't make any unrealistic assumptions, such as "the document author will always want a subtitle"...