3

Having a strange problem using lineno.

The document I'm creating is a 24-page legal document. I'm numbering all the lines using lineno for easy reference. The line numbers need to be reset every page and it all works perfectly until page 17. From page 18 on, instead of line '1' being on the top of the page, it appears as the last line of the previous page.

The only relevant code I can see are both in the preamble:

\usepackage{lineno}
....
....
....
\pagewiselinenumbers
....
\begin{document}

Problem with this question is I understand it may be hard to answer. I'm hoping someone else has had similar problems that they found the solution to.

7
  • What document class are you using?
    – Alan Munn
    Commented Aug 9, 2011 at 21:54
  • 1
    Anything special about pages 17/18? Perhaps inclusion of a figure? A special environment that you used? (Re)Newcommands and the like? How about page 19? Does it start numbering properly with 1 again? Remember, for \pagewiselinenumbers to work, you have to compile the document at least twice.
    – Werner
    Commented Aug 9, 2011 at 22:24
  • In addition to @Werner's good suggestions, is there a section heading right at the end of p. 17? If you add a few lines more of text at page 17 does the problem still arise?
    – Alan Munn
    Commented Aug 9, 2011 at 22:48
  • @Alan I'm using article. Werner There is no new environment on either of those pages. The only time I introduce a new environment is on page 23 where I introduce an enumerate environment. From 18-24, all the lines begin on number 2, with 1 acting as the final line of the previous page. NOW, Alan, that is exactly it. It began a new section (I use a command I call \xsection) right at the bottom of page 17. Adding some dummy text there completely fixed the problem. Do you know why it does this?
    – Robert Ray
    Commented Aug 9, 2011 at 23:32
  • Well I can't reproduce the problem, but it seemed like a reasonable guess. And I suspect the system can never be foolproof, so I think the best you can do is rework your text a little to fix the bad break. (Or issue a \clearpage right before this particular \xsection so that it begins on the next page.)
    – Alan Munn
    Commented Aug 10, 2011 at 0:05

2 Answers 2

6

The lineno package does a remarkable job of adding numbers to the text, but there are various ways in which it might get it wrong, not through any real deficiency in the package, but just due to the complexities of how pages are built in TeX.

The pagewise numbering scheme requires the package to write the line numbers first to an .aux file, which it then reads back on a second run to generate the per-page numbers.

I was unable to replicate the behaviour in your document, but I suspect that the likely cause is a section break at the very end of the page on which the numbering began to fail. This kind of problem is solved in the same way that a typical bad page break problem is solved.

  • rewrite the text so that the section appears earlier in the page or moves to the next page
  • insert a manual \clearpage to force the section onto the next page

This second option should obviously only be done at the last stages of writing the document.

0

Please give \newpage or \clearpage at the end of the previous page, hope this may help you to fix...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .