LaTeX forum ⇒ Document Classeslineno package

Information and discussion about specific document classes and how to create your own document classes.
rotis
Posts: 3
Joined: Sat Mar 24, 2007 2:19 pm

lineno package

Postby rotis » Sat Mar 24, 2007 2:32 pm

Hi. I'm a true beginner in Latex, and I have a problem:

I'm trying to use the lineno-package to numerate the lines in my manuscript.
It does not work properly: The first 70 lines got a number, but after that it seems to me to be only random lines that get number. This problem only occurs in a part with a lot of equations.

Any hint how to solve the problem (I’m using WinEdt, and writing in an elsart-environment)??

Ledurt
Posts: 12
Joined: Tue Mar 27, 2007 7:05 pm

Postby Ledurt » Tue Mar 27, 2007 10:50 pm

Try to add the "displaymath" option to the lineno package.

rotis
Posts: 3
Joined: Sat Mar 24, 2007 2:19 pm

Postby rotis » Wed Mar 28, 2007 8:38 am

no, that did not help. Actually, it made things worse. A lot of the text with formulas was removed in the tranformation to PDF.

Ledurt
Posts: 12
Joined: Tue Mar 27, 2007 7:05 pm

Postby Ledurt » Wed Mar 28, 2007 4:56 pm


pvthuan
Posts: 1
Joined: Wed Dec 05, 2007 5:30 pm

Postby pvthuan » Wed Jan 23, 2008 7:29 pm

I have the same problem. I have tried several options of the package but the number is not continuous. The line with equation is not counted.

What should I do?

rotis
Posts: 3
Joined: Sat Mar 24, 2007 2:19 pm

Postby rotis » Thu Jan 24, 2008 9:28 am

I might have solved the problem. I use the \begin{linenomath} and \end{linenomath} before and after the equation commando. it did the work for me.
rotis

lubejob
Posts: 2
Joined: Thu Jul 31, 2008 2:56 am

Postby lubejob » Thu Jul 31, 2008 3:05 am

I'm trying to add line numbers to a document and have tried the previous suggestions. When I use \linenumbers prior to \begin{document}, it will print line numbers but randomly skip lines and paragraphs. At least I think it is random.

I have tried \begin{linenumbers} ... \end{linenumbers} within the document, but then I get the error, "missing \begin{document} ". At this point, even "undoing", i.e. ^Z to get my original document back will erase this error. Any other suggestions? Thanks for any help.

Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

Postby Ted » Thu Jul 31, 2008 6:00 am

rotis wrote:This problem only occurs in a part with a lot of equations.
Maybe this will help... (though it might be a solution to a different lineno problem) Take a look at the fix at:


To make a long story short(er), lineno is not very compatible with popular amsmath environments. So you need to patch them all to get them to automatically play nice with lineno. I tried to make this simple with the following (insert in your preamble):
  1. \newcommand*\patchAmsMathEnvironmentForLineno[1]{%
  2. \expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
  3. \expandafter\let\csname oldend#1\expandafter\endcsname\csname end#1\endcsname
  4. \renewenvironment{#1}%
  5. {\linenomath\csname old#1\endcsname}%
  6. {\csname oldend#1\endcsname\endlinenomath}}%
  7. \newcommand*\patchBothAmsMathEnvironmentsForLineno[1]{%
  8. \patchAmsMathEnvironmentForLineno{#1}%
  9. \patchAmsMathEnvironmentForLineno{#1*}}%
  10. \AtBeginDocument{%
  11. \patchBothAmsMathEnvironmentsForLineno{equation}%
  12. \patchBothAmsMathEnvironmentsForLineno{align}%
  13. \patchBothAmsMathEnvironmentsForLineno{flalign}%
  14. \patchBothAmsMathEnvironmentsForLineno{alignat}%
  15. \patchBothAmsMathEnvironmentsForLineno{gather}%
  16. \patchBothAmsMathEnvironmentsForLineno{multline}%
  17. }
If there are other environments that you use that also need patching, add a
  1. \patchAmsMathEnvironmentForLineno{environment_name}
before that closing brace. If you want to hit both environment_name and environment_name*, use
  1. \patchBothAmsMathEnvironmentsForLineno{environment_name}
instead.

It's not perfect, but IIRC, it's a big improvement.
-- Ted [home/blog]

lubejob
Posts: 2
Joined: Thu Jul 31, 2008 2:56 am

Postby lubejob » Thu Jul 31, 2008 5:18 pm

Thanks! That did the trick - though I had to rename my file - otherwise I kept getting a "missing \begin{document}" error.

Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

Postby Ted » Thu Jul 31, 2008 5:41 pm

lubejob wrote:Thanks! That did the trick - though I had to rename my file - otherwise I kept getting a "missing \begin{document}" error.
I don't quite understand the file renaming thing.

You may notice that some math environments receive two numbers. I haven't figured out a good way to solve that problem. In fact, I'm not quite sure it's possible while using lineno. It's a tradeoff. At least the line numbers in the rest of the text are still there.
-- Ted [home/blog]


Return to “Document Classes”

Who is online

Users browsing this forum: No registered users and 8 guests