Annotation of ttbar/p20_taujets_note/ulineno.tex, revision 1.1.1.1

1.1       uid12904    1: % Copyright 1995--1999 Stephan I. B"ottcher <stephan@nevis1.columbia.edu>
                      2: %
                      3: % This program can be redistributed and/or modified under the terms
                      4: % of the LaTeX Project Public License Distributed from CTAN
                      5: % archives in directory macros/latex/base/lppl.txt; either
                      6: % version 1 of the License, or any later version.
                      7: %
                      8: % $Id: ulineno.tex,v 3.1 2001/08/03 03:29:19 stephan Exp $
                      9: %
                     10: % 1999-06-11 SiB: updated for lineno.sty v3.00
                     11: 
                     12: \documentclass[12pt,a4paper,titlepage]{article}
                     13: 
                     14:                                               \date{\def\$##1: ##2 ##3${##2}%$
                     15:                                                                       Version 
                     16:    \$Revision: 3.1 $, 
                     17:    \$Date: 2001/08/03 03:29:19 $
                     18:                                                                              }
                     19:                                  \def\lineno.sty{\texttt{\itshape lineno.sty}}
                     20: 
                     21: 
                     22: \title{           \lineno.sty
                     23: \\                Users Manual
                     24: }
                     25: \author{      Stephan I. B\"ottcher
                     26: }
                     27: 
                     28: \usepackage{lineno}
                     29: \usepackage{url}
                     30: 
                     31: \def~{\verb~}
                     32: \catcode`\<\catcode`\~
                     33: \def<#1>{$\langle${\itshape#1}\/$\rangle$}
                     34: \catcode`\|\catcode`\~
                     35: \def|#1{{\ttfamily\string#1}}
                     36: \def\NL{<number>]}
                     37: 
                     38: \begin{document}
                     39: \begin{runninglinenumbers}
                     40: \renewcommand\linenumberfont{\normalfont\small\bfseries}
                     41: \setlength\linenumbersep{1cm}
                     42: \maketitle
                     43: \thispagestyle{empty}
                     44: \resetlinenumber
                     45: \tableofcontents
                     46: \clearpage
                     47: \setcounter{page}{1}
                     48: \pagewiselinenumbers
                     49: 
                     50: \section{When to use \lineno.sty}
                     51: 
                     52: The primary use of \lineno.sty is to get line numbers in your LaTeX
                     53: document.  \lineno.sty directly supports line numbers in various
                     54: modes, and if you have any wishes that are not directly supported,
                     55: chances are good that \lineno.sty can be adapted to do it.  And if it
                     56: turns out to be difficult with \lineno.sty, then it will be even more
                     57: difficult without.
                     58: 
                     59: There is one class of cases however, where \lineno.sty is not the most
                     60: appropriate tool.  When your text already comes in lines, like source
                     61: listings, tables, poetry,  then \lineno.sty will propably do the job,
                     62: but other tools could do it much more efficiently.
                     63: 
                     64: \lineno.sty can only number lines in the main text.  Lines in any kind
                     65: of boxes cannot be numbered.  But see section \ref{sec:ilineno} below.
                     66: 
                     67: \lineno.sty is especially useful when the text is broken into lines by
                     68: \TeX\ itself.  In this case, the task to attach line numbers is not
                     69: easy, and a tool like \lineno.sty has good chances to break when used
                     70: together with other packages.
                     71: 
                     72: On the other hand, \lineno.sty proved to be quite stable, and I did
                     73: not get any reports of complete failure yet.
                     74: 
                     75: With \lineno.sty, you can refer to the line numbers via \LaTeX s
                     76: ~\ref~ and ~\pageref~ macros.
                     77: 
                     78: There are other applications, not directly related to line numbering.
                     79: Whenever you want to attach something to your text, after a paragraph
                     80: was broken into lines, across pagebreaks, lineno may do the job.
                     81: 
                     82: \begin{bframe}
                     83:   Say, you need a frame around some text, but the text should be able
                     84:   to break across pages, \lineno.sty can be used to draw rules on both
                     85:   margins, which can be completed at the top and bottom by some
                     86:   special environment, see section\,\,\ref{sec:bframe}.
                     87: \end{bframe}
                     88: 
                     89: There may be cases, where other packages do a better job, e.g.,
                     90: \url{CTAN:macros/latex/contrib/supported/numline}.
                     91: 
                     92: 
                     93: \section{Where to get \lineno.sty}
                     94: 
                     95: \lineno.sty is available on the \emph{Comprehensive TeX Archive
                     96:   Network} (CTAN), e.g, \url{ftp:// ftp.tex.ac.uk/ tex-archive/
                     97:   macros/ latex/ contrib/ supported/ lineno/ lineno.sty}.
                     98: 
                     99: The home of \lineno.sty is \url{http:// www.nevis.columbia.edu/
                    100:   ~stephan/ tex/ #lineno}.  Here you can get the latest version.
                    101: 
                    102: \end{runninglinenumbers}
                    103: 
                    104: \section{How to use \lineno.sty}
                    105: 
                    106: As any other \LaTeXe\ package, you need to load it with
                    107: \begin{quote}
                    108:    ~\usepackage[~<options>~]{lineno}~
                    109: \end{quote}
                    110: 
                    111: \subsection{Package options}
                    112: 
                    113: The available <options> are:
                    114: \begin{description}
                    115: 
                    116: \item[\texttt{[left]}:]  Put the line numbers into the left margin
                    117:   (default). 
                    118: 
                    119: \item[\texttt{[right]}:]  Put the line numbers into the right margin.
                    120: 
                    121: \item[\texttt{[switch]}:]  Put the line numbers into the outer margin
                    122:   (left on even numbered pager, right on odd numbered pages).
                    123: 
                    124: \item[\texttt{[switch*]}:]  Put the line numbers into the inner
                    125:   margin.
                    126:   
                    127: \item[\texttt{[pagewise]}:] Number the lines from 1 on each page.
                    128: 
                    129: \item[\texttt{[running]}:]  Continuously number the lines (default).
                    130:   
                    131: \item[\texttt{[modulo]}:] Print line numbers only if they are
                    132:   multiples of five.
                    133: 
                    134: \item[\texttt{[mathlines]}:]  When using the ~{linenomath}~
                    135:   environment for display math, put line numbers also on the lines of
                    136:   the display.
                    137: 
                    138: \item[\texttt{[displaymath]}:]  Automatically wrap the standard LaTeX
                    139:   display math environments in ~{linenomath}~.
                    140: 
                    141:   \begin{itshape}
                    142:     Change from v2 to v3:  ~[mathlines]~ was called ~[displaymath]~
                    143:     before, and ~[displaymath]~ was ~\usepacke{mlineno}~.
                    144:   \end{itshape}
                    145:   
                    146: \end{description}
                    147: All effects of these option can also be obtained by calling certain
                    148: macros later in the document, except for ~[displaymath]~.
                    149: 
                    150: \subsection{How to turn on line numbering}
                    151: 
                    152: The line numbering is not activated by default.  If you want line
                    153: numbers, you have to turn it on.  The simplest way is to say
                    154: \begin{quote}
                    155:     ~\linenumbers~
                    156: \end{quote}
                    157: This will turn on line numbers within the current group, according to
                    158: the currently selected mode.  If you do it right at the beginning, the
                    159: whole document will be numbered.
                    160: 
                    161: ~\linenumbers~ takes effect only when a paragraph is finished.  This
                    162: is important if you use ~\linenumbers~ for a single paragraph only.
                    163: This will \emph{not} work:
                    164: \begin{quote}\obeylines
                    165:    ~\begingroup~\\%
                    166:    ~\linenumbers~
                    167:      Text of your paragraph.
                    168:    ~\endgroup~
                    169: \end{quote}
                    170: because the ~\endgroup~ terminates the effect of ~\linenumbers~ before
                    171: the paragraph is finished.  The solution is to insert an empty line,
                    172: or an explicit ~\par~ before the ~\endgroup~.
                    173: 
                    174: The prefered solution is to use an enviroment:
                    175: \begin{quote}\obeylines
                    176:    ~\begin{linenumbers}~ 
                    177:      Text of your paragraph. 
                    178:    ~\end{linenumbers}~
                    179: \end{quote}
                    180: ~\end{linenumbers}~ terminates the paragraph for you.  It will also
                    181: make sure that the next paragraph is not indented, if there is no
                    182: empty line in between.
                    183: 
                    184: This form will not finish any preceeding paragraph.  If you do not
                    185: leave an empty line before ~\begin{linenumbers}~, the previous
                    186:   paragraph may also get line numbers (this is not true after a list
                    187:   environment).
                    188: 
                    189: A quite esoteric form to number a single paragraph is:
                    190: \begin{quote}\obeylines
                    191:      Text of your paragraph.
                    192:      ~{\linenumbers\par}~
                    193: \end{quote}
                    194: Here, the ~\linenumbers~ is turned on in a group that just executes
                    195: the ~\par~ to terminate the previous paragraph.  Only this paragraph
                    196: will have line numbers. (~\par~ is exactly equivalent to an empty
                    197: line).
                    198: 
                    199: 
                    200: \subsection{How to turn off line numbering}
                    201: 
                    202: You do not usualy turn of line numbering explicitly, but rather
                    203: restrict line numbering to a group or an environment.  However, you
                    204: can turn it off with the command
                    205: \begin{quote}
                    206:    ~\nolinenumbers~
                    207: \end{quote}
                    208: This macro can also be used as an environment.  The same restrictions
                    209: apply as for ~\linenumbers~.
                    210: 
                    211: 
                    212: \section{Numbering modes}
                    213: 
                    214: Attaching line numbers after \TeX\ has broken the paragraph into lines
                    215: is already quite a difficult job for \TeX.  Why?  Because \TeX\ does
                    216: not normally give you any control after line breaking.  \lineno.sty
                    217: does it by pretending that the current page ends after each and every
                    218: line.  This keeps \TeX\ quite busy, but works.
                    219: 
                    220: Often, you want the line numbers to depend on the page they finally end
                    221: up.  E.g., you want the numbers to start with~ ~1 one each new page,
                    222: or you want them to appear on the outer margins in twoside mode.  This
                    223: is an almost impossible demand, but \lineno.sty can do it, at some
                    224: cost, in terms of computing time, memory, and disk space.  \lineno.sty
                    225: needs to write a note into the auxiliary file for each line in the
                    226: numbered part of the text, and \TeX\ keeps some memory for each page,
                    227: and all that takes some computation time to figure out on which page
                    228: the line was in the last \LaTeX\ run.
                    229: 
                    230: Thus, there are two basic numbering modes
                    231: \begin{enumerate}
                    232:   
                    233: \item \emph{Running} line numbers.  The numbers run continuously along
                    234:   the document, without considering page breaks.  
                    235:   
                    236:   The line numbers can be reset, or preset at any point in the
                    237:   document (except within a paragraph).  Margin switching (or any
                    238:   other dependence on the page breaks) is not possible.
                    239:   
                    240: \item \emph{Pagewise} line numbers.  The lines on each page are
                    241:   numbered from one.  Automatic margin switching is possible.
                    242: 
                    243:   \emph{Running} mode can be simulated in pagewise mode, to get
                    244:   automatic margin switching with continuous line numbers, but without
                    245:   the ability to reset/preset the line numbers anywhere in the
                    246:   document.  
                    247:   
                    248:   Any feature that depends on the page breaks must use this mode.
                    249: 
                    250: \end{enumerate}
                    251: 
                    252: \begin{runninglinenumbers*}
                    253: 
                    254: \subsection{\emph{Running} line numbers}
                    255: 
                    256: This is the default mode of operation.  The lines of your text are
                    257: numbered continuously across page breaks.  
                    258: 
                    259: You cannot get automatic margin switching in this mode, because at the
                    260: time when the line numbers are attached, it is not yet decided on
                    261: which page the line will end up.  However, you can simulate continuous
                    262: line numbers in \emph{pagewise} mode (see below), where margin
                    263: switching becomes possible.
                    264: 
                    265: You get this mode by
                    266: \begin{itemize}\raggedright
                    267: \item \emph{not} specifying any of the package options
                    268:   ~[switch,pagewise]~,
                    269: \item specifying the package option ~[running]~,
                    270: \item give the command ~\setrunninglinenumbers~ in the document, or
                    271: \item turn on line numbering with ~\runninglinenumbers~ or
                    272:   ~\begin{runninglinenumbers}~. 
                    273: \end{itemize}
                    274: 
                    275: \subsubsection{Reseting or setting the line number}
                    276: 
                    277: You can reset the line number with
                    278: \begin{quote}
                    279:   ~\resetlinenumber[~<number>~]~
                    280: \end{quote}
                    281: where the default is to reset the line number to one.
                    282: 
                    283: Alternatively, you can give the line number in an optional argument to
                    284: any command that turns on the line numbering in this mode:
                    285: \begin{quote}\obeylines
                    286:   ~\linenumbers[~<number>~]~ 
                    287:   ~\runninglinenumbers[~<number>~]~ 
                    288:   ~\begin{linenumbers}[~<number>~]~
                    289:   ~\begin{runninglinenumbers}[~<number>~]~
                    290: \end{quote}
                    291: or reset the line number to 1 with any of the following:
                    292: \begin{quote}\obeylines
                    293:   ~\linenumbers*~ 
                    294:   ~\runninglinenumbers*~ 
                    295:   ~\begin{linenumbers*}~
                    296:   ~\begin{linenumbers}*~
                    297:   ~\begin{runninglinenumbers*}~
                    298:   ~\begin{runninglinenumbers}*~
                    299: \end{quote}
                    300: This section of the manual is enclosed in
                    301: \begin{quote}\obeylines
                    302:   ~\begin{runninglinenumbers*}~
                    303:   ~\end{runninglinenumbers*}~
                    304: \end{quote}
                    305: \end{runninglinenumbers*}
                    306: 
                    307: 
                    308: \begin{pagewiselinenumbers}
                    309: 
                    310: \subsection{\emph{Pagewise} line numbers}
                    311: 
                    312: Basically, this mode prints line numbers starting with 1 on top of
                    313: each page, counting only lines where this mode is active.  If you
                    314: turn on this mode in the middle of a page, the numbers start with 1
                    315: at that point.
                    316: 
                    317: The \emph{pagewise} mode of operation is quite a bit more work for
                    318: \TeX.  When the line numbers are printed, \TeX\ does not know on which
                    319: page the current line will go.  To get \emph{pagewise} mode working,
                    320: \LaTeX\ has to remember on which page the line went in a previous run.
                    321: This information is written into the ~.aux~ file, and like a table of
                    322: contents, you will not see the numbers until you run \LaTeX\ at least
                    323: twice on the document.  Sometimes the information in the ~.aux~ file
                    324: becomes invalid in a way that causes \lineno.sty to hang.  In such a
                    325: case you'll have to delete all ~.aux~ files of the document to get it
                    326: going again.
                    327: 
                    328: You get this mode by
                    329: \begin{itemize}\raggedright
                    330: \item specifying the package option
                    331:   ~[pagewise]~, but not ~[running]~,
                    332: \item give the command ~\setpagewiselinenumbers~ in the document, or
                    333: \item turn on line numbering with ~\pagewiselinenumbers~ or
                    334:   ~\begin{pagewiselinenumbers}~. 
                    335: \end{itemize}
                    336: 
                    337: You cannot reset or preset the line numbers in \emph{pagewise} mode.
                    338: This mode uses a different counter than \emph{running} mode.  You can
                    339: switch between the mode, and the \emph{running} numbers will continue
                    340: where they left of, unless you reset the counter.
                    341: 
                    342: \subsubsection{Margin switching}
                    343: 
                    344: As a side effect of all the business to find out on which page the lines
                    345: end up, margin switching becomes possible.  It is now possible to
                    346: print the line number differently on odd and even pages.  The command
                    347: \begin{quote}
                    348:   ~\switchlinenumbers~
                    349: \end{quote}
                    350: will cause the line numbers to be printed on the outer margins, on the
                    351: right side for odd pages, and on the left side for even numbered
                    352: pages.  If you add a star, the numbers go on the inner margins
                    353: \begin{quote}
                    354:   ~\switchlinenumbers*~
                    355: \end{quote}
                    356: You can achieve the same effect by specifying the package
                    357: option ~[switch]~ or ~[switch*]~ together with ~[pagewise]~. 
                    358: 
                    359: Margin switching is independent of any ~[twoside]~ option of the
                    360: document class.
                    361: 
                    362: \subsubsection{\emph{Running} mode with margin switching}
                    363: 
                    364: Margin switching is not possible in \emph{running} mode, but you can
                    365: abuse the pagewise mode to produce continuous line numbers.  This mode
                    366: is activated with the command
                    367: \begin{quote}
                    368:   ~\runningpagewiselinenumbers~
                    369: \end{quote}
                    370: It is not possible to reset the line number counter for this mode, the
                    371: lines will be numbered starting from one at the beginning of the
                    372: document, and continue.  You can switch back to real pagewise mode with
                    373: \begin{quote}
                    374:   ~\realpagewiselinenumbers~
                    375: \end{quote}
                    376: but when you resume \emph{running-pagewise}, the numbers will not
                    377: continue where they left off, but jump by the number of lines that
                    378: were numbered \emph{real-pagewise}.
                    379: 
                    380: The package options ~[switch]~ and ~[switch*]~ will turn on
                    381: \emph{running pagewise} mode with margin switching, unless you also
                    382: specify ~[pagewise]~.
                    383: 
                    384: Finally, if you give these options together with ~[running]~, like
                    385: \begin{quote}
                    386:   ~\usepackage[switch,pagewise,running]{lineno}~
                    387: \end{quote}
                    388: the mode is set to plain \emph{running} line numbers, but later in
                    389: your document, if you say ~\pagewiselinenumbers~, the setings of the
                    390: ~[switch]~ and ~[pagewise]~ options will take effect.
                    391: 
                    392: \subsubsection{Page numbers}
                    393: 
                    394: Any pages that contain \emph{pagewise} numbered lines must have a
                    395: different page number.  This may cause trouble with titlepages or
                    396: simmilar fudging with the page number counter in the document.  (I am
                    397: talking about ~\c@page~ or ~\count 0~ here, not ~\thepage~).
                    398: 
                    399: If you get strange errors, like \emph{``the use of} ~\nextLN~
                    400: \emph{does not match its definition''}, you should first delete all
                    401: ~.aux~ files, and rerun \LaTeX\ several times.  If the error does not
                    402: reappear, fine, else check your page numbers, including those that are
                    403: not printed.  You may use \emph{running} line numbers on your
                    404: titlepages, since the page boundaries are predefined, usually.
                    405: 
                    406: \end{pagewiselinenumbers}
                    407: 
                    408: \begin{linenumbers*}
                    409: 
                    410: \subsection{Margin selection}
                    411: 
                    412: In any mode you can select a fixed margin on which the numbers shall
                    413: be printed.  You can either give a package option ~[left]~ or
                    414: ~[right]~, or change the margin within the document with
                    415: \begin{quote}\obeylines
                    416:   ~\leftlinenumbers~
                    417: \rightlinenumbers
                    418:   ~\rightlinenumbers~
                    419: \end{quote}
                    420: \rightlinenumbers
                    421: Neither of these commands actually turns on line numbering.  The
                    422: margin setting is changed for the currently selected mode
                    423: \emph{running} or \emph{pagewise}.  If you want to set the margin for
                    424: both modes, append a star
                    425: \begin{quote}\obeylines
                    426:   ~\leftlinenumbers*~
                    427:   ~\rightlinenumbers*~
                    428: \end{quote}
                    429: The default is ~\leftlinenumbers*~.
                    430: 
                    431: \end{linenumbers*}
                    432: 
                    433: 
                    434: \subsection{Summary of mode selection commands}
                    435: 
                    436: The following commands change the major line numbering mode.
                    437: \begin{description}\itemsep=0pt\parskip=0pt
                    438: \item [|\setrunninglinenumbers]
                    439: \item [|\setpagewiselinenumbers] \leavevmode\\
                    440:   set the current mode, without activating or deactivating line
                    441:   numbering. 
                    442: \item [|\runninglinenumbers\texttt{*[\NL}]
                    443: \item [|\pagewiselinenumbers] \leavevmode\\
                    444:   set the current mode and activate line numbering, optionally reset
                    445:   (~*~), or set the line number for \emph{running} mode. 
                    446: \end{description}
                    447: The following commands do not change the major mode, but modify the
                    448: the behaviour of \emph{pagewise} mode
                    449: \begin{description}\itemsep=0pt\parskip=0pt
                    450: \item [|\realpagewiselinenumbers]
                    451: \item [|\runningpagewiselinenumbers] \leavevmode\\
                    452:   select if \emph{pagewise} mode should number continuously, or really
                    453:   pagewise.
                    454: \end{description}
                    455: 
                    456: 
                    457: \subsection{Summary of margin selection commands}
                    458: 
                    459: The following command select into which margin the numbers should be
                    460: printed 
                    461: \begin{description}\itemsep=0pt\parskip=0pt
                    462: \item [|\leftlinenumbers\texttt*]
                    463: \item [|\rightlinenumbers\texttt*] \leavevmode\\
                    464:   put the line numbers in the left/right margin in both modes.
                    465: \item [|\leftlinenumbers]
                    466: \item [|\rightlinenumbers] \leavevmode\\
                    467:   put the line number into the left/right margin in the currently
                    468:   selected mode.
                    469: \item [|\switchlinenumbers] \leavevmode\\
                    470:   put the line numbers into the outer margin, when using
                    471:   \emph{pagewise} mode.
                    472: \item [|\switchlinenumbers\texttt*] \leavevmode\\
                    473:   put the line numbers into the inner margin, when using
                    474:   \emph{pagewise} mode.
                    475: \end{description}
                    476: 
                    477: \begin{linenumbers*}
                    478: \modulolinenumbers[2]
                    479: 
                    480: \subsection{Numbering only one in five lines}
                    481: 
                    482: You can ask lineno to print the line numbers only if they devide by
                    483: <n>, by saying
                    484: \begin{quote}
                    485:   ~\modulolinenumbers[~<n>~]~
                    486: \end{quote}
                    487: If you omit the optional argument, it will be every fifth line, or
                    488: whatever you used last (the current value of the counter
                    489: ~linenumbermodulo~).  You get the same effect by giving the package
                    490: option ~[modulo]~.
                    491: 
                    492: If you set <n> to 1, the modulo value is not changed, but modulo
                    493: numbering is turned off.  
                    494: 
                    495: Changing the counter ~linenumbermodulo~ does not turn on modulo
                    496: numbering, it just changes the modulo, if it is turned on without the
                    497: optional argument.
                    498: 
                    499: This section of the manual is enclosed in
                    500: \begin{quote}
                    501:   ~\begin{linenumbers*}~ \\ 
                    502:   ~\modulolinenumbers[2]~
                    503: 
                    504:   ~\end{linenumbers*}~
                    505: \end{quote}
                    506: 
                    507: \end{linenumbers*}
                    508: 
                    509: \begin{pagewiselinenumbers}
                    510: \switchlinenumbers
                    511: 
                    512: \subsection{How the line numbers look like}
                    513: 
                    514: This section of the manual is enclosed in
                    515: \begin{quote}
                    516:  ~\begin{pagewiselinenumbers}~ \\
                    517:  ~\switchlinenumbers~
                    518: 
                    519:  ~\end{pagewiselinenumbers}~
                    520: \end{quote}
                    521: By default, the line numbers are set in
                    522: \begin{quote}
                    523:   ~\normalfont\tiny\sffamily~
                    524: \end{quote}
                    525: right justified to 10\,pt left of the nominal left edge of the text.
                    526: If the number is to appear on the right margin, it is right justified
                    527: to 20\,pt right of the nominal right edge of the text.
                    528: 
                    529: You can easily change that, of course.  The font is defined by the
                    530: macro
                    531: \begin{quote}
                    532:   ~\linenumberfont~
                    533: \end{quote}
                    534: You can redefine it to make the numbers appear in a differnt font
                    535: (with ~\renewcommand~).  I'll say right here in this manual
                    536: \renewcommand\linenumberfont{\normalfont\bfseries\small}
                    537: \begin{quote}
                    538:   ~\renewcommand\linenumberfont{\normalfont\bfseries\small}~
                    539: \end{quote}
                    540: The distance on the left margin can be changed with
                    541: \begin{quote}
                    542:   ~\setlength\linenumbersep{~<distance>~}~
                    543: \end{quote}
                    544: The distance on the right margin is ~\linenumbersep~ plus
                    545: ~\linenumberwidth~, both are set to 10\,pt by default.
                    546: Let's do right here
                    547: \setlength\linenumberwidth{1cm}
                    548: \begin{quote}
                    549:   ~\setlength\linenumbersep{1cm}~
                    550: \end{quote}
                    551: I put the command at the end of the paragraph, but it effects the
                    552: whole paragraph, because that is where everything happens: at the end
                    553: of the paragraphs.
                    554: 
                    555: The line numbers are printed as arabic numerals, as defined in the
                    556: macro
                    557: \begin{quote}
                    558:   ~\thelinenumber~
                    559: \end{quote}
                    560: for the \LaTeX\ counter ~{linenumber}~.  You can redefine that, as
                    561: for any other \LaTeX\ counter.  E.g.,
                    562: \renewcommand\thelinenumber{\roman{linenumber}}
                    563: \begin{quote}
                    564:   ~\renewcommand\thelinenumber{\roman{linenumber}}~
                    565: \end{quote}
                    566: (For heavy duty line numbering, you should use \LaTeX s internal
                    567: format, e.g., ~\@roman\c@linenumber~.)
                    568: 
                    569: \subsubsection{Deeper customization}
                    570: 
                    571: The line number is attached to the line by the macro
                    572: \begin{quote}
                    573:   ~\makeLineNumber~
                    574: \end{quote}
                    575: which is expanded inside a zero width ~\hbox~ alligned to the
                    576: origin of the current line (left edge, baselines alligned).  You can
                    577: do anything in this macro.  Let's assume you do not want line numbers
                    578: at all, but just attach something else to each line of text: this is
                    579: the macro to modify.  You can refer to the line number by the macro
                    580: ~\LineNumber~, which prints the current value of the counter
                    581: ~{linenumber}~, or nothing if \emph{modulo} mode is active, and the
                    582: number does not divide by ~{linenumbermodulo}~.  You should not modify
                    583: this macro when using any form of \emph{pagewise} mode.  At the end of
                    584: this paragraph I put the following
                    585: \begin{runninglinenumbers}
                    586: \renewcommand\makeLineNumber
                    587:    {\hss$\rightarrow$\ \rlap{\hskip\textwidth\ $\leftarrow$}}
                    588: \end{runninglinenumbers}
                    589: \begin{quote}
                    590:   ~\begin{runninglinenumbers}~\\
                    591:   ~\renewcommand\makeLineNumber~\\
                    592:   ~ {\hss$\rightarrow$\ \rlap{\hskip\textwidth\ $\leftarrow$}}~\\
                    593:   ~\end{runninglinenumbers}~
                    594: \end{quote}
                    595: 
                    596: Redefining ~\makeLineNumber~ cuts deep into the linenumber mode
                    597: setting.  If you still want to use the basic modes \emph{running} and
                    598: \emph{pagewise} you should go one level up and modify one of the
                    599: following macros, which are called by (or assigned to)
                    600: ~\makeLineNumber~ depending on the current mode, and with the counter
                    601: ~{linenumber}~ allready adjusted for the current page when using
                    602: \emph{pagewise} mode.
                    603: \begin{quote}\obeylines
                    604:   ~\makeLineNumberRunning~
                    605:   ~\makeLineNumberOdd~
                    606:   ~\makeLineNumberEven~
                    607: \end{quote}
                    608: The first is used in \emph{running} mode, the other two in
                    609: \emph{pagewise} mode.  If you modify those, you cut into the
                    610: margin selection mechanism as advertised above.  You will have to call
                    611: a mode selection command after changing these macros, to make them take
                    612: effect (at least for ~\makeLineNumberRunning~).  
                    613: 
                    614: You can go up one more step.  The margin selection commands redefine
                    615: the above macros by making them equivalent (~\let~) to one of the
                    616: following macros
                    617: \begin{quote}\obeylines
                    618:   ~\makeLineNumberLeft~
                    619:   ~\makeLineNumberRight~
                    620: \end{quote}
                    621: You may redefine these, and afterwards issue a margin selection
                    622: command followed by a mode selection command.  The default definitions
                    623: are
                    624: \begin{quote}
                    625:   ~\def\makeLineNumberLeft~\\
                    626:   ~  {\hss\linenumberfont\LineNumber\hskip\linenumbersep}~
                    627: \end{quote}
                    628: and
                    629: \begin{quote}
                    630:   ~\def\makeLineNumberRight~\\
                    631:   ~  {\linenumberfont\hskip\linenumbersep\hskip\textwidth~\\
                    632:   ~    \hbox to\linenumberwidth{\hss\LineNumber}\hss}~
                    633: \end{quote}
                    634: Whatever you do, use ~\LineNumber~ to print the digits.  This ensures
                    635: that the modulo mode setting is acknowledged.  If you want to
                    636: customize that as well, this is the macro to change.  ~\LineNumber~
                    637: eventually refers to ~\thelinenumber~, which is the place to customize
                    638: the numerals themselves.  At the end of this paragraph I said
                    639: \renewcommand\LineNumber{\ifodd\value{linenumber} \thelinenumber)\fi}
                    640: \begin{quote}
                    641:    ~\renewcommand\LineNumber~\\
                    642:    ~   {\ifodd\value{linenumber} \thelinenumber)\fi}~
                    643: \end{quote}
                    644: Line number references are not affected by ~\LineNumber~, but you
                    645: should keep track of ~\thelinenumber~.  Look at the following
                    646: reference
                    647: \begin{quote}
                    648:   The setion title of the next section is on page \pageref{ll1}, line
                    649:   \ref{ll1}.
                    650: \end{quote}
                    651: There is a mismatch in the definition of ~\thelinenumber~, from the
                    652: point of the refered line to the reference here.
                    653: \end{pagewiselinenumbers}
                    654: 
                    655: \begin{pagewiselinenumbers}
                    656: 
                    657: \section[Line number references]
                    658:         {Line number references\linelabel{ll1}}
                    659: 
                    660: \lineno.sty allows to refer to a line number with ~\ref{~<label>~}~.
                    661: The label is set by ~\linelabel{~<label>~}~, anywhere in a paragraph
                    662: that gets line numbers.  If you put a ~\linelabel~ somewhere else, the
                    663: line number it refers to is pretty meaningless, but no error message
                    664: is issued.  (This section begins on line \ref{ll1}, page
                    665: \pageref{ll1} and ends on line \ref{ll2}, page \pageref{ll2}.)
                    666: 
                    667: References work both in \emph{running} and \emph{pagewise} modes.
                    668: However, you have to be very careful when using both \emph{real
                    669:   pagewise} mode and \emph{running pagewise} mode: The mode setting
                    670: must be the same during reference as during labeling.
                    671: 
                    672: The restrictions on placing a ~\linelabel~ are the same as for a
                    673: ~\marginpar~.  (In fact, they are implemented as fake ~\marginpar~s.)
                    674: E.g., the linelabel on the section header of this chapter could not be
                    675: placed in the straight forward way, because it would cause an error in
                    676: the table of contents.  (It should be disabled during \emph{toc}
                    677: processing.)  Instead, I typed
                    678: \begin{quote}
                    679:   ~\section[Line number references]~\\
                    680:   ~        {Line number references\linelabel{ll1}}~
                    681: \end{quote}
                    682: This works fine, with the standard \LaTeX\ ~{article}~ document
                    683: style.  If more generic markup is required, you should avoid things
                    684: like this (you should avoid \lineno.sty altogether, in that case).
                    685: 
                    686: ~\linelabel~ does not work in display math.  (Why,  you do not use
                    687: equation numbers?)
                    688: 
                    689: The ~\linelabel~ command starts a new paragraph if it is issued after
                    690: an empty line.  It will properly ignore further whitespace before the
                    691: first word of text. Thus you can easily get a label to the first line
                    692: of a paragraph.  
                    693: 
                    694: Furthermore, ~\linelabel~ uses \LaTeX s standart tricks to avoid
                    695: unnecessary spaces if you place is between two words with spaces
                    696: around, but you should not do that anyway, if you want to make sure
                    697: that the label applies to a certain word in the text.  You should
                    698: attach the line label to the word in question without intervening
                    699: spaces, either before of after the word.  If you leave spaces both
                    700: before and after the ~\linelabel~ command, the current implemenation
                    701: attaches the line label to the following word (by ignoring the
                    702: trailing space).
                    703: 
                    704: Special care should be taken at the end of a paragraph.  You better
                    705: put the line label without intervening spaces behind the period, like
                    706: this 
                    707: \begin{quote}
                    708:   ~This is the end of this section.%~\\
                    709:   ~\linelabel{ll2}~
                    710: \end{quote}
                    711: This is the end of this section.%
                    712: \linelabel{ll2}
                    713: 
                    714: \end{pagewiselinenumbers}
                    715: 
                    716: \begin{linenumbers*}
                    717: 
                    718: 
                    719: \section{Known incompatibilities}
                    720: 
                    721: This section will expand whenever somebody discovers problems when
                    722: using \lineno.sty together with other \LaTeX\ packages.
                    723: 
                    724: \subsection{\texttt{wrapfig.sty}}
                    725: 
                    726: \lineno.sty used to have problems with \texttt{wrapfig.sty}, but this
                    727: is solved but \lineno.sty, version 2.05.
                    728: 
                    729: 
                    730: \section{Extension packages}
                    731: 
                    732: The extension packages were abolished with version v3.00 of
                    733: \lineno.sty.  One package, ~itemrule.sty~, was dropped, the others
                    734: were put directly into the the main \lineno.sty package file.
                    735: 
                    736: \subsection{Display math, \texttt{\itshape mlineno}}
                    737: 
                    738: \lineno.sty does not work well with display math.  The parts of a
                    739: paragraph preceeding a display math will not get line numbers.  The
                    740: reason is that the paragraph is not finished, but the part above the
                    741: display is broken into lines anyway.
                    742: 
                    743: Let me demonstrate the effect.  This paragraph contains a
                    744: ~{displaymath}~ environment.  The part before the Formula does not get
                    745: line numbers.  Here comes the Formula
                    746: \begin{displaymath}
                    747:     \mathrm{6\,H_2O + 6\,CO_2 \ \rightarrow\  C_6H_{12}O_6 + 6\,O_2}
                    748: \end{displaymath}
                    749: which makes the line numbers disappear.  The trailing part of the
                    750: paragraph does get line numbers.  
                    751: 
                    752: There are several means to solve the problem, but none of them is
                    753: fully satisfactory.  \lineno.sty defines a ~{linenomath}~ environment,
                    754: which can be wrapped around a display math to make the line numbering
                    755: work.  This will work with any kind of display math, even if you use
                    756: explicit ~$$~ pairs.  There is a ~*~-form ~{linenomath*}~ which also
                    757: numbers the lines of the display itself, as good as it can.  Here
                    758: comes an example use of ~{linenomath*}~
                    759: \begin{linenomath*}
                    760: \begin{eqnarray*}
                    761:   b_1 &=& a_{11}x_1 + a_{12}x_2 \\
                    762:   b_2 &=& a_{21}x_1 + a_{22}x_2   
                    763: \end{eqnarray*}
                    764: \end{linenomath*}
                    765: wrapping an ~{egnarray*}~ like this
                    766: \begin{quote}
                    767:   ~\begin{linenomath*}~\\
                    768:   ~  \begin{eqnarray*}~\\
                    769:   ~    b_1 &=& a_{11}x_1 + a_{12}x_2 \\~\\
                    770:   ~    b_2 &=& a_{21}x_1 + a_{22}x_2~\\   
                    771:   ~  \end{eqnarray*}~\\
                    772:   ~\end{linenomath*}~
                    773: \end{quote}
                    774: Specifying the package option ~[mathlines]~, causes the
                    775: ~{linenomath}~ environment to switch its function with its *-form.
                    776: This allows you to later decide if you want the numbers on the formulas
                    777: or not, without putting in stars everywhere (as long as you have been
                    778: consistent).
                    779: 
                    780: The ~{linenomath}~ wrapper does nothing if line numbering is not
                    781: activated.  You do not need to remove them if you decide to omit the
                    782: line numbering later (although you still have to load \lineno.sty).
                    783: 
                    784: The \texttt{\itshape mlineno} extension redefines the standard \LaTeX\ 
                    785: display math environments to wrap themselves automatically into
                    786: ~{linenomath}~:
                    787: \begin{quote}\obeylines
                    788:    ~\[~ ~\]~
                    789:    ~{displaymath}~
                    790:    ~{equation}~
                    791:    ~{eqnarray}~
                    792:    ~{eqnarray*}~
                    793: \end{quote}
                    794: As of version 3.00 you can activate this by the package option
                    795: ~[displaymath]~.  You can keep existing explicit ~{linenomath}~
                    796: wrappers without harm.  
                    797: 
                    798: This will probably not work with AMSmath.
                    799: 
                    800: Other solutions to make \lineno.sty work with display math are either
                    801: ugly or less stable.  The ugly possibility is to precede every display
                    802: math with an empty line, or better with
                    803: \begin{quote}
                    804:   ~{\par\nobreak\noindent}~
                    805: \end{quote}
                    806: but this gains you nothing compared to using the ~{linenomath}~
                    807: environment, since you still have to modify your document.
                    808: 
                    809: \end{linenumbers*}
                    810: 
                    811: 
                    812: \subsection{\texttt{\itshape rlineno}}
                    813: 
                    814: \begin{runninglinenumbers}
                    815: It is currently not possible to put a ~\linelabel~ into math mode.
                    816: This should not impose problems with inline math, since you can attach
                    817: the label just outside the math shift, like\linelabel{rll1} 
                    818: \begin{quote}
                    819:   ~... \linelabel{~<label>~}$x=f(y)$ ...~
                    820: \end{quote}
                    821: but to refer to a line in display math, you cannot label it directly. 
                    822: \end{runninglinenumbers}
                    823: 
                    824: \begin{pagewiselinenumbers}
                    825: The extension \texttt{\itshape rlineno} offers a solution,
                    826: allowing to refer to a line number with an offset.  
                    827: 
                    828: This extension is now available with plain \lineno.sty v3.00.
                    829: 
                    830: You put the ~\linelabel~ at the end of the preceeding line, and refer
                    831: to that number, plus 1 or, in case of multiline displays, by any other
                    832: offset.\linelabel{rll2}
                    833: \begin{quote}
                    834:   ~...\linelabel{~<label>~}~ \\
                    835:   ~\begin{equation}~ \\
                    836:   ~     y=f'(x)~ \\
                    837:   ~\end{equation}~ \\
                    838:   ~... the formula in line \lineref[+1]{~<label>~}~ 
                    839: \end{quote}
                    840: The offset calculation is different for pagewise or running line
                    841: numbers, and you will have to make sure the right method is used. 
                    842: \end{pagewiselinenumbers}
                    843: 
                    844: The macro ~\lineref[~<offset>~]{~<label>~}~ uses the method of the
                    845: currently selected mode (line numbering need not be activated).  To
                    846: specify the mode explicitly, use ~\linerefr~ or ~\linerefp~ for
                    847: running or pagewise mode respectively.
                    848: 
                    849: For example, the manual sets a ~\linelabel{rll1}~ at the end of the
                    850: line preceeding the single line quote environment at
                    851: line\,\linerefr[+1]{rll1} in the first paragraph of this chapter, and
                    852: refered to it via
                    853: \begin{quote}
                    854:   ~\linerefr[+1]{rll1}~
                    855: \end{quote}
                    856: and another one preceeding the quote environment in the second
                    857: paragraph of this chapter, with the central line
                    858: numbered\,\linerefp[+3]{rll2}, which I just refered to via
                    859: \begin{quote}
                    860:   ~\linerefp[+3]{rll2}~
                    861: \end{quote}
                    862: \begin{runninglinenumbers}
                    863: If the correct mode is selected (e.g., ~\setrunninglinenumbers~),
                    864: you can use ~\lineref[+1]{rll1}~ to refer to
                    865: line\,\lineref[+1]{rll1}.
                    866: \end{runninglinenumbers}
                    867: 
                    868: 
                    869: \subsection{\texttt{\itshape numquote}}
                    870: 
                    871: This extension defines two environments, each of them with a *-form or
                    872: alternatively an optional argument.
                    873: \begin{quote}\obeylines
                    874:   ~\begin{numquote}~
                    875:   ~\end{numquote}~
                    876: \end{quote}
                    877: is like ~{quote}~,
                    878: \begin{quote}\obeylines
                    879:   ~\begin{numquotation}~
                    880:   ~\end{numquotation}~
                    881: \end{quote}
                    882: is like ~{quotation}~, but with the lines numbered.  Numbering
                    883: restarts with 1 each time it is used, except you use the *-form, or
                    884: specify the line number to start with in an optional argument.
                    885: \begin{numquote}
                    886: The line numbers set to the left of the text, indented by the same
                    887: amount as the quote or quotation.  This works as expected even if the
                    888: quote appears in a nested list. 
                    889: \end{numquote}
                    890: To customize the distance from the text or the shape of the
                    891: numbers, you can modify the macros ~\quotelinenumbersep~ and
                    892: ~\quotelinenumberfont~ respectively.
                    893: 
                    894: As of version 3.00, this is available directly with \lineno.sty.
                    895: 
                    896: \clearpage
                    897: 
                    898: \subsection{\texttt{\itshape ilineno}}
                    899: \label{sec:ilineno}
                    900: 
                    901: \begin{center}
                    902: \noindent\fbox{\parbox{0.8\textwidth}{
                    903:   \internallinenumbers \resetlinenumber[13]
                    904:   Sometimes you need line numbers within a |\parbox\ or figure.  This
                    905:   extension can do that, if the text is simple enough.  It works by
                    906:   drawing a ladder of numbers next to the paragraph, each number
                    907:   vertically separated by |\baselineskip\ from the other.  This
                    908:   obviously dose not work nicely with anything but straight text.
                    909:   Extra high lines (like this: $\displaystyle x=\frac AB$) will
                    910:   disturb the alignment.  The power of \lineno.sty is not necessary to
                    911:   achieve this, but you may need both in one document with a somewhat
                    912:   coherent interface, and some of the necessary infrastructure from
                    913:   \lineno.sty is actually useful.
                    914: }}\end{center}
                    915: % Why is the v-spacing wrong here?
                    916: 
                    917: The preceding paragraph was set like this:
                    918: \begin{quote}
                    919:   ~\begin{center}\fbox{\parbox{0.8\textwidth}{~ \\
                    920:     ~\internallinenumbers~ \\
                    921:     ~\resetlinenumber[13]~ \\
                    922:     ~ ~ Sometimes you need \dots \\
                    923:   ~}}\end{center}~
                    924: \end{quote}
                    925: 
                    926: \subsection{\texttt{\itshape itemrule.sty}}
                    927: 
                    928: Somebody asked me if he can get a rule next to an itemized item, from
                    929: the bullet downwards.  This style did that.  It was unstable and of
                    930: little interest, so it is gone from the \lineno.sty distribution.
                    931: 
                    932: \subsection{\texttt{\itshape bframe}}
                    933: \label{sec:bframe}
                    934: 
                    935: \setlength\bframesep{10pt}
                    936: \begin{bframe}
                    937: \lineno.sty can be used for unexpected purposes.  The environment 
                    938: \begin{quote}\obeylines
                    939:   ~\begin{bframe}~
                    940:   ~\end{bframe}~
                    941: \end{quote}
                    942: draws boxes around some text, even across page breaks.  At a page
                    943: break, the box is open (it is difficult to fix that).  There are two
                    944: parameters:
                    945: \begin{description}\itemsep=0pt\parskip=0pt
                    946: \item [|\bframesep] \leavevmode\\
                    947:   defines the separation of the box from the text.
                    948: \item [|\bframerule] \leavevmode\\
                    949:   defines the thickness of the lines around the text.
                    950: \end{description}
                    951: 
                    952: It works by asking \lineno.sty to draw small rules left and right to
                    953: the lines.  The total height of the rules is ~\baselineskip~ plus
                    954: ~\bframesep~. This leaves some extra space for extra high lines.
                    955: 
                    956: The current version is very preliminary.  In a future version there
                    957: may be a possibility to move the vertical lines inwards for indented
                    958: text.  The box may optionally be closed at page breaks.  It will not
                    959: likely be possible to have a colored background in the box, at least
                    960: not with a graphics driver that cannot put a background behind
                    961: existing foreground (Postscript cannot, I've been told).  Tell me how
                    962: to make a gray background, like block dots on transparent, and I can
                    963: do shaded boxes.
                    964: 
                    965: \end{bframe}
                    966: 
                    967: \section{How to print the documented source}
                    968: 
                    969: \begin{bframe}
                    970: \lineno.sty is written in three programming languages: \TeX, sh,
                    971: and awk.
                    972: 
                    973: The file can be loaded as a \LaTeXe\ package as it is.  However, if
                    974: you feed it into a Unix shell, like
                    975: \begin{quote}
                    976:    ~csh>  source ./lineno.sty~
                    977: \end{quote}
                    978: it will produce the files ~lineno.tex~ and ~lineno.dvi~, which is the
                    979: documented source of \lineno.sty.  If you want to learn how it works,
                    980: or you need to adapt \lineno.sty for some special requirements, you
                    981: should read that document.
                    982: \end{bframe}
                    983: 
                    984: \end{document}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>