1  lineno.sty

2 Users Manual

3 Stephan I. Böttcher

4 Version 3.0, 1999/06/11

1 Contents

2  1 When to use lineno.sty  1
3  2 Where to get lineno.sty  1
4  3 How to use lineno.sty  2

5 3.1 Package options . . . . . . . . . . . . . . . . . . . . . . . . . . 2 6 3.2 How to turn on line numbering . . . . . . . . . . . . . . . . . 2 7 3.3 How to turn off line numbering . . . . . . . . . . . . . . . . . 3

8  4 Numbering modes  4

9 4.1 Running line numbers . . . . . . . . . . . . . . . . . . . . . . 4 10 4.1.1 Reseting or setting the line number . . . . . . . . . . . 5 11 4.2 Pagewise line numbers . . . . . . . . . . . . . . . . . . . . . . 6 12 4.2.1 Margin switching . . . . . . . . . . . . . . . . . . . . . 6 13 4.2.2 Running mode with margin switching . . . . . . . . . . 7 14 4.2.3 Page numbers . . . . . . . . . . . . . . . . . . . . . . . 7 15 4.3 Margin selection . . . . . . . . . . . . . . . . . . . . . . . . . . 7 16 4.4 Summary of mode selection commands . . . . . . . . . . . . . 8 17 4.5 Summary of margin selection commands . . . . . . . . . . . . 8 18 4.6 Numbering only one in five lines . . . . . . . . . . . . . . . . . 9 19 4.7 How the line numbers look like . . . . . . . . . . . . . . . . . 9 20 4.7.1 Deeper customization . . . . . . . . . . . . . . . . . . . 10

21  5 Line number references  12
22  6 Known incompatibilities  13

23 6.1 wrapfig.sty . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

24  7 Extension packages  13

25 7.1 Display math, mlineno . . . . . . . . . . . . . . . . . . . . . 13 26 7.2 rlineno . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 27 7.3 numquote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 28 7.4 ilineno . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 29 7.5 itemrule.sty . . . . . . . . . . . . . . . . . . . . . . . . . . 17 30 7.6 bframe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

31  8 How to print the documented source  18

1 1 When to use lineno.sty

2 The primary use of lineno.sty is to get line numbers in your LaTeX doc-3 ument. lineno.sty directly supports line numbers in various modes, and if 4 you have any wishes that are not directly supported, chances are good that 5 lineno.sty can be adapted to do it. And if it turns out to be difficult with 6 lineno.sty, then it will be even more difficult without. 7 There is one class of cases however, where lineno.sty is not the most 8 appropriate tool. When your text already comes in lines, like source listings, 9 tables, poetry, then lineno.sty will propably do the job, but other tools 10 could do it much more efficiently. 11 lineno.sty can only number lines in the main text. Lines in any kind 12 of boxes cannot be numbered. But see section 7.4 below. 13 lineno.sty is especially useful when the text is broken into lines by TEX 14 itself. In this case, the task to attach line numbers is not easy, and a tool 15 like lineno.sty has good chances to break when used together with other 16 packages. 17 On the other hand, lineno.sty proved to be quite stable, and I did not 18 get any reports of complete failure yet. 19 With lineno.sty, you can refer to the line numbers via L^{A}TEXs \ref and 20 \pageref macros. 21 There are other applications, not directly related to line numbering. 22 Whenever you want to attach something to your text, after a paragraph 23 was broken into lines, across pagebreaks, lineno may do the job.

Say, you need a frame around some text, but the text should be able to break across pages, lineno.sty can be used to draw rules on both margins, which can be completed at the top and bottom by some special environment, see section 7.6.

24 There may be cases, where other packages do a better job, e.g., CTAN:

25  macros/latex/contrib/supported/numline.

26 2 Where to get lineno.sty

27 lineno.sty is available on the Comprehensive TeX Archive Network (CTAN),

28  e.g, ftp://ftp.tex.ac.uk/tex-archive/macros/latex/contrib/supported/
29  lineno/lineno.sty.
30  The home of lineno.sty is http://www.nevis.columbia.edu/~stephan/

31 tex/#lineno. Here you can get the latest version.

3 How to use lineno.sty

