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

Post by rotis »

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)??

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Ledurt
Posts: 12
Joined: Tue Mar 27, 2007 7:05 pm

Re: lineno package

Post by Ledurt »

Try to add the "displaymath" option to the lineno package.
rotis
Posts: 3
Joined: Sat Mar 24, 2007 2:19 pm

Re: lineno package

Post by rotis »

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

lineno package

Post by Ledurt »

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

Re: lineno package

Post by pvthuan »

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

Re: lineno package

Post by rotis »

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

Re: lineno package

Post by lubejob »

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

lineno package

Post by Ted »

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):

Code: Select all

\newcommand*\patchAmsMathEnvironmentForLineno[1]{%
  \expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
  \expandafter\let\csname oldend#1\expandafter\endcsname\csname end#1\endcsname
  \renewenvironment{#1}%
     {\linenomath\csname old#1\endcsname}%
     {\csname oldend#1\endcsname\endlinenomath}}% 
\newcommand*\patchBothAmsMathEnvironmentsForLineno[1]{%
  \patchAmsMathEnvironmentForLineno{#1}%
  \patchAmsMathEnvironmentForLineno{#1*}}%
\AtBeginDocument{%
\patchBothAmsMathEnvironmentsForLineno{equation}%
\patchBothAmsMathEnvironmentsForLineno{align}%
\patchBothAmsMathEnvironmentsForLineno{flalign}%
\patchBothAmsMathEnvironmentsForLineno{alignat}%
\patchBothAmsMathEnvironmentsForLineno{gather}%
\patchBothAmsMathEnvironmentsForLineno{multline}%
}
If there are other environments that you use that also need patching, add a

Code: Select all

\patchAmsMathEnvironmentForLineno{environment_name}
before that closing brace. If you want to hit both environment_name and environment_name*, use

Code: Select all

\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

Re: lineno package

Post by lubejob »

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

lineno package

Post by Ted »

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]
Post Reply