As any other L^{A}TEX 2ε package, you need to load it with

     \usepackage[⟨options⟩]{lineno}

3.1 Package options

The available ⟨options⟩ are: [left]: Put the line numbers into the left margin (default). [right]: Put the line numbers into the right margin. [switch]: Put the line numbers into the outer margin (left on even num-

bered pager, right on odd numbered pages). [switch*]: Put the line numbers into the inner margin. [pagewise]: Number the lines from 1 on each page. [running]: Continuously number the lines (default). [modulo]: Print line numbers only if they are multiples of five. [mathlines]: When using the {linenomath} environment for display math,

put line numbers also on the lines of the display. [displaymath]: Automatically wrap the standard LaTeX display math en-

vironments in {linenomath}.

Change from v2 to v3: [mathlines] was called [displaymath] before,

     and [displaymath] was \usepacke{mlineno}.

All effects of these option can also be obtained by calling certain macros later in the document, except for [displaymath].

3.2 How to turn on line numbering

The line numbering is not activated by default. If you want line numbers, you have to turn it on. The simplest way is to say

     \linenumbers

This will turn on line numbers within the current group, according to the currently selected mode. If you do it right at the beginning, the whole document will be numbered.

\linenumbers takes effect only when a paragraph is finished. This is important if you use \linenumbers for a single paragraph only. This will not work:

     \begingroup
     \linenumbers

Text of your paragraph.

     \endgroup

because the \endgroup terminates the effect of \linenumbers before the paragraph is finished. The solution is to insert an empty line, or an explicit

\par before the \endgroup.

The prefered solution is to use an enviroment:

     \begin{linenumbers}

Text of your paragraph.

     \end{linenumbers}

\end{linenumbers} terminates the paragraph for you. It will also make sure that the next paragraph is not indented, if there is no empty line in between.

This form will not finish any preceeding paragraph. If you do not leave an empty line before \begin{linenumbers}, the previous paragraph may also get line numbers (this is not true after a list environment).

A quite esoteric form to number a single paragraph is:

Text of your paragraph.

     {\linenumbers\par}

Here, the \linenumbers is turned on in a group that just executes the \par to terminate the previous paragraph. Only this paragraph will have line numbers. (\par is exactly equivalent to an empty line).

3.3 How to turn off line numbering

You do not usualy turn of line numbering explicitly, but rather restrict line numbering to a group or an environment. However, you can turn it off with the command

     \nolinenumbers

This macro can also be used as an environment. The same restrictions apply

as for \linenumbers.

4 Numbering modes

Attaching line numbers after TEX has broken the paragraph into lines is already quite a difficult job for TEX. Why? Because TEX does not normally give you any control after line breaking. lineno.sty does it by pretending that the current page ends after each and every line. This keeps TEX quite busy, but works.

Often, you want the line numbers to depend on the page they finally end up. E.g., you want the numbers to start with 1 one each new page, or you want them to appear on the outer margins in twoside mode. This is an almost impossible demand, but lineno.sty can do it, at some cost, in terms of computing time, memory, and disk space. lineno.sty needs to write a note into the auxiliary file for each line in the numbered part of the text, and TEX keeps some memory for each page, and all that takes some computation time to figure out on which page the line was in the last L^{A}TEX run.

Thus, there are two basic numbering modes

1. Running line numbers. The numbers run continuously along the document, without considering page breaks.

The line numbers can be reset, or preset at any point in the document (except within a paragraph). Margin switching (or any other dependence on the page breaks) is not possible.

2. Pagewise line numbers. The lines on each page are numbered from one. Automatic margin switching is possible.

Running mode can be simulated in pagewise mode, to get automatic margin switching with continuous line numbers, but without the ability to reset/preset the line numbers anywhere in the document.

Any feature that depends on the page breaks must use this mode.

1 4.1 Running line numbers

2 This is the default mode of operation. The lines of your text are numbered 3 continuously across page breaks. 4 You cannot get automatic margin switching in this mode, because at the 5 time when the line numbers are attached, it is not yet decided on which page 6 the line will end up. However, you can simulate continuous line numbers in 7 pagewise mode (see below), where margin switching becomes possible. 8 You get this mode by

9 • not specifying any of the package options [switch,pagewise], 10 • specifying the package option [running], 11 • give the command \setrunninglinenumbers in the document, or 12 • turn on line numbering with \runninglinenumbers or

13  \begin{runninglinenumbers}.

14 4.1.1 Reseting or setting the line number 15 You can reset the line number with

16  \resetlinenumber[⟨number⟩]

17 where the default is to reset the line number to one. 18 Alternatively, you can give the line number in an optional argument to 19 any command that turns on the line numbering in this mode:

20  \linenumbers[⟨number⟩]
21  \runninglinenumbers[⟨number⟩]
22  \begin{linenumbers}[⟨number⟩]
23  \begin{runninglinenumbers}[⟨number⟩]

24 or reset the line number to 1 with any of the following:

25  \linenumbers*
26  \runninglinenumbers*
27  \begin{linenumbers*}
28  \begin{linenumbers}*
29  \begin{runninglinenumbers*}
30  \begin{runninglinenumbers}*

31 This section of the manual is enclosed in

32  \begin{runninglinenumbers*}
33  \end{runninglinenumbers*}

1 4.2 Pagewise line numbers

2 Basically, this mode prints line numbers starting with 1 on top of each page, 3 counting only lines where this mode is active. If you turn on this mode in 4 the middle of a page, the numbers start with 1 at that point. 5 The pagewise mode of operation is quite a bit more work for TEX. When 6 the line numbers are printed, TEX does not know on which page the current 7 line will go. To get pagewise mode working, L^{A}TEX has to remember on which 8 page the line went in a previous run. This information is written into the 9 .aux file, and like a table of contents, you will not see the numbers until 10 you run L^{A}TEX at least twice on the document. Sometimes the information 11 in the .aux file becomes invalid in a way that causes lineno.sty to hang. 12 In such a case you’ll have to delete all .aux files of the document to get it 13 going again. 14 You get this mode by

15 • specifying the package option [pagewise], but not [running],

16 • give the command \setpagewiselinenumbers in the document, or

17 • turn on line numbering with \pagewiselinenumbers or

18  \begin{pagewiselinenumbers}.

19 You cannot reset or preset the line numbers in pagewise mode. This 20 mode uses a different counter than running mode. You can switch between 21 the mode, and the running numbers will continue where they left of, unless 22 you reset the counter.

23 4.2.1 Margin switching

24 As a side effect of all the business to find out on which page the lines end 25 up, margin switching becomes possible. It is now possible to print the line 26 number differently on odd and even pages. The command

27  \switchlinenumbers

28 will cause the line numbers to be printed on the outer margins, on the right 29 side for odd pages, and on the left side for even numbered pages. If you add 30 a star, the numbers go on the inner margins

31  \switchlinenumbers*

32 You can achieve the same effect by specifying the package option [switch]

33 or [switch*] together with [pagewise].

34 Margin switching is independent of any [twoside] option of the docu-35 ment class.

1 4.2.2 Running mode with margin switching

2 Margin switching is not possible in running mode, but you can abuse the 3 pagewise mode to produce continuous line numbers. This mode is activated 4 with the command

 5  \runningpagewiselinenumbers

6 It is not possible to reset the line number counter for this mode, the lines 7 will be numbered starting from one at the beginning of the document, and 8 continue. You can switch back to real pagewise mode with

 9  \realpagewiselinenumbers

10 but when you resume running-pagewise, the numbers will not continue where 11 they left off, but jump by the number of lines that were numbered real-12 pagewise. 13 The package options [switch] and [switch*] will turn on running page-14 wise mode with margin switching, unless you also specify [pagewise]. 15 Finally, if you give these options together with [running], like

16  \usepackage[switch,pagewise,running]{lineno}

17 the mode is set to plain running line numbers, but later in your docu-18 ment, if you say \pagewiselinenumbers, the setings of the [switch] and 19 [pagewise] options will take effect.

20 4.2.3 Page numbers

21 Any pages that contain pagewise numbered lines must have a different page 22 number. This may cause trouble with titlepages or simmilar fudging with 23 the page number counter in the document. (I am talking about \c@page or

24 \count 0 here, not \thepage).

25 If you get strange errors, like “the use of \nextLN does not match its 26 definition”, you should first delete all .aux files, and rerun L^{A}TEX several 27 times. If the error does not reappear, fine, else check your page numbers, 28 including those that are not printed. You may use running line numbers on 29 your titlepages, since the page boundaries are predefined, usually.

1 4.3 Margin selection

2 In any mode you can select a fixed margin on which the numbers shall be 3 printed. You can either give a package option [left] or [right], or change 4 the margin within the document with

5  \leftlinenumbers
     \rightlinenumbers  6

Neither of these commands actually turns on line numbering. The margin 7 setting is changed for the currently selected mode running or pagewise. If 8 you want to set the margin for both modes, append a star 9

     \leftlinenumbers*  10
     \rightlinenumbers*  11
The default is \leftlinenumbers*.  12

4.4 Summary of mode selection commands

The following commands change the major line numbering mode.

\setrunninglinenumbers
\setpagewiselinenumbers

set the current mode, without activating or deactivating line numbering.

\runninglinenumbers*[⟨number ⟩]
\pagewiselinenumbers

set the current mode and activate line numbering, optionally reset (*), or set the line number for running mode.

The following commands do not change the major mode, but modify the the behaviour of pagewise mode

\realpagewiselinenumbers
\runningpagewiselinenumbers

select if pagewise mode should number continuously, or really pagewise.

4.5 Summary of margin selection commands

The following command select into which margin the numbers should be printed

\leftlinenumbers*
\rightlinenumbers*

put the line numbers in the left/right margin in both modes.

\leftlinenumbers

  \rightlinenumbers

put the line number into the left/right margin in the currently selected mode.

  \switchlinenumbers

put the line numbers into the outer margin, when using pagewise mode.

  \switchlinenumbers*

put the line numbers into the inner margin, when using pagewise mode.

4.6 Numbering only one in five lines

2 You can ask lineno to print the line numbers only if they devide by ⟨n⟩, by saying

4  \modulolinenumbers[⟨n⟩]

If you omit the optional argument, it will be every fifth line, or whatever you 6 used last (the current value of the counter linenumbermodulo). You get the

same effect by giving the package option [modulo]. 8 If you set ⟨n⟩ to 1, the modulo value is not changed, but modulo num-

bering is turned off. 10 Changing the counter linenumbermodulo does not turn on modulo num-

bering, it just changes the modulo, if it is turned on without the optional 12 argument.

This section of the manual is enclosed in

14  \begin{linenumbers*}
       \modulolinenumbers[2]
16  \end{linenumbers*}

1 4.7 How the line numbers look like

2 This section of the manual is enclosed in

3  \begin{pagewiselinenumbers}
4  \switchlinenumbers
5  \end{pagewiselinenumbers}

6 By default, the line numbers are set in

7  \normalfont\tiny\sffamily

right justified to 10 pt left of the nominal left edge of the text. If the number 1 is to appear on the right margin, it is right justified to 20 pt right of the 2 nominal right edge of the text. 3

You can easily change that, of course. The font is defined by the macro 4

     \linenumberfont  5

You can redefine it to make the numbers appear in a differnt font (with 6 \renewcommand). I’ll say right here in this manual 7

     \renewcommand\linenumberfont{\normalfont\bfseries\small}  8

The distance on the left margin can be changed with 9

     \setlength\linenumbersep{⟨distance⟩}  10

The distance on the right margin is \linenumbersep plus \linenumberwidth, 11 both are set to 10 pt by default. Let’s do right here 12

     \setlength\linenumbersep{1cm}  13

I put the command at the end of the paragraph, but it effects the whole 14 paragraph, because that is where everything happens: at the end of the 15 paragraphs. 16

The line numbers are printed as arabic numerals, as defined in the macro 17

     \thelinenumber  18

for the L^{A}TEX counter {linenumber}. You can redefine that, as for any other xix L^{A}TEX counter. E.g., xx

     \renewcommand\thelinenumber{\roman{linenumber}}  xxi

(For heavy duty line numbering, you should use L^{A}TEXs internal format, e.g., xxii

\@roman\c@linenumber.)  xxiii

4.7.1 Deeper customization xxiv The line number is attached to the line by the macro xxv

     \makeLineNumber  xxvi

which is expanded inside a zero width \hbox alligned to the origin of the → ←

current line (left edge, baselines alligned). You can do anything in this macro.

→ ← Let’s assume you do not want line numbers at all, but just attach something → ←

else to each line of text: this is the macro to modify. You can refer to the → ← line number by the macro \LineNumber, which prints the current value of the → ←

counter {linenumber}, or nothing if modulo mode is active, and the number → ←

does not divide by {linenumbermodulo}. You should not modify this macro → ←

when using any form of pagewise mode. At the end of this paragraph I put → ←

the following → ←

i  \begin{runninglinenumbers}
ii  \renewcommand\makeLineNumber
iii  {\hss$\rightarrow$\ \rlap{\hskip\textwidth\ $\leftarrow$}}
iv  \end{runninglinenumbers}

v Redefining \makeLineNumber cuts deep into the linenumber mode setting. vi If you still want to use the basic modes running and pagewise you should vii go one level up and modify one of the following macros, which are called by viii (or assigned to) \makeLineNumber depending on the current mode, and with ix the counter {linenumber} allready adjusted for the current page when using x pagewise mode.

xi  \makeLineNumberRunning
xii  \makeLineNumberOdd
xiii  \makeLineNumberEven

xiv The first is used in running mode, the other two in pagewise mode. If you xv modify those, you cut into the margin selection mechanism as advertised xvi above. You will have to call a mode selection command after changing these xvii macros, to make them take effect (at least for \makeLineNumberRunning). xviii You can go up one more step. The margin selection commands redefine xix the above macros by making them equivalent (\let) to one of the following xx macros

xxi  \makeLineNumberLeft
xxii  \makeLineNumberRight

xxiii You may redefine these, and afterwards issue a margin selection command xxiv followed by a mode selection command. The default definitions are

xxv  \def\makeLineNumberLeft
xxvi  {\hss\linenumberfont\LineNumber\hskip\linenumbersep}

xxvii and

xxviii  \def\makeLineNumberRight
xxix  {\linenumberfont\hskip\linenumbersep\hskip\textwidth
xxx  \hbox to\linenumberwidth{\hss\LineNumber}\hss}

Whatever you do, use \LineNumber to print the digits. This ensures that i) the modulo mode setting is acknowledged. If you want to customize that as well, this is the macro to change. \LineNumber eventually refers to iii) \thelinenumber, which is the place to customize the numerals themselves. At the end of this paragraph I said v)

       \renewcommand\LineNumber
          {\ifodd\value{linenumber} \thelinenumber)\fi}  vii)

Line number references are not affected by \LineNumber, but you should keep track of \thelinenumber. Look at the following reference ix)

The setion title of the next section is on page 12, line xiii.

There is a mismatch in the definition of \thelinenumber, from the point of xi) the refered line to the reference here.

13 5 Line number references

14 lineno.sty allows to refer to a line number with \ref{⟨label⟩}. The label is 15 set by \linelabel{⟨label⟩}, anywhere in a paragraph that gets line numbers. 16 If you put a \linelabel somewhere else, the line number it refers to is pretty 17 meaningless, but no error message is issued. (This section begins on line 13, 18 page 12 and ends on line 16, page 13.) 19 References work both in running and pagewise modes. However, you 20 have to be very careful when using both real pagewise mode and running 21 pagewise mode: The mode setting must be the same during reference as 22 during labeling. 23 The restrictions on placing a \linelabel are the same as for a \marginpar. 24 (In fact, they are implemented as fake \marginpars.) E.g., the linelabel on 25 the section header of this chapter could not be placed in the straight forward 26 way, because it would cause an error in the table of contents. (It should be 27 disabled during toc processing.) Instead, I typed

28  \section[Line number references]
29  {Line number references\linelabel{ll1}}

30 This works fine, with the standard L^{A}TEX {article} document style. If more 31 generic markup is required, you should avoid things like this (you should 32 avoid lineno.sty altogether, in that case). 33 \linelabel does not work in display math. (Why, you do not use equa-34 tion numbers?)

1 The \linelabel command starts a new paragraph if it is issued after an 2 empty line. It will properly ignore further whitespace before the first word 3 of text. Thus you can easily get a label to the first line of a paragraph. 4 Furthermore, \linelabel uses L^{A}TEXs standart tricks to avoid unneces-5 sary spaces if you place is between two words with spaces around, but you 6 should not do that anyway, if you want to make sure that the label applies 7 to a certain word in the text. You should attach the line label to the word in 8 question without intervening spaces, either before of after the word. If you 9 leave spaces both before and after the \linelabel command, the current 10 implemenation attaches the line label to the following word (by ignoring the 11 trailing space). 12 Special care should be taken at the end of a paragraph. You better put 13 the line label without intervening spaces behind the period, like this

14  This is the end of this section.%
15  \linelabel{ll2}

16 This is the end of this section.

1 6 Known incompatibilities

2 This section will expand whenever somebody discovers problems when using 3 lineno.sty together with other L^{A}TEX packages.

4 6.1 wrapfig.sty

5 lineno.sty used to have problems with wrapfig.sty, but this is solved but 6 lineno.sty, version 2.05.

7 7 Extension packages

8 The extension packages were abolished with version v3.00 of lineno.sty. 9 One package, itemrule.sty, was dropped, the others were put directly into 10 the the main lineno.sty package file.

11 7.1 Display math, mlineno

12 lineno.sty does not work well with display math. The parts of a paragraph 13 preceeding a display math will not get line numbers. The reason is that the 14 paragraph is not finished, but the part above the display is broken into lines 15 anyway.

Let me demonstrate the effect. This paragraph contains a {displaymath} environment. The part before the Formula does not get line numbers. Here comes the Formula

6 H_{2}O + 6 CO_{2} → C_{6}H_{12}O_{6} + 6 O_{2}

16 which makes the line numbers disappear. The trailing part of the paragraph 17 does get line numbers. 18 There are several means to solve the problem, but none of them is fully 19 satisfactory. lineno.sty defines a {linenomath} environment, which can 20 be wrapped around a display math to make the line numbering work. This 21 will work with any kind of display math, even if you use explicit $$ pairs. 22 There is a *-form {linenomath*} which also numbers the lines of the display 23 itself, as good as it can. Here comes an example use of {linenomath*}

b_{1} = a_{11}x_{1} + a_{12}x_{2} 24
b_{2} = a_{21}x_{1} + a_{22}x_{2} 25

26 wrapping an {egnarray*} like this

27  \begin{linenomath*}
28  \begin{eqnarray*}
29  b_1 &=& a_{11}x_1 + a_{12}x_2 \\
30  b_2 &=& a_{21}x_1 + a_{22}x_2
31  \end{eqnarray*}
32  \end{linenomath*}

33 Specifying the package option [mathlines], causes the {linenomath} en-34 vironment to switch its function with its *-form. This allows you to later 35 decide if you want the numbers on the formulas or not, without putting in 36 stars everywhere (as long as you have been consistent). 37 The {linenomath} wrapper does nothing if line numbering is not ac-38 tivated. You do not need to remove them if you decide to omit the line 39 numbering later (although you still have to load lineno.sty ). 40 The mlineno extension redefines the standard L^{A}TEX display math envi-41 ronments to wrap themselves automatically into {linenomath}:

42  {displaymath}
43  {equation}
44  {eqnarray}
45  {eqnarray*}

46 As of version 3.00 you can activate this by the package option [displaymath]. 47 You can keep existing explicit {linenomath} wrappers without harm. 48 This will probably not work with AMSmath. 49 Other solutions to make lineno.sty work with display math are either 50 ugly or less stable. The ugly possibility is to precede every display math with 51 an empty line, or better with

52  {\par\nobreak\noindent}

53 but this gains you nothing compared to using the {linenomath} environ-54 ment, since you still have to modify your document.

  7.2 rlineno

55 It is currently not possible to put a \linelabel into math mode. This should 56 not impose problems with inline math, since you can attach the label just 57 outside the math shift, like

58  ... \linelabel{⟨label⟩}$x=f(y)$ ...

59 but to refer to a line in display math, you cannot label it directly. 1 The extension rlineno offers a solution, allowing to refer to a line number 2 with an offset. 3 This extension is now available with plain lineno.sty v3.00. 4 You put the \linelabel at the end of the preceeding line, and refer to 5 that number, plus 1 or, in case of multiline displays, by any other offset.

 6  ...\linelabel{⟨label⟩}
 7  \begin{equation}
 8  y=f'(x)
 9  \end{equation}
10  ... the formula in line \lineref[+1]{⟨label⟩}

11 The offset calculation is different for pagewise or running line numbers, and 12 you will have to make sure the right method is used.

The macro \lineref[⟨offset⟩]{⟨label⟩} uses the method of the currently selected mode (line numbering need not be activated). To specify the mode explicitly, use \linerefr or \linerefp for running or pagewise mode respectively.

For example, the manual sets a \linelabel{rll1} at the end of the line preceeding the single line quote environment at line 58 in the first paragraph of this chapter, and refered to it via

       \linerefr[+1]{rll1}

and another one preceeding the quote environment in the second paragraph of this chapter, with the central line numbered 8, which I just refered to via

     \linerefp[+3]{rll2}

60 If the correct mode is selected (e.g., \setrunninglinenumbers), you can use

61 \lineref[+1]{rll1} to refer to line 58.
7.3 numquote

This extension defines two environments, each of them with a *-form or alternatively an optional argument.

     \begin{numquote}
     \end{numquote}
is like {quote},
     \begin{numquotation}
     \end{numquotation}

is like {quotation}, but with the lines numbered. Numbering restarts with 1 each time it is used, except you use the *-form, or specify the line number to start with in an optional argument.

1 The line numbers set to the left of the text, indented by the same 2 amount as the quote or quotation. This works as expected even 3 if the quote appears in a nested list.

To customize the distance from the text or the shape of the numbers, you

can modify the macros \quotelinenumbersep and \quotelinenumberfont

respectively.

As of version 3.00, this is available directly with lineno.sty.

7.4 ilineno

Sometimes you need line numbers within a \parbox or figure. This extension can do that, if the text is simple enough. It works by drawing a ladder of numbers next to the paragraph, each number vertically separated by \baselineskip from the other. This obviously dose not work nicely with anything but

straight text. Extra high lines (like this: x = \frac{A}{B}) will disturb the alignment. The power of lineno.sty is not necessary to achieve this, but you may need both in one document with a somewhat coherent interface, and some of the necessary infrastructure from lineno.sty is actually useful.

13 14 15 16 17 18 19 20 21 22

The preceding paragraph was set like this:

\begin{center}\fbox{\parbox{0.8\textwidth}{
\internallinenumbers
\resetlinenumber[13]

Sometimes you need …

}}\end{center}
7.5 itemrule.sty

Somebody asked me if he can get a rule next to an itemized item, from the bullet downwards. This style did that. It was unstable and of little interest, so it is gone from the lineno.sty distribution.

7.6 bframe

lineno.sty can be used for unexpected purposes. The environment

\begin{bframe}
\end{bframe}

draws boxes around some text, even across page breaks. At a page break, the box is open (it is difficult to fix that). There are two parameters:

\bframesep

defines the separation of the box from the text.

\bframerule

defines the thickness of the lines around the text.

It works by asking lineno.sty to draw small rules left and right to the lines. The total height of the rules is \baselineskip plus \bframesep. This leaves some extra space for extra high lines.

The current version is very preliminary. In a future version there may be a possibility to move the vertical lines inwards for indented text. The box may optionally be closed at page breaks. It will not likely be possible to have a colored background in the box, at least not with a graphics driver that cannot put a background behind existing foreground (Postscript cannot, I’ve been told). Tell me how to make a gray background, like block dots on transparent, and I can do shaded boxes.

8 How to print the documented source

lineno.sty is written in three programming languages: TEX, sh, and awk.

The file can be loaded as a L^{A}TEX 2ε package as it is. However, if you feed it into a Unix shell, like

     csh>  source ./lineno.sty

it will produce the files lineno.tex and lineno.dvi, which is the documented source of lineno.sty. If you want to learn how it works, or you need to adapt lineno.sty for some special requirements, you should read that document.