Annotation of ttbar/p20_taujets_note/lineno.sty, revision 1.1
1.1 ! uid12904 1: \iffalse; awk '/S[H]ELL1/' lineno.sty|sh;exit;
! 2: ... see bottom for .tex documentation ...
! 3:
! 4: Macro file lineno.sty for LaTeX: attach line numbers, refer to them.
! 5: \fi
! 6: \def\fileversion{v4.41} \def\filedate{2005/11/02} %VERSION
! 7:
! 8: %%% Copyright 1995--2003 Stephan I. B"ottcher <boettcher@physik.uni-kiel.de>;
! 9: %%% Copyright 2002--2005 Uwe L"uck, http://www.contact-ednotes.sty.de.vu
! 10: %%% for version 4 and code from former Ednotes bundle
! 11: %%% --author-maintained.
! 12: %%%
! 13: %%% This file can be redistributed and/or modified under
! 14: %%% the terms of the LaTeX Project Public License; either
! 15: %%% version 1.3a of the License, or any later version.
! 16: %%% The latest version of this license is in
! 17: %%% http://www.latex-project.org/lppl.txt
! 18: %%% We did our best to help you, but there is NO WARRANTY.
! 19: %
! 20: %%% $Id: lineno.sty,v 3.14.2.2 2004/09/13 19:30:39 stephan Exp $ %% was v4.00.
! 21: % \title{\texttt{\itshape
! 22: %% %% (UL 2004/10/09:) Italic TT is evil
! 23: %% %% ... or nice front page layout!?
! 24: %%
! 25: % lineno.sty \ \fileversion\ \filedate
! 26: % \unskip}\\\ \\
! 27: % A \LaTeX\ package to attach
! 28: % \\ line numbers to paragraphs
! 29: % \unskip}\author{%
! 30: % Stephan I. B\"ottcher
! 31: % \\ Uwe L\"uck
! 32: % \unskip}\date{%
! 33: % boettcher@physik.uni-kiel.de
! 34: % \\ http://contact-ednotes.sty.de.vu
! 35: %% \\ stephan@nevis.columbia.edu
! 36: %% \\ Stephan.Boettcher@cern.ch
! 37: % \\}
! 38: %
! 39: % \documentclass[a4paper,12pt]{article}%D
! 40: % \usepackage{lineno}%D
! 41: %% %% (New v4.00)
! 42: % \catcode`\_\active\let_~
! 43: %% %% Beware math!? (/New v4.00)
! 44: % \def~{\verb~}
! 45: % \let\lessthan<
! 46: % \catcode`\<\active
! 47: % \def<#1>{$\langle${\itshape#1}\/$\rangle$}
! 48: % \catcode`\|\active
! 49: %% (New v4.1: \tt star; in box anyway.)
! 50: % \def|#1{\ttfamily\string#1}
! 51: %% \def|#1{{\ttfamily\string#1}}
! 52: %% (/New v4.1)
! 53: % \newenvironment{code}
! 54: % {\par\runninglinenumbers
! 55: % \modulolinenumbers[1]%
! 56: % \linenumbersep.3em
! 57: % \footnotesize
! 58: % \def\linenumberfont
! 59: % {\normalfont\tiny\itshape}}
! 60: % {}
! 61: %% %% (New v4.00)
! 62: % {\makeatletter \gdef\scs#1{\texttt
! 63: % {\protect\@backslashchar#1}}}
! 64: % \def\old{\par\footnotesize}
! 65: %% %% (/New v4.00)
! 66: %% %% (New v4.1)
! 67: % {\catcode`\/\active
! 68: % \gdef\path{\begingroup\catcode`\/\active
! 69: % \let/\slash\dopath}
! 70: % \gdef\dopath#1{\slash\unpenalty#1\endgroup}}
! 71: %% %% (/New v4.1)
! 72: %
! 73: % \begin{document}%D
! 74: %% \DocInput{lineno}%D
! 75: % \pagewiselinenumbers
! 76: % \maketitle
! 77: % \pagestyle{headings}
! 78: % \tableofcontents
! 79: % \sloppy
! 80: %
! 81: %% %% New v4.00: `...section{%' + \unskip
! 82: % \section{%
! 83: % Introductions
! 84: %% %% New v4.00: `s'
! 85: % \unskip}
! 86: %
! 87: % (New v4.00) Parts of former first section
! 88: % have been rendered separate subsections for package
! 89: % version_v4.00. (/New v4.00)
! 90: %
! 91: % \subsection{%
! 92: % Introduction to versions $\textrm{v}\lessthan4$
! 93: % \unskip}
! 94: %
! 95: % This package provides line numbers on paragraphs.
! 96: % After \TeX\ has broken a paragraph into lines there will
! 97: % be line numbers attached to them, with the possibility to
! 98: % make references through the \LaTeX\ ~\ref~, ~\pageref~
! 99: % cross reference mechanism. This includes four issues:
! 100: % \begin{itemize}
! 101: % \item attach a line number on each line,
! 102: % \item create references to a line number,
! 103: % \item control line numbering mode,
! 104: % \item count the lines and print the numbers.
! 105: % \end{itemize}
! 106: % The first two points are implemented through patches to
! 107: % the output routine. The third by redefining ~\par~, ~\@par~
! 108: % and ~\@@par~. The counting is easy, as long as you want
! 109: % the line numbers run through the text. If they shall
! 110: % start over at the top of each page, the aux-file as well
! 111: % as \TeX s memory have to carry a load for each counted line.
! 112: %
! 113: % I wrote this package for my wife Petra, who needs it for
! 114: % transcriptions of interviews. This allows her to
! 115: % precisely refer to passages in the text. It works well
! 116: % together with ~\marginpar~s, but not too well with displaymath.
! 117: % ~\footnote~s are a problem, especially when they
! 118: % are split, but we may get there.
! 119: % (New v4.00 UL) Version v4.00 overcomes the problem, I believe.
! 120: % (/UL /New v4.00)
! 121: %
! 122: % lineno.sty works
! 123: % surprisingly well with other packages, for
! 124: % example, ~wrapfig.sty~. So please try if it
! 125: % works with whatever you need, and if it does,
! 126: % please tell me, and if it does not, tell me as
! 127: % well, so I can try to fix it.
! 128: %
! 129: % \subsection{%
! 130: % Introduction to versions v4.00ff. (UL)
! 131: % \unskip}
! 132: %
! 133: % ~lineno.sty~ has been maintained by Stephan until version_v3.14.
! 134: % From version_v4.00 onwards, maintenance is shifting towards
! 135: % Uwe L\"uck (UL), who is the author of v4\dots code and of v4\dots
! 136: % changes in documentation. This came about as follows.
! 137: %
! 138: % Since late 2002, Christian Tapp and Uwe L\"uck have employed
! 139: % ~lineno.sty~ for their ~ednotes.sty~, a package supporting
! 140: % critical editions---cf.
! 141: % \[\mbox{\tt
! 142: % http://ednotes.sty.de.vu
! 143: % \unskip}\]
! 144: % ---while you find ~ednotes.sty~ and surrounding files in
! 145: % CTAN folder \path{macros/latex/contrib/ednotes}.
! 146: %
! 147: % Soon, some weaknesses of ~lineno.sty~ showed up, mainly since
! 148: % Christian's critical editions (using ~ednotes.sty~) needed lots
! 149: % of ~\linelabel~s and footnotes. (These weaknesses are due to
! 150: % weaknesses of \LaTeX's ~\marginpar~ mechanism that Stephan
! 151: % used for ~\linelabel~.) So we changed some ~lineno.sty~
! 152: % definitions in some extra files, which moreover offered new
! 153: % features. We sent these files to Stephan, hoping he would take
! 154: % the changes into ~lineno.sty~. However, he was too short of time.
! 155: %
! 156: % Writing a TUGboat article on Ednotes in 2004, we hoped to
! 157: % reduce the number of files in the Ednotes bundle and so asked
! 158: % Stephan again. Now he generously offered maintenance to me, so
! 159: % I could execute the changes on my own.
! 160: %
! 161: % The improvements are as follows:
! 162: % \begin{itemize}\item
! 163: % [(i)] Footnotes placement approaches intentions better
! 164: % (footnotes formerly liked to pile up at late pages).
! 165: % \item
! 166: % [(ii)] The number of ~\linelabel~s in one paragraph is no longer
! 167: % limited to 18.
! 168: % \item
! 169: % [(iii)] ~\pagebreak~, ~\nopagebreak~, ~\vspace~, and the star
! 170: % and optional versions of ~\\~ work as one would expect
! 171: % (section_\ref{s:MVadj}). %% Added for v4.1
! 172: % \item
! 173: % [(iv)] A command is offered which chooses the first line number
! 174: % to be printed in the margin
! 175: % (subsection_\ref{ss:Mod}). %% Added for v4.1
! 176: % \item
! 177: % [(v)] (New v4.1) \LaTeX\ tabular environments (optionally)
! 178: % get line numbers as well, and you can refer to them in the
! 179: % usual automatic way. (It may be considered a shortcoming that,
! 180: % precisely, \emph{rows} are numbered, not lines.---See
! 181: % subsection_\ref{ss:Tab}.)
! 182: % \item
! 183: % [(vi)] We are moving towards referring to math items
! 184: % (subsection_\ref{ss:MathRef} and the hooks in
! 185: % subsection_\ref{ss:LL}).
! 186: % (/New v4.1)
! 187: % \end{itemize}
! 188: % (Thanks to Stephan for making this possible!)
! 189: %
! 190: %% Unpublish:
! 191: %% You may trace the earlier developments of these changes by
! 192: %% requesting our files ~linenox0.sty~, ~linenox1.sty~, and
! 193: %% ~lnopatch.sty~. Most of our changes have been in ~linenox0.sty~.
! 194: %% Our ~linenox1.sty~ has extended ~linenox0.sty~ for one single
! 195: %% purpose in a not very stable way.
! 196: %%% (See ~\linenumberpar~ below).
! 197: %% ~lnopatch.sty~ has done the first line number thing referred
! 198: %% to in case_(iv) up to now.
! 199: %% (New v4.1)
! 200: %% Case_(v) earlier was provided by our ~edtab02.sty~---now
! 201: %% called ~edtable.sty~.
! 202: %% (/New v4.1)
! 203: %
! 204: % Ednotes moreover profits from Stephan's offer with regard
! 205: % to the documentation of our code which yielded these
! 206: % improvements formerly. This documentation now becomes
! 207: % printable, being part of the ~lineno.sty~ documentation.
! 208: %
! 209: % Of course, Stephan's previous ~lineno.sty~ versions were a great
! 210: % and ingenious work and exhibit greatest \TeX pertise. I never
! 211: % could have done this. I learnt a lot in studying the code when
! 212: % Christian pointed out strange output results and error
! 213: % messages, and there are still large portions of ~lineno.sty~
! 214: % which I don't understand (consider only pagewise numbering of
! 215: % lines). Fortunately, Stephan has offered future help if
! 216: % needed.---My code for attaching line numbers to \emph{tabular
! 217: % environments} (as mentioned above, now still in
! 218: % ~edtable.sty~) %% %% TODO
! 219: % developed from macros which Stephan and Christian experimented
! 220: % with in December 2002. Stephan built the basics.
! 221: % (However, I then became too proud to follow his advice only to
! 222: % use and modify ~longtable.sty~.)
! 223: %
! 224: % There are some issues concerning use of counters on which I
! 225: % don't agree with Stephan and where I would like to change the
! 226: % code if ~lineno.sty~ is ``mine'' as Stephan offered. However,
! 227: % Stephan is afraid of compatibility problems from which, in
! 228: % particular, his wife could suffer in the near future. So he
! 229: % demanded that I change as little as possible for my first
! 230: % version. Instead of executing changes that I plan I just offer
! 231: % my opinions at the single occasions. I hope to get in touch
! 232: % this way with users who consider subtle features vital which I
! 233: % consider strange.
! 234: %
! 235: % On the other hand, the sections on improvements of the
! 236: % implementation have been blown up very much and may be tiring
! 237: % and litte understandable for mere \emph{users}. These users
! 238: % may profit from the present presentation just by jumping to
! 239: % sections_\ref{s:Opts} and_\ref{s:UserCmds}. There is a user's
! 240: % guide ulineno.tex which may be even more helpful, but it has
! 241: % not been updated for a while. %% TODO
! 242: %
! 243: % \subsection{%
! 244: % Availability
! 245: % \unskip}
! 246: %
! 247: % In case you have found the present file otherwise than from
! 248: % CTAN: A recent version and documentation of this package
! 249: % should be available from CTAN folder
! 250: % \path{macros/latex/contrib/lineno}.
! 251: % Or mail to one of the addresses at top of file.
! 252: %
! 253: % \subsection{%
! 254: % Introductory code
! 255: % \unskip}
! 256: %
! 257: % This style option is written for \LaTeXe, November 1994 or later,
! 258: % since we need the ~\protected@write~ macro.
! 259: %
! 260: % (New v4.00) And we use ~\newcommand*~ for
! 261: % controlling length of user macro arguments, which has been
! 262: % available since December 1994.
! 263: %%
! 264:
! 265: \NeedsTeXFormat{LaTeX2e}[1994/12/01]
! 266: %% [1994/11/04]
! 267: \ProvidesPackage{lineno}
! 268: [\filedate\space line numbers on paragraphs \fileversion]
! 269: % (/New v4.00)
! 270: %%
! 271: %% History of versions:
! 272: %% v1.00 1995/03/31 SIB: first release for Petra's interview transcriptions
! 273: %% v1.01 1995/10/28 SIB: added ~pagewise~ mode
! 274: %% v1.02 1995/11/15 SIB: added ~modulo~ option
! 275: %% v1.03 1995/12/05 SIB: pagewise: try to reduce the hash-size requirements
! 276: %% v2.00 1995/12/06 SIB: .. it works, new user interface
! 277: %% v2.01 1996/09/17 SIB: put into CVS
! 278: %% v2.02 1997/03/17 SIB: add: \@reinserts, for footnotes
! 279: %% v2.04 1998/03/09 SIB: add: linenomath environment
! 280: %% v2.05 1998/04/26 SIB: add: prevgraf test
! 281: %% v2.06 1999/03/02 SIB: LPPL added
! 282: %% v3.00 1999/06/11 SiB: include the extension in the main file
! 283: %% v3.01 1999/08/28 SiB: \@reinserts -> \holdinginserts
! 284: %% v3.02 2000/03/10 SiB: \@LN@output
! 285: %% v3.03 2000/07/01 SiB: \@LN@ExtraLabelItems, hyperref
! 286: %% v3.04 2000/12/17 SiB: longtable compatibility.
! 287: %% v3.05 2001/01/02 SiB: [fleqn] detection.
! 288: %% v3.05a 2001/01/04 SiB: [fleqn] detection reverted for eqnarray.
! 289: %% v3.06 2001/01/17 SiB: [twocolumn] mode support.
! 290: %% v3.07 2001/07/30 SiB: [hyperref] option obsoleted.
! 291: %% v3.08 2001/08/02 SiB: linenomath wrapping for \[ \]
! 292: %% v3.08a 2001/08/04 SiB: linenomath wrapping for \[ \] fixed
! 293: %% v3.08b 2002/01/27 SiB: enquotation typo fix
! 294: %% v3.09 2003/01/14 SIB: hyperref detection fix
! 295: %% v3.10 2003/04/15 FMi: \MakeLineNo fix for deep boxes
! 296: %% v3.10a 2003/11/12 Uwe Lück: \lineref typo fix
! 297: %% v4.00 2004/09/02 UL: included linenox0, linenox1, lnopatch code with
! 298: %% documentation, usually indicated by `New v4.00';
! 299: %% discussions of old code, indicated by `UL';
! 300: %% LPPL v.1 -> LPPL v1.3, `program' -> `file';
! 301: %% first lines with \filedate and \fileversion,
! 302: %% according nawk lines; `November 1994 or later',
! 303: %% some earlier documentation typos (including a few
! 304: %% bad minus signs), { -> {% and } -> \unskip} at
! 305: %% line ends (so, e.g., alignment in TOC works); \scs.
! 306: %% 2004/09/03 UL: removed everything which indicated that the
! 307: %% present file were named `lineno4.sty'.
! 308: %% v4.1 2004/09/19 UL: Inserted Stephan's identification line, removed
! 309: %% some TODOs and remarks from v4.00.
! 310: %% 2004/10/04 UL: Added acknowledgement for Daniel Doherty;
! 311: %% `(New v4.00)' with [|\firstlinenumber]; changed
! 312: %% TODOs; Refining -> Redefining (\vadjust).
! 313: %% 2004/10/05 UL: ednmath0 -> mathrefs; \catcode`\~ -> \active;
! 314: %% \path; refined section on options `mathrefs';
! 315: %% changes in introduction.
! 316: %% 2004/10/06 UL: Changed/removed TODOs, e.g., for edtable.sty.
! 317: %% 2004/10/11 UL: Reminders: linenox0/1/lnopatch.sty obsolete;
! 318: %% \tt star in list of commands.
! 319: %% 2004/10/12 UL: Corrected blank lines in lineno.tex.
! 320: %% 2004/10/19 UL: Fixed minor typos; remark on \if@LN@edtable.
! 321: %% v4.1a 2004/11/07 UL: LPPL v1.3a.
! 322: %% v4.1b 2004/11/13 UL: Comment on \outputpenalty values.
! 323: %% v4.1c 2005/01/10 UL: Contact via http.
! 324: %% v4.11 2005/02/20 UL: Error message with \linelabel when not numbering.
! 325: %% 2005/03/07 UL: Removed \linelabel from ss:Tab heading, consider
! 326: %% marginal line numbers as well, revised ss:Tab.
! 327: %% Added a few lines on missing explanations to
! 328: %% s:UserCmds. Corrected some code alignments.
! 329: %% 2005/03/08 UL: Require recent edtable.sty.
! 330: %%
! 331:
! 332: %% v4.2 2005/03/21 UL: "Physical page" counter works with \include.
! 333: %% 2005/04/17 UL: Raised options section above extensions section
! 334: %% (v4.00 disabled `displaymath' option);
! 335: %% third arg for \@ifundefined{mathindent};
! 336: %% "bunch of options";
! 337: %% 2005/04/24 UL: compatibility with tamefloats; vplref.sty.
! 338: %% 2005/04/25 UL: \number -> \the; wondered -> $$; subsec. appbas;
! 339: %% CrtlLN sec -> subsec.; \newcommand* wherever ...;
! 340: %% doc. on `other output routines' and `addpageno'
! 341: %% (this changed from `varioref').
! 342: %% 2005/04/27 UL: =1\relax -> =\@ne, 0\relax ..., \hb@xt@,
! 343: %% \ifx\@@par\@@@par -> \ifLineNumbers, typos,
! 344: %% \pagestyle{headings}, LaTeX -> \LaTeX.
! 345: %% v4.21 2005/04/28 UL: linenomath section: removed wrong \else's,
! 346: %% \holding...: \thr@@, \@LN@outer@holdins, \global.
! 347: %% v4.22 2005/05/01 UL: \unvbox\@outputbox; \@LN@col without #1,
! 348: %% 2005/05/08 UL: global/local \internall..., \resetl... global,
! 349: %% shortened discussions of this and of \newcounter.
! 350: %% 2005/05/09 UL: corr.: doc. typo, version history, bad lines;
! 351: %% percent; \chardef for modulo,
! 352: %% \value{firstlinenumber}.
! 353: %% v4.3 2005/05/10 UL: \@backslashchar -> \char`\\ in \scs.
! 354: %% 2005/05/11 UL: \linenumbers sets ...outer@holdins; tidied up
! 355: %% documentation regarding earlier versions.
! 356: %% 2005/05/12 UL: `linenomath' without spurious number above;
! 357: %% `displaymath' default; edmac homepage ->
! 358: %% ednotes.sty.de.vu, \endlinenomath without
! 359: %% numbers: no change of \holdinginserts;
! 360: %% \linelabel doesn't go to .aux or mark,
! 361: %% hyperref detected; undone 2005/05/10 (bad mark).
! 362: %% 2005/05/13 UL: Reworked hyperref detection (new subsec.).
! 363: %% 2005/05/15 UL: More typo fixes, corrected terrible confusions in
! 364: %% the discussion (v4.22/v4.3) of \new/\stepcounter;
! 365: %% new subsec. in `Line number ...'; another
! 366: %% implementation of `hyperref' detection.
! 367: %% 2005/05/16 UL: Final minor changes.
! 368: %% v4.31b /06/14 UL: Extended explanation of \firstlinenumbers
! 369: %% and package options; \@LN@ifgreat@critical;
! 370: %% \modulolinenumbers*. Sent to Ednotes.news only.
! 371: %% v4.31 2005/06/15 UL: \modulolinenumbers* with \firstlinenumber{1};
! 372: %% " -> ``/''; more doc. on \firstlinenumber .
! 373: %% 2005/06/20 UL: Typo fix.
! 374: %% 2005/10/01 UL: Warning about \mod...* with pagewise mode.
! 375: %% v4.31a /10/02 UL: Minor changes of appearance of doc., e.g.,
! 376: %% \[ for $$.
! 377: %% v4.32b /10/15 UL: Support for \addvspace; removed comments that
! 378: %% had been invisible already for some time;
! 379: %% made clear with which environments the
! 380: %% linenomath environment is not needed.
! 381: %% v4.32ab /10/15 UL: Observe \if@nobreak with support for \addvspace.
! 382: %% v4.32 2005/10/17 UL: Just made it official and sent it to CTAN.
! 383: %% v4.33b /10/23 UL: \if@nobreak\nobreak\fi -> \nobreak .
! 384: %% v4.33ab /10/24 UL: \LineNoLaTeXOutput without \@tempswafalse;
! 385: %% undid v4.22: \[unv]box\@outputbox (space is OK,
! 386: %% \unvbox pushes short columns down); \@LN@kern@z@ .
! 387: %% v4.4b 2005/10/24 UL: Another tidying-up of the discussion of
! 388: %% \stepcounter{linenumber}; \@LN@screenoff@pen
! 389: %% replaces \@LN@kern@z@, \@LN@depthbox .
! 390: %% v4.4 2005/10/27 UL: Just made official for CTAN.
! 391: %% v4.4a 2005/10/29 UL: Undid change of discussion of
! 392: %% \stepcounter{linenumber} (confusion again).
! 393: %% v4.41 2005/11/02 UL: Raised \CheckCommand*.
! 394: %%
! 395: %% Acknowledgements:
! 396: %% v3.06: Donald Arseneau, pointed to mparhack.sty.
! 397: %% v3.07+: Frank Mittelbach, points out inconsistencies in the
! 398: %% user interface.
! 399: %% v3.10: Frank Mittelbach \MakeLineNo fix for deep boxes
! 400: %% v4.00: Daniel Doherty points out clash of \pagewise... with resetting
! 401: %% page number.
! 402: %% v4.21: Much testing work by Erik Luijten.
! 403: %% v4.3: `displaymath' default by Erik Luijten's suggestion.
! 404: %% v4.31: \modulolinenumbers* is an idea of Hillel Chayim Yisraeli's.
! 405: %% v4.32: Support for \addvspace due to Saravanan M.'s observation.
! 406: %% v4.33: Different support for \addvspace due to bug reports by
! 407: %% Saravanan M.'s and David Josef Dev.
! 408: %% v4.4: David Josef Dev points out that \kern\z@ after a paragraph
! 409: %% tends to place its final baseline wrongly.
! 410: %
! 411: %
! 412: % \section{%
! 413: % Put the line numbers to the lines
! 414: % \unskip}
! 415: %
! 416: % (New v4.00) This section contained the most
! 417: % basic package code previously. For various purposes of
! 418: % version_4\dots, much of these basics have been to be modified.
! 419: % Much of my (UL's) reasoning on these modifications has been to
! 420: % be reported. Sorry, the present section has been blown up
! 421: % awfully thus and contains ramifications that may be difficult
! 422: % to trace. We add some ~\subsection~ commands in order to cope
! 423: % with the new situation. (/New v4.00)
! 424: %
! 425: % \subsection{%
! 426: % Basic code of \texttt{lineno.sty} \scs{output}
! 427: % \unskip}\label{ss:output}
! 428: %
! 429: % The line numbers have to be attached by the output
! 430: % routine. We simply set the ~\interlinepenalty~ to $-100000$.
! 431: % The output routine will be called after each line in the
! 432: % paragraph, except the last, where we trigger by ~\par~.
! 433: % The ~\linenopenalty~ is small enough to compensate a bunch of
! 434: % penalties (e.g., with ~\samepage~).
! 435: %
! 436: % (New v3.04) Longtable uses
! 437: % ~\penalty~$-30000$. The lineno penalty range was
! 438: % shrunk to $-188000 \dots -32000$. (/New v3.04)
! 439: % (New v4.00) New values are listed below (11111f.). (/New v4.00)
! 440:
! 441: \newcount\linenopenalty\linenopenalty=-100000
! 442:
! 443: %% TODO v4.4+:
! 444: % (UL) Hm. It is never needed below
! 445: % that this is a counter. ~\def\linenopenalty{-100000\relax}~
! 446: % would do. (I guess this consumes more memory, but it
! 447: % is more important to save counters than to save memory.)
! 448: % I was frightened by ~-\linenopenalty~ below, but indeed
! 449: % \TeX\ interprets the string ~--100000~ as 100000.
! 450: % Has any user or extension package writer ever called
! 451: % ~\linenopenalty=xxx~, or could I really change this?---The
! 452: % counter is somewhat faster than the macro. Together with the
! 453: % compatibility question this seems to support keeping the
! 454: % counter. (???)
! 455: %% Note that Stephan chose ~\mathchardef~ below,
! 456: %% so his choice above seems to have been deliberate.
! 457: %% <- no point, \mathchardef token is fast.
! 458: % (/UL)
! 459:
! 460: \mathchardef\linenopenaltypar=32000
! 461:
! 462: % So let's make a hook to ~\output~, the direct way. The \LaTeX\
! 463: % macro ~\@reinserts~ puts the footnotes back on the page.
! 464: %
! 465: % (New v3.01) ~\@reinserts~ badly
! 466: % screws up split footnotes. The bottom part is
! 467: % still on the recent contributions list, and the
! 468: % top part will be put back there after the bottom
! 469: % part. Thus, since lineno.sty does not play well
! 470: % with ~\inserts~ anyway, we can safely experiment
! 471: % with ~\holdinginserts~, without making things
! 472: % much worse.
! 473: %
! 474: % Or that's what I thought, but: Just activating
! 475: % ~\holdinginserts~ while doing the ~\par~ will
! 476: % not do the trick: The ~\output~ routine may be
! 477: % called for a real page break before all line
! 478: % numbers are done, and how can we get control
! 479: % over ~\holdinginserts~ at that point?
! 480: %
! 481: % Let's try this: When the ~\output~ routine is
! 482: % run with ~\holdinginserts=3~ for a real page
! 483: % break, then we reset ~\holdinginserts~ and
! 484: % restart ~\output~.
! 485: %
! 486: % Then, again, how do we keep the remaining
! 487: % ~\inserts~ while doing further line numbers?
! 488: %
! 489: % If we find ~\holdinginserts~=$-3$ we activate it again
! 490: % after doing ~\output~. (/New v3.01)
! 491: %
! 492: % (New v3.02) To work with
! 493: % multicol.sty, the original output routine is now
! 494: % called indirectly, instead of being replaced.
! 495: % When multicol.sty changes ~\output~, it is a
! 496: % toks register, not the real thing. (/New v3.02)
! 497: %
! 498: % (New v4.00) Two further complications are added.
! 499: %%
! 500: %% TODO v4.3+: Or three, ~\@nobreakfalse~ after ~\MakeLineNo~
! 501: %% for getting rid of ~\@LN@nopagebreak~.
! 502: % \begin{itemize}\item
! 503: % [(i)] Problems with footnotes formerly resulted from
! 504: % \LaTeX's ~\@reinserts~ in ~\@specialoutput~ which Stephan's
! 505: % ~\linelabel~ called via the ~\marginpar~ mechanism.
! 506: % \item
! 507: % [(ii)] \LaTeX\ commands using ~\vadjust~ formerly didn't work
! 508: % as one would have hoped. The problem is as follows:
! 509: % Printing the line number results from
! 510: % a box that the output routine inserts at the place of the
! 511: % ~\interlinepenalty~. ~\vadjust~ items appear \emph{above} the
! 512: % ~\interlinepenalty~ (\TeX book p._105). So ~\pagebreak~, e.g.,
! 513: % formerly sent the line number to the next page, while the
! 514: % penalty from ~\nopagebreak~ could not tie the following line,
! 515: % since it was screened off by the line number box.---Our trick
! 516: % is putting the ~\vadjust~ items into a list macro from which
! 517: % the output routine transfers them into the vertical list,
! 518: % below the line number box.
! 519: % \end{itemize}
! 520: % In this case_(ii), like in case_(i), footnotes would suffer
! 521: % if ~\holdinginserts~ were non-positive. Indeed, in both
! 522: % cases_(i) and_(ii) we tackle the footnote problem by extending
! 523: % that part of Stephan's output routine that is active when
! 524: % ~\holdinginserts~ is positive. This extension writes the line
! 525: % number ~\newlabel~ to the .aux file (which was formerly done
! 526: % under $~\holdinginserts~=-3$) and handles the ~\vadjust~
! 527: % items.---To trigger ~\output~ and its ~\linelabel~ or, resp.,
! 528: % ~\vadjust~ part, the list of signal penalties started
! 529: % immediately before is increased here (first for ~\linelabel~,
! 530: % second for postponed ~\vadjust~ items):
! 531:
! 532: \mathchardef\@Mllbcodepen=11111
! 533: \mathchardef\@Mppvacodepen=11112
! 534:
! 535: % (/New v4.00) (New v4.2) David Kastrup urges to use a private
! 536: % name instead of ~\the\output~ (LaTeX-L-list). Otherwise an
! 537: % ~\output~ routine loaded later and using ~\newtoks\output~
! 538: % again may get lost entirely. So we change use of ~\@LN@output~,
! 539: % using it for the former purpose. Reference to what appeared
! 540: % with the name of ~\output~ here lasts for a few lines and then
! 541: % is given away.
! 542:
! 543: \let\@tempa\output
! 544: \newtoks\output
! 545: \let\@LN@output\output
! 546: \output=\expandafter{\the\@tempa}
! 547:
! 548: % Now we add two cases to Stephan's output routine. (New v4.00)
! 549:
! 550: \@tempa={%
! 551: % (/New 4.2)
! 552: \LineNoTest
! 553: \if@tempswa
! 554: %%
! 555: %% (UL) Learnt that even in def.s blank line means ~\par~.
! 556: %% to leave visual space in present file with having a
! 557: %% blank line neither in present nor in .tex file,
! 558: %% use double comment mark (`%%'). (/UL)
! 559: %%
! 560: % (New v4.00)
! 561: % We insert recognition of waiting ~\linelabel~ items---
! 562: %%
! 563: \ifnum\outputpenalty=-\@Mllbcodepen
! 564: \WriteLineNo
! 565: %%
! 566: % ---and of waiting ~\vadjust~ items:
! 567: %%
! 568: \else
! 569: \ifnum\outputpenalty=-\@Mppvacodepen
! 570: \PassVadjustList
! 571: \else
! 572: %%
! 573: %% Now we give control back to Stephan.
! 574: % (/New v4.00) (New v4.2) Outsource ``Standard'' output
! 575: % ---which occurs so rarely---to subsection_\ref{ss:LLO}:
! 576: %%
! 577: \LineNoLaTeXOutput
! 578: % (/New v4.2) (New v4.00)
! 579: % Two new ~\fi~s for the ~\linelabel~ and ~\vadjust~ tests---
! 580: %%
! 581: \fi
! 582: \fi
! 583: %%
! 584: % ---and the remaining is
! 585: %%%next three lines are
! 586: % Stephan's code again:
! 587: % (/New v4.00)
! 588: %%
! 589: \else
! 590: \MakeLineNo
! 591: \fi
! 592: }
! 593:
! 594: % (New v4.00) Our new macros
! 595: % ~\WriteLineNo~ and ~\PassVadjustList~ will be dealt with in
! 596: % sections_\ref{s:LNref} and_\ref{ss:PVadj}. (/New v4.00)
! 597: %
! 598: % \subsection{%
! 599: % \scs{LineNoTest}
! 600: % \unskip}
! 601: %
! 602: % The float mechanism inserts ~\interlinepenalty~s during
! 603: % ~\output~. So carefully reset it before going on. Else
! 604: % we get doubled line numbers on every float placed in
! 605: % horizontal mode, e.g, from ~\linelabel~.
! 606: %
! 607: % Sorry, neither a ~\linelabel~ nor a ~\marginpar~ should
! 608: % insert a penalty, else the following linenumber
! 609: % could go to the next page. Nor should any other
! 610: % float. So let us suppress the ~\interlinepenalty~
! 611: % altogether with the ~\@nobreak~ switch.
! 612: %
! 613: % Since (ltspace.dtx, v1.2p)[1996/07/26], the ~\@nobreaktrue~ does
! 614: % it's job globally. We need to do it locally here.
! 615:
! 616: \def\LineNoTest{%
! 617: \let\@@par\@@@par
! 618: \ifnum\interlinepenalty<-\linenopenaltypar
! 619: \advance\interlinepenalty-\linenopenalty
! 620: \@LN@nobreaktrue
! 621: \fi
! 622: \@tempswatrue
! 623: \ifnum\outputpenalty>-\linenopenaltypar\else
! 624: \ifnum\outputpenalty>-188000\relax
! 625: \@tempswafalse
! 626: \fi
! 627: \fi
! 628: }
! 629:
! 630: \def\@LN@nobreaktrue{\let\if@nobreak\iftrue} % renamed v4.33
! 631:
! 632: % (UL) I thought here were
! 633: % another case of the save stack problem explained in \TeX book,
! 634: % p._301, namely through both local and global changing
! 635: % ~\if@nobreak~. However, ~\@LN@nobreak~ is called during
! 636: % ~\@LN@output~ only, while ~\@nobreaktrue~ is called by \LaTeX's
! 637: % ~\@startsection~ only. The latter never happens during
! 638: % ~\@LN@output~. So there is no local value of ~\if@nobreak~ on
! 639: % save stack when ~\@nobreaktrue~ acts, since ~\the\@LN@output~
! 640: % (where ~\@LN@output~ is a new name for the original ~\output~)
! 641: % is executed within a group (\TeX book p._21).
! 642: %%
! 643: %% 2004/09/19 Removed nonsense here according to Stephan 2004/09/04.
! 644: %%
! 645: % (/UL)
! 646: %
! 647: % \subsection{%
! 648: % Other output routines (v4.2)
! 649: % \unskip}\label{ss:LLO}
! 650: %
! 651: % I had thought of dealing with bad interference of footnotes
! 652: % (and ~\enlargethispage~) with (real) ~\marginpar~s and floats
! 653: % \emph{here}. Yet this is done in
! 654: % \[
! 655: % ~http://~\mbox{[CTAN]}
! 656: % ~/macros/latex/contrib/tamefloats/tameflts.sty~
! 657: % \]
! 658: % now, and I prefer striving for compatibility with the latter.
! 659: % (See there for expanding on the problem.)
! 660: % This requires returning the special absolute value of
! 661: % ~\holdinginserts~ that ~lineno.sty~ finds at the end of a newly
! 662: % typeset paragraph---now done in subsection_\ref{ss:calls}
! 663: % (~\linenumberpar~).
! 664: % The former ~\LineNoHoldInsertsTest~ has been filled into here.
! 665: %% ---`3' is replaced by ~\thr@@~ for a while. ~\thr@@~ is
! 666: %% useful practice since plain \TeX, but Stephan may have been
! 667: %% wise in suspecting that \LaTeX\ once could forsake ~\thr@@~.
! 668: %% The same holds for ~\@M=10000~.
! 669: % Note: when the following code is invoked, we have
! 670: % ~\if@tempswa~_ =_~\iftrue~.
! 671: % WARNING: I am still not sure whether the present code is good
! 672: % for cooperating with other packages that use ~\holdinginserts~.
! 673:
! 674: \def\LineNoLaTeXOutput{%
! 675: \ifnum \holdinginserts=\thr@@ % v4.33 without \@tempswafalse
! 676: \global\holdinginserts-\thr@@
! 677: \unvbox\@cclv
! 678: \ifnum \outputpenalty=\@M \else \penalty\outputpenalty \fi
! 679: \else
! 680: \if@twocolumn \let\@makecol\@LN@makecol \fi
! 681: \the\@LN@output % finally following David Kastrup's advice.
! 682: \ifnum \holdinginserts=-\thr@@
! 683: \global\holdinginserts\thr@@ \fi
! 684: \fi
! 685: }
! 686:
! 687: % \textit{More on dealing with output routines from other
! 688: % packages:}
! 689: % Since ~lineno.sty~'s output routine is called at least once
! 690: % for each output line, I think it should be in \TeX's
! 691: % original ~\output~, while output routines dealing with
! 692: % building pages and with floats etc.\ should be filled into
! 693: % registers addressed by ~\output~ after ~\newtoks\output~.
! 694: % Therefore \begin{enumerate}
! 695: % \item
! 696: % ~tameflts.sty~ should be loaded \emph{after} ~lineno.sty~;
! 697: % \item
! 698: % if a class changes ~\output~ (APS journal class revtex4,
! 699: % e.g.), ~lineno.sty~ should be loaded by ~\RequirePackage~
! 700: % [here presumably following some options in
! 701: % brackets]~{lineno}~ \emph{preceding} ~\documentclass~.
! 702: % \item
! 703: % If you actually maintain such a class, please consider
! 704: % loading ~lineno.sty~ on some draft option. The bunch of
! 705: % lineno's package options may be a problem, but perhaps the
! 706: % purpose of your class is offering only very few of lineno's
! 707: % options anyway, maybe just one.
! 708: % \end{enumerate}
! 709: % The latter may also be needed with classes that don't follow
! 710: % David Kastrup's rule on changing ~\output~.
! 711: %
! 712: % \subsection{%
! 713: % \scs{MakeLineNo}: Actually attach line number
! 714: % \unskip}\label{ss:MLN}
! 715: %
! 716: % We have to return all the page to the current page, and
! 717: % add a box with the line number, without adding
! 718: % breakpoints, glue or space. The depth of our line number
! 719: % should be equal to the previous depth of the page, in
! 720: % case the page breaks here, and the box has to be moved up
! 721: % by that depth.
! 722: %
! 723: % The ~\interlinepenalty~ comes after the ~\vadjust~ from a
! 724: % ~\linelabel~, so we increment the line number \emph{after}
! 725: % printing it. The macro ~\makeLineNumber~ produces the
! 726: % text of the line number, see section \ref{appearance}.
! 727: %
! 728: % (UL) I needed a while to understand
! 729: % the sentence on incrementing. Correctly: writing the
! 730: % ~\newlabel~ to the .aux file is triggered by the signal
! 731: % penalty that ~\end@float~ inserts via ~\vadjust~.
! 732: % However, this could be changed by our new ~\PostponeVadjust~.
! 733: % After ~\c@linenumber~ has been introduced as a \LaTeX\
! 734: % counter, it might be preferable that it behaved like standard
! 735: % \LaTeX\ counters which are incremented shortly before printing.
! 736: % But this may be of little practical relevance in this case,
! 737: % as ~\c@linenumber~ is driven in a very non-standard
! 738: % way.---However still, this behaviour of ~\c@linenumber~
! 739: % generates a problem with our ~edtable.sty~.
! 740: %% \unskip---Before,
! 741: %% I thought that Stephan had reported his reasoning incorrectly
! 742: %% and rather did this because of his ~\resetlinenumber~ which
! 743: %% initializes ~\c@linenumber~ to 1 instead of 0---the latter is
! 744: %% usual with \LaTeX\ counters. Cf._additional comment at
! 745: %% ~\resetlinenumber~.
! 746: % (/UL).
! 747: %
! 748: % Finally we put in the natural ~\interlinepenalty~, except
! 749: % after the last line.
! 750: %
! 751: % (New v3.10) Frank Mittelbach points out that box255 may be
! 752: % less deep than the last box inside, so he proposes to
! 753: % measure the page depth with ~\boxmaxdepth=\maxdimen~.
! 754: % (/New v3.10)
! 755: %
! 756: % (UL, New v4.00) We also resume the matter of
! 757: % ~\vadjust~ items that was started in section_\ref{ss:output}.
! 758: %
! 759: % \TeX\ puts only nonzero interline
! 760: % penalties into the vertical list (\TeX book p._105), while
! 761: % ~lineno.sty~ formerly replaced the signal interline penalty by
! 762: % something closing with an explicit penalty of the value that
! 763: % the interline penalty would have without ~lineno.sty~.
! 764: % This is usually 0. Now, explicit vertical penalties can be
! 765: % very nasty with respect to ~\nopagebreak~, e.g., a low (even
! 766: % positive) ~\widowpenalty~ may force a widow where you
! 767: % explicitly tried to forbid it by ~\nopagebreak~
! 768: % (see explanation soon below).
! 769: % The ~\nopagebreak~ we create here would never work if all
! 770: % those zero penalties were present.---On
! 771: % the other hand, we cannot just omit Stephan's zero penalties,
! 772: % because \TeX\ puts a penalty of 10000 after what ~lineno.sty~
! 773: % inserts (\TeX book p._125). This penalty must be overridden
! 774: % to allow page breaks between ordinary lines. To revive
! 775: % ~\nopagebreak~, we therefore replace those zero (or low)
! 776: % penalties by penalties that the user demanded by
! 777: % ~\nopagebreak~.---This mechanism is not perfect and does not
! 778: % exactly restore the original \LaTeX\ working of ~\pagebreak~
! 779: % and ~\nopagebreak~. Viz., if there are several vertical
! 780: % penalties after a line which were produced by closely sitting
! 781: % ~\[no]pagebreak~s, without ~lineno.sty~ the lowest penalty would
! 782: % be effective (cf._\TeX book exercise_14.10). Our mechanism, by
! 783: % contrast, chooses the \emph{last} user-set penalty of the line
! 784: % as the effective one. It would not be very difficult to come
! 785: % more close to the original mechanism, but until someone urges
! 786: % us we will cling to the present simple way. You may consider an
! 787: % advantage of the difference between our mechanism and the
! 788: % original one that the user here can actually override low
! 789: % penalties by ~\nopagebreak~, which may be what a lay \LaTeX\
! 790: % user would expect.
! 791: %% ---Zero glue would do instead of zero
! 792: %% penalty! This could make things easier. Maybe next time.
! 793: %% <- v4.4: No, problem with column depth.
! 794: % (/UL, /New v4.00)
! 795:
! 796: \def\MakeLineNo{%
! 797: \@LN@maybe@normalLineNumber % v4.31
! 798: \boxmaxdepth\maxdimen\setbox\z@\vbox{\unvbox\@cclv}%
! 799: \@tempdima\dp\z@ \unvbox\z@
! 800: \sbox\@tempboxa{\hb@xt@\z@{\makeLineNumber}}%
! 801: %%
! 802: % (New v4.00) Previously,
! 803: % \begin{old}\begin{verbatim}
! 804: % % \stepcounter{linenumber}%
! 805: % \end{verbatim}
! 806: % \end{old}
! 807: %% %% TODO: Still first `\begin{old}'?
! 808: % followed. (Of course, there was no
! 809: % comment mark; I put it there to make
! 810: % reading the actual code easy.)
! 811: %
! 812: % (New v4.22: improved) Why not just
! 813: % \[~\global\advance\c@linenumber\@ne~?\]
! 814: % ~\stepcounter~ additionally resets ``subordinate''
! 815: % counters, but which could these (usefully) be?
! 816: % Again, may be column counters with ~edtable.sty~!?
! 817: %
! 818: % But then, our ~edtable.sty~ and its ~longtable~ option
! 819: % should use it as well. So use a shorthand supporting
! 820: % uniformity. You can even use it as a hook for choosing
! 821: % ~\global\advance\c@linenumber\@ne~ instead of our choice.
! 822: % (/New v4.22)
! 823: %%
! 824: \stepLineNumber
! 825: %%
! 826: % (New v4.4) Now
! 827: %%
! 828: \ht\@tempboxa\z@ \@LN@depthbox
! 829: %%
! 830: % appends the box containing the line number without changing
! 831: % ~\prevdepth~---see end of section.
! 832: % Now is the time for inserting the $\dots$ (/New v4.4)
! 833: %% The line number has now been placed (it may be invisible
! 834: %% depending on the modulo feature), so
! 835: %% we can insert the
! 836: % ~\vadjust~ items. We cannot do this much later, because
! 837: % their right place is above the artificial interline
! 838: % penalty which Stephan's code will soon insert
! 839: % (cf._\TeX book p._105). The next command is just ~\relax~
! 840: % if no ~\vadjust~ items have been accumulated for the
! 841: % current line. Otherwise it is a list macro inserting
! 842: % the ~\vadjust~ items and finally resetting itself.
! 843: % (This is made in section_\ref{ss:PVadj} below.)
! 844: % If the final item is a penalty, it is stored so it can
! 845: % compete with other things about page breaking.
! 846: %%
! 847: \@LN@do@vadjusts
! 848: \count@\lastpenalty
! 849: %%
! 850: % At this place,
! 851: % \begin{old}\begin{verbatim}
! 852: % % \ifnum\outputpenalty=-\linenopenaltypar\else
! 853: % \end{verbatim}
! 854: % \end{old}
! 855: % originally followed. We need something \emph{before} the
! 856: % ~\else~:
! 857: %%
! 858: \ifnum\outputpenalty=-\linenopenaltypar
! 859: \ifnum\count@=\z@ \else
! 860: %%
! 861: % So final ~\pagebreak[0]~ or ~\nopagebreak[0]~ has no
! 862: % effect---but this will make a difference after headings only,
! 863: % where nobody should place such a thing anyway.
! 864: %%
! 865: \xdef\@LN@parpgbrk{%
! 866: \penalty\the\count@
! 867: \global\let\noexpand\@LN@parpgbrk
! 868: \noexpand\@LN@screenoff@pen}% v4.4
! 869: %%
! 870: % That penalty will replace former ~\kern\z@~ in
! 871: % ~\linenumberpar~, see subsection_\ref{ss:calls}.---A
! 872: % few days earlier, I tried to send just a penalty value.
! 873: % However, the ~\kern\z@~ in ~\linenumberpar~ is crucial,
! 874: % as I then found out. See below.---The final penalty is
! 875: % repeated, but this does no harm. (It would not be very
! 876: % difficult to avoid the repeating, but it may even be
! 877: % less efficient.) It may be repeated due to the previous
! 878: % ~\xdef~, but it may be repeated as well below in the
! 879: % present macro where artificial interline penalty is to
! 880: % be overridden.
! 881: %%
! 882: \fi
! 883: \else
! 884: %%
! 885: % (/New v4.00)
! 886: %% Corrected code alignment with v4.11.
! 887: \@tempcnta\outputpenalty
! 888: \advance\@tempcnta -\linenopenalty
! 889: %%
! 890: % (New v4.00)
! 891: % \begin{old}\begin{verbatim}
! 892: % % \penalty\@tempcnta
! 893: % \end{verbatim}
! 894: % \end{old}
! 895: % followed previously. To give ~\nopagebreak~ a chance,
! 896: % we do
! 897: %% Corrected code alignment with v4.11.
! 898: \penalty \ifnum\count@<\@tempcnta \@tempcnta \else \count@ \fi
! 899: %%
! 900: % instead.---In ~linenox0.sty~, the ~\else~ thing once was omitted.
! 901: % Sergei Mariev's complaint (thanks!) showed that it is vital
! 902: % (see comment before ~\MakeLineNo~).
! 903: % The remaining ~\fi~ from previous package version closes the
! 904: % ~\ifnum\outputpenalty~\dots
! 905: % (/New v4.00)
! 906: %%
! 907: \fi
! 908: }
! 909:
! 910: % (New v4.00)
! 911:
! 912: \newcommand\stepLineNumber{\stepcounter{linenumber}}
! 913:
! 914: % For reason, see use above. (/New v4.00)
! 915: %% %% TODO v4.4+: ~\newcommand~ more often!?
! 916: %
! 917: % (New v4.4) The depth preserving trick is drawn here from
! 918: % ~\MakeLineNo~ because it will be used again in
! 919: % section_\ref{ss:calls}.
! 920:
! 921: \def\@LN@depthbox{%
! 922: \dp\@tempboxa=\@tempdima
! 923: \nointerlineskip \kern-\@tempdima \box\@tempboxa}
! 924:
! 925: % (/New v4.4)
! 926: %
! 927: % \section{%
! 928: % Control line numbering
! 929: % \unskip}
! 930: % \subsection{%
! 931: % Inserting \scs{output} calls %% own subsec. v4.4.
! 932: % \unskip}\label{ss:calls}
! 933: % The line numbering is controlled via ~\par~. \LaTeX\
! 934: % saved the \TeX-primitive ~\par~ in ~\@@par~. We push it
! 935: % one level further out, and redefine ~\@@par~ to insert
! 936: % the ~\interlinepenalty~ needed to trigger the
! 937: % line numbering. And we need to allow pagebreaks after a
! 938: % paragraph.
! 939: %
! 940: % New (2.05beta): the prevgraf test. A paragraph that ends with a
! 941: % displayed equation, a ~\noindent\par~ or ~wrapfig.sty~ produce empty
! 942: % paragraphs. These should not get a spurious line number via
! 943: % ~\linenopenaltypar~.
! 944:
! 945: \let\@@@par\@@par
! 946: \newcount\linenoprevgraf
! 947:
! 948: % (UL) And needs ~\linenoprevgraf~
! 949: % to be a counter? Perhaps there may be a paragraph having
! 950: % thousands of lines, so ~\mathchardef~ doesn't suffice (really??).
! 951: %%
! 952: %% %% TODO: limitations of lines per paragraph elsewhere?
! 953: %% %% Signal penalties, e.g.!? ~\deadcycles~!?
! 954: %%
! 955: % A macro ending on ~\relax~ might suffice, but would be
! 956: % somewhat slow. I think I will use ~\mathchardef~ next time.
! 957: % Or has any user used ~\linenoprevgraf~? (/UL)
! 958:
! 959: %% v4.33: changed code alignment for better understanding.
! 960: \def\linenumberpar{%
! 961: \ifvmode \@@@par \else
! 962: \ifinner \@@@par \else
! 963: \xdef\@LN@outer@holdins{\the\holdinginserts}% v4.2
! 964: \advance \interlinepenalty \linenopenalty
! 965: \linenoprevgraf \prevgraf
! 966: \global \holdinginserts \thr@@
! 967: \@@@par
! 968: \ifnum\prevgraf>\linenoprevgraf
! 969: \penalty-\linenopenaltypar
! 970: \fi
! 971: %%
! 972: % (New v4.00)
! 973: % \begin{old}\begin{verbatim}
! 974: % % \kern\z@
! 975: % \end{verbatim}
! 976: % \end{old}
! 977: % was here previously. What for?
! 978: % According to \TeX book p._125, Stephan's
! 979: % interline penalty is changed into 10000. At the end of a
! 980: % paragraph, the ~\parskip~ would follow that penalty of 10000,
! 981: % so there could be a page break neither at the
! 982: % ~\parskip~ nor at the ~\baselineskip~ (\TeX book p._110)---so
! 983: % there could never be a page break between two paragraphs.
! 984: % So something must screen off the 10000 penalty.
! 985: % Indeed, the ~\kern~ is a place to break.
! 986: % (Stephan once knew this: see `allow pagebreaks' above.)
! 987: %
! 988: % Formerly, I tried to replace ~\kern\z@~ by
! 989: % \begin{old}\begin{verbatim}
! 990: % % \penalty\@LN@parpgpen\relax
! 991: % \end{verbatim}
! 992: % \end{old}
! 993: % ---but this allows a page break after heading. So:
! 994: %%
! 995: \@LN@parpgbrk
! 996: %%
! 997: %% After heading, ~\kern\z@~ resulting from previous line
! 998: %% (see below) is followed by ~\write~ or ~\penalty10000~,
! 999: %% so causes no page break.
! 1000: %
! 1001: % These and similar changes were formerly done by ~linenox1.sty~.
! 1002: % (/New v4.00)
! 1003: %
! 1004: % (New v4.4)
! 1005: % A ~\belowdisplayskip~ may precede the previous when the paragraph
! 1006: % ends on a display-math; or there may be a ~\topsep~ from a list, etc.
! 1007: % ~\addvspace~ couldn't take account for it with ~\kern\z@~
! 1008: % here. v4.32 therefore moved the space down -- with at least two
! 1009: % bad consequences.
! 1010: % Moreover, David Josef Dev observes that ~\kern\z@~ may
! 1011: % inappropriately yield column depth 0pt.
! 1012: % For these reasons, we introduce ~\@LN@screenoff@pen~ below.
! 1013: % (/New v4.4)
! 1014: %%
! 1015: \global\holdinginserts\@LN@outer@holdins % v4.2
! 1016: \advance\interlinepenalty -\linenopenalty
! 1017: \fi % from \ifinner ... \else
! 1018: \fi} % from \ifvmode ... \else
! 1019:
! 1020: % (New v4.00, v4.4) Initialize ~\@LN@parpgbrk~, accounting
! 1021: % for earlier space and for appropriate columndepth.
! 1022: % We use former ~\MakeLineNo~'s depth-preverving trick
! 1023: % ~\@LN@depthbox~ again:
! 1024:
! 1025: \def\@LN@screenoff@pen{%
! 1026: \ifdim\lastskip=\z@
! 1027: \@tempdima\prevdepth \setbox\@tempboxa\null
! 1028: \@LN@depthbox \fi}
! 1029:
! 1030: \global\let\@LN@parpgbrk\@LN@screenoff@pen
! 1031:
! 1032: % (/New v4.4, v4.00)
! 1033: % \subsection{%
! 1034: % Turning on/off %% own subsec. v4.4.
! 1035: % \unskip}\label{ss:OnOff}
! 1036: % The basic commands to enable and disable line numbers.
! 1037: % ~\@par~ and ~\par~ are only touched, when they are ~\let~
! 1038: % to ~\@@@par~/~\linenumberpar~. The line number may be
! 1039: % reset to 1 with the star-form, or set by an optional
! 1040: % argument ~[~<number>~]~.
! 1041: %
! 1042: % (New v4.00) We add ~\ifLineNumbers~ etc.\ since
! 1043: % a number of our new adjustments need to know whether
! 1044: % linenumbering is active. This just provides a kind of
! 1045: % shorthand for ~\ifx\@@par\linenumberpar~; moreover it is
! 1046: % more stable: who knows what may happen to ~\@@par~?---A
! 1047: % caveat: ~\ifLineNumbers~ may be wrong. E.g., it may be
! 1048: % ~\iffalse~ where it acts, while a ~\linenumbers~ a few
! 1049: % lines below---in the same paragraph---brings about that
! 1050: % the line where the ~\ifLineNumbers~ appears gets a
! 1051: % marginal number.
! 1052: %% Better implementation suggested below.
! 1053: %%
! 1054: % (New v4.3) Just noticed: Such tricks have been
! 1055: % disallowed with v4.11, see subsections_\ref{ss:LL}
! 1056: % and_\ref{ss:OnOff}.---Moreover, the switching between
! 1057: % meanings of ~\linelabel~ for a possible error message
! 1058: % as of v4.11 is removed. Speed is difficult to esteem
! 1059: % and also depends on applications. Just use the most
! 1060: % simple code you find. (/New v4.3)
! 1061:
! 1062: \newif\ifLineNumbers \LineNumbersfalse
! 1063:
! 1064: % (/New v4.00)
! 1065:
! 1066: \def\linenumbers{%
! 1067: \LineNumberstrue % v4.00
! 1068: \xdef\@LN@outer@holdins{\the\holdinginserts}% v4.3
! 1069: %%
! 1070: % (New v4.3) The previous line is for ~{linenomath}~
! 1071: % in a first numbered paragraph. (/New v4.3)
! 1072: %%
! 1073: \let\@@par\linenumberpar
! 1074: % \let\linelabel\@LN@linelabel % v4.11, removed v4.3
! 1075: \ifx\@par\@@@par\let\@par\linenumberpar\fi
! 1076: \ifx\par\@@@par\let\par\linenumberpar\fi
! 1077: \@LN@maybe@moduloresume % v4.31
! 1078: \@ifnextchar[{\resetlinenumber}%]
! 1079: {\@ifstar{\resetlinenumber}{}}%
! 1080: }
! 1081:
! 1082: \def\nolinenumbers{%
! 1083: \LineNumbersfalse % v4.00
! 1084: \let\@@par\@@@par
! 1085: % \let\linelabel\@LN@LLerror % v4.11, removed v4.3
! 1086: \ifx\@par\linenumberpar\let\@par\@@@par\fi
! 1087: \ifx\par\linenumberpar\let\par\@@@par\fi
! 1088: }
! 1089:
! 1090: % (New v4.00) Moreover, it is useful to switch to
! 1091: % ~\nolinenumbers~ in ~\@arrayparboxrestore~. We postpone this
! 1092: % to section_\ref{ss:ReDef} where we'll have an appending macro
! 1093: % for doing this. (/New v4.00)
! 1094: %
! 1095: % What happens with a display math? Since ~\par~ is not executed,
! 1096: % when breaking the lines before a display, they will not get
! 1097: % line numbers. Sorry, but I do not dare to change
! 1098: % ~\interlinepenalty~ globally, nor do I want to redefine
! 1099: % the display math environments here.
! 1100: % \begin{displaymath}
! 1101: % display \ math
! 1102: % \end{displaymath}
! 1103: % See the subsection below, for a wrapper environment to make
! 1104: % it work. But that requires to wrap each and every display
! 1105: % in your \LaTeX\ source %%.
! 1106: %% v4.3:
! 1107: % (see option ~displaymath~ in subsections_\ref{ss:v3opts}
! 1108: % and_\ref{ss:display} for some relief [UL]).
! 1109: %
! 1110: % The next two commands are provided to turn on line
! 1111: % numbering in a specific mode. Please note the difference:
! 1112: % for pagewise numbering, ~\linenumbers~ comes first to
! 1113: % inhibit it from seeing optional arguments, since
! 1114: % re-/presetting the counter is useless.
! 1115:
! 1116: \def\pagewiselinenumbers{\linenumbers\setpagewiselinenumbers}
! 1117: \def\runninglinenumbers{\setrunninglinenumbers\linenumbers}
! 1118:
! 1119: % Finally, it is a \LaTeX\ style, so we provide for the use
! 1120: % of environments, including the suppression of the
! 1121: % following paragraph's indentation.
! 1122: %
! 1123: %% TODO: v4.4+:
! 1124: % (UL) I am drawing the following
! 1125: % private thoughts of Stephan's to publicity so that others may
! 1126: % think about them---or to remind myself of them in an efficient
! 1127: % way. (/UL)
! 1128: %% UL changed `%%%' to `% %' below.
! 1129: %% TODO: add \par to \linenumbers, if called from an environment. %% v4.3
! 1130: %% ToDO: add an \@endpe hack if \linenumbers are turned on
! 1131: % \begin{old}\begin{verbatim}
! 1132: % % TO DO: add \par to \linenumbers, if called from an environment.
! 1133: % % To DO: add an \@endpe hack if \linenumbers are turned on
! 1134: % % in horizontal mode. {\par\parskip\z@\noindent} or
! 1135: % % something.
! 1136: % \end{verbatim}
! 1137: % \end{old}
! 1138: % (UL) However, I rather think that ~\linenumbers~ and %% v4.31
! 1139: % ~\nolinenumbers~ should execute a ~\par~ already. (Then the
! 1140: % ~\par~s in the following definitions should be removed.) (/UL)
! 1141:
! 1142: \@namedef{linenumbers*}{\par\linenumbers*}
! 1143: \@namedef{runninglinenumbers*}{\par\runninglinenumbers*}
! 1144:
! 1145: \def\endlinenumbers{\par\@endpetrue}
! 1146: \let\endrunninglinenumbers\endlinenumbers
! 1147: \let\endpagewiselinenumbers\endlinenumbers
! 1148: \expandafter\let\csname endlinenumbers*\endcsname\endlinenumbers
! 1149: \expandafter\let\csname endrunninglinenumbers*\endcsname\endlinenumbers
! 1150: \let\endnolinenumbers\endlinenumbers
! 1151:
! 1152: %
! 1153: % \subsection{%
! 1154: % Display math
! 1155: % \unskip}\label{ss:DM}
! 1156: %
! 1157: % Now we tackle the problem to get display math working.
! 1158: % There are different options.
! 1159: % \begin{enumerate}\item[
! 1160: % 1.] Precede every display math with a ~\par~.
! 1161: % Not too good.
! 1162: % \item[
! 1163: % 2.] Change ~\interlinepenalty~ and associates globally.
! 1164: % Unstable.
! 1165: % \item[
! 1166: % 3.] Wrap each display math with a ~{linenomath}~
! 1167: % environment.
! 1168: % \end{enumerate}
! 1169: % We'll go for option 3. See if it works:
! 1170: % \begin{linenomath}
! 1171: % \begin{equation}
! 1172: % display \ math
! 1173: % \end{equation}
! 1174: % \end{linenomath}
! 1175: % The star form ~{linenomath*}~ should also number the lines
! 1176: % of the display itself,
! 1177: % \begin{linenomath*}
! 1178: % \begin{eqnarray}
! 1179: % multi && line \\
! 1180: % display && math \\
! 1181: % &
! 1182: % \begin{array}{c}
! 1183: % with \\
! 1184: % array
! 1185: % \end{array}
! 1186: % &
! 1187: % \end{eqnarray}
! 1188: % \end{linenomath*}
! 1189: % including multline displays.
! 1190: %
! 1191: % First, here are two macros to turn
! 1192: % on linenumbering on paragraphs preceeding displays, with
! 1193: % numbering the lines of the display itself, or without.
! 1194: % The ~\ifx..~ tests if line numbering is turned on. It
! 1195: % does not harm to add these wrappers in sections that are
! 1196: % not numbered. Nor does it harm to wrap a display
! 1197: % twice, e.q, in case you have some ~{equation}~s wrapped
! 1198: % explicitely, and later you redefine ~\equation~ to do it
! 1199: % automatically.
! 1200: %
! 1201: % (New v4.3) To avoid the spurious line number above a
! 1202: % display in vmode, I insert ~\ifhmode~. (/New v4.3)
! 1203:
! 1204: \newcommand\linenomathNonumbers{%
! 1205: \ifLineNumbers
! 1206: %% \ifx\@@par\@@@par\else
! 1207: \ifnum\interlinepenalty>-\linenopenaltypar
! 1208: \global\holdinginserts\thr@@
! 1209: \advance\interlinepenalty \linenopenalty
! 1210: \ifhmode % v4.3
! 1211: \advance\predisplaypenalty \linenopenalty
! 1212: \fi
! 1213: \fi
! 1214: \fi
! 1215: \ignorespaces
! 1216: }
! 1217:
! 1218: \newcommand\linenomathWithnumbers{%
! 1219: \ifLineNumbers
! 1220: %% \ifx\@@par\@@@par\else
! 1221: \ifnum\interlinepenalty>-\linenopenaltypar
! 1222: \global\holdinginserts\thr@@
! 1223: \advance\interlinepenalty \linenopenalty
! 1224: \ifhmode % v4.3
! 1225: \advance\predisplaypenalty \linenopenalty
! 1226: \fi
! 1227: \advance\postdisplaypenalty \linenopenalty
! 1228: \advance\interdisplaylinepenalty \linenopenalty
! 1229: \fi
! 1230: \fi
! 1231: \ignorespaces
! 1232: }
! 1233:
! 1234: % The ~{linenomath}~ environment has two forms, with and
! 1235: % without a star. The following two macros define the
! 1236: % environment, where the stared/non-stared form does/doesn't number the
! 1237: % lines of the display or vice versa.
! 1238:
! 1239: \newcommand\linenumberdisplaymath{%
! 1240: \def\linenomath{\linenomathWithnumbers}%
! 1241: \@namedef{linenomath*}{\linenomathNonumbers}%
! 1242: }
! 1243:
! 1244: \newcommand\nolinenumberdisplaymath{%
! 1245: \def\linenomath{\linenomathNonumbers}%
! 1246: \@namedef{linenomath*}{\linenomathWithnumbers}%
! 1247: }
! 1248:
! 1249: \def\endlinenomath{%
! 1250: \ifLineNumbers % v4.3
! 1251: \global\holdinginserts\@LN@outer@holdins % v4.21
! 1252: \fi
! 1253: \global % v4.21 support for LaTeX2e earlier than 1996/07/26.
! 1254: \@ignoretrue
! 1255: }
! 1256: \expandafter\let\csname endlinenomath*\endcsname\endlinenomath
! 1257:
! 1258: % The default is not to number the lines of a display. But
! 1259: % the package option ~mathlines~ may be used to switch
! 1260: % that behavior.
! 1261:
! 1262: \nolinenumberdisplaymath
! 1263:
! 1264: %
! 1265: % \section{%
! 1266: % Line number references
! 1267: % \unskip}\label{s:LNref}
! 1268: % \subsection{%
! 1269: % Internals %% New subsec. v4.3.
! 1270: % \unskip}
! 1271: % The only way to get a label to a line number in a
! 1272: % paragraph is to ask the output routine to mark it.
! 1273: %
! 1274: % (New v4.00) The following two paragraphs don't hold any
! 1275: % longer, see below. (/New v4.00)
! 1276: % \begin{old}\begin{verbatim}
! 1277: % % We use the marginpar mechanism to hook to ~\output~ for a
! 1278: % % second time. Marginpars are floats with number $-1$, we
! 1279: % % fake marginpars with No $-2$. Originally, every negative
! 1280: % % numbered float was considered to be a marginpar.
! 1281: % %
! 1282: % % The float box number ~\@currbox~ is used to transfer the
! 1283: % % label name in a macro called ~\@LNL@~<box-number>.
! 1284: % \end{verbatim}
! 1285: % \end{old}
! 1286: % A ~\newlabel~ is written to the aux-file. The reference
! 1287: % is to ~\theLineNumber~, \emph{not} ~\thelinenumber~.
! 1288: % This allows to hook in, as done below for pagewise line
! 1289: % numbering.
! 1290: %
! 1291: % (New v3.03) The ~\@LN@ExtraLabelItems~ are added for a hook
! 1292: % to keep packages like ~{hyperref}~ happy. (/New v3.03)
! 1293: %
! 1294: % (New v4.00)
! 1295: % We fire the ~\marginpar~ mechanism, so we leave \LaTeX's
! 1296: % ~\@addmarginpar~ untouched.
! 1297: % \begin{old}\begin{verbatim}
! 1298: % % \let\@LN@addmarginpar\@addmarginpar
! 1299: % % \def\@addmarginpar{%
! 1300: % % \ifnum\count\@currbox>-2\relax
! 1301: % % \expandafter\@LN@addmarginpar
! 1302: % % \else
! 1303: % % \@cons\@freelist\@currbox
! 1304: % % \protected@write\@auxout{}{%
! 1305: % % \string\newlabel
! 1306: % % {\csname @LNL@\the\@currbox\endcsname}%
! 1307: % % {{\theLineNumber}{\thepage}\@LN@ExtraLabelItems}}%
! 1308: % % \fi}
! 1309: % \end{verbatim}
! 1310: % \end{old}
! 1311: % OK, we keep Stephan's ~\@LN@ExtraLabelItems~:
! 1312: % (/New v4.00)
! 1313:
! 1314: \let\@LN@ExtraLabelItems\@empty
! 1315:
! 1316: % (New v4.00)
! 1317: % We imitate the ~\marginpar~ mechanism without using the
! 1318: % ~\@freelist~ boxes. ~\linelabel~ will indeed place a signal
! 1319: % penalty (~\@Mllbcodepen~, new), and it will put a label into
! 1320: % some list macro ~\@LN@labellist~. A new part of the output
! 1321: % routine will take the labels from the list and will write
! 1322: % ~\newlabel~s to the .aux file.
! 1323: %
! 1324: % The following is a version of \LaTeX's ~\@xnext~.
! 1325:
! 1326: \def\@LN@xnext#1\@lt#2\@@#3#4{\def#3{#1}\gdef#4{#2}}
! 1327:
! 1328: % This takes an item ~#1~ from a list ~#4~ into ~#3~;
! 1329: % to be used as ~\expandafter\@LN@xnext#4\@@#3#4~.
! 1330: % Our lists use ~\@lt~ after each item for separating.
! 1331: % Indeed, there will be another list macro which can
! 1332: % appear as argument ~#4~, this will be used for moving
! 1333: % ~\vadjust~ items (section_\ref{ss:PVadj}).
! 1334: % The list for ~\linelabel~s is the following:
! 1335:
! 1336: \global\let\@LN@labellist\@empty
! 1337:
! 1338: % The next is the new part of the output routine writing the
! 1339: % ~\newlabel~ to the .aux file. Since it is no real page output,
! 1340: % the page is put back to top of the main vertical list.
! 1341:
! 1342: \def\WriteLineNo{%
! 1343: \unvbox\@cclv
! 1344: \expandafter \@LN@xnext \@LN@labellist \@@
! 1345: \@LN@label \@LN@labellist
! 1346: \protected@write\@auxout{}{\string\newlabel{\@LN@label}%
! 1347: {{\theLineNumber}{\thepage}\@LN@ExtraLabelItems}}%
! 1348: }
! 1349:
! 1350: % (/New v4.00)
! 1351: %
! 1352: % \subsection{%
! 1353: % The \scs{linelabel} command
! 1354: % \unskip}\label{ss:LL}
! 1355: % To refer to a place in line ~\ref{~<foo>~}~ at page
! 1356: % ~\pageref{~<foo>~}~ you place a ~\linelabel{~<foo>~}~ at
! 1357: % that place.
! 1358: %
! 1359: % \linelabel{demo}
! 1360: % \marginpar{\tiny\raggedright
! 1361: % See if it works: This paragraph
! 1362: % starts on page \pageref{demo}, line
! 1363: % \ref{demo}.
! 1364: % \unskip}%
! 1365: % (New v4.11)
! 1366: % \begin{old}\begin{verbatim}
! 1367: % % If you use this command outside a ~\linenumbers~
! 1368: % % paragraph, you will get references to some bogus
! 1369: % % line numbers, sorry. But we don't disable the command,
! 1370: % % because only the ~\par~ at the end of a paragraph may
! 1371: % % decide whether to print line numbers on this paragraph
! 1372: % % or not. A ~\linelabel~ may legally appear earlier than
! 1373: % % ~\linenumbers~.
! 1374: % \end{verbatim}
! 1375: % \end{old}
! 1376: % This trick is better not allowed---see subsections_\ref{ss:LL}
! 1377: % and_\ref{ss:OnOff}.
! 1378: % (/New v4.11)
! 1379: %
! 1380: % ~\linelabel~
! 1381: % \begin{old}\begin{verbatim}
! 1382: % %, via a fake float number $-2$, %% new mechanism v4.00
! 1383: % \end{verbatim}
! 1384: % \end{old}
! 1385: % puts a
! 1386: % ~\penalty~ into a ~\vadjust~, which triggers the
! 1387: % pagebuilder after putting the current line to the main
! 1388: % vertical list. A ~\write~ is placed on the main vertical
! 1389: % list, which prints a reference to the current value of
! 1390: % ~\thelinenumber~ and ~\thepage~ at the time of the
! 1391: % ~\shipout~.
! 1392: %
! 1393: % A ~\linelabel~ is allowed only in outer horizontal mode.
! 1394: % In outer vertical mode we start a paragraph, and ignore
! 1395: % trailing spaces (by fooling ~\@esphack~).
! 1396: %
! 1397: % (New v4.00) We aim at relaxing the previous condition.
! 1398: % We insert a hook ~\@LN@mathhook~ and a shorthand
! 1399: % ~\@LN@postlabel~ to support the ~mathrefs~ option which
! 1400: % allows ~\linelabel~ in math mode.
! 1401: %
! 1402: % The next paragraph is no longer valid.
! 1403: % \begin{old}\begin{verbatim}
! 1404: % % The argument of ~\linelabel~ is put into a macro with a
! 1405: % % name derived from the number of the allocated float box.
! 1406: % % Much of the rest is dummy float setup.
! 1407: % \end{verbatim}
! 1408: % \end{old}
! 1409: % (/New v4.00)
! 1410: %
! 1411: % (New v4.11)
! 1412: % \begin{old}\begin{verbatim}
! 1413: % % \def\linelabel#1{%
! 1414: % \end{verbatim}
! 1415: % \end{old}
! 1416: % I forgot ~\linenumbers~ today, costed me hours or so.
! 1417:
! 1418: \def\@LN@LLerror{\PackageError{lineno}{%
! 1419: \string\linelabel\space without \string\linenumbers}{%
! 1420: Just see documentation. (New feature v4.11)}\@gobble}
! 1421:
! 1422: % (New v4.3) Here some things have changed for v4.3.
! 1423: % The previous ~#1~ has been replaced by ~\@gobble~.
! 1424: % Ensuing, the ~\linelabel~ error message is re-implemented.
! 1425: % I find it difficult to compare efficiency of slight
! 1426: % alternatives---so choose an easy one. Explicit switching
! 1427: % in ~\linenumbers~ and ~\nolinenumbers~ is an additional
! 1428: % command that may better be avoided.
! 1429:
! 1430: \newcommand\linelabel{%
! 1431: \ifLineNumbers \expandafter \@LN@linelabel
! 1432: \else \expandafter \@LN@LLerror \fi}
! 1433: %%\let\linelabel\@LN@LLerror
! 1434:
! 1435: \gdef\@LN@linelabel#1{%
! 1436: %%
! 1437: % ~\gdef~ for hyperref ``symbolically''. (/New v4.11)
! 1438: %%
! 1439: \ifx\protect\@typeset@protect
! 1440: %%
! 1441: % $\gets$ And a ~\linelabel~ should never be replicated in a
! 1442: % mark or a TOC entry. (/New v4.3)
! 1443: %%
! 1444: \ifvmode
! 1445: \ifinner \else
! 1446: \leavevmode \@bsphack \@savsk\p@
! 1447: \fi
! 1448: \else
! 1449: \@bsphack
! 1450: \fi
! 1451: \ifhmode
! 1452: \ifinner
! 1453: \@parmoderr
! 1454: \else
! 1455: %%
! 1456: % (New v4.00)
! 1457: %%
! 1458: \@LN@postlabel{#1}%
! 1459: % \begin{old}\begin{verbatim}
! 1460: % % \@floatpenalty -\@Mii
! 1461: % % \@next\@currbox\@freelist
! 1462: % % {\global\count\@currbox-2%
! 1463: % % \expandafter\gdef\csname @LNL@\the\@currbox\endcsname{#1}}%
! 1464: % % {\@floatpenalty\z@ \@fltovf \def\@currbox{\@tempboxa}}%
! 1465: % % \begingroup
! 1466: % % \setbox\@currbox \color@vbox \vbox \bgroup \end@float
! 1467: % % \endgroup
! 1468: % % \@ignorefalse \@esphack
! 1469: % \end{verbatim}
! 1470: % \end{old}
! 1471: % (/New v4.00)
! 1472: %%
! 1473: \@esphack
! 1474: %%
! 1475: % (New v4.00)
! 1476: % The ~\@ignorefalse~ was appropriate before because the
! 1477: % ~\@Esphack~ in ~\end@float~ set ~\@ignoretrue~. Cf._\LaTeX's
! 1478: % ~\@xympar~. (/New v4.00)
! 1479: %%
! 1480: \fi
! 1481: \else
! 1482: %%
! 1483: % (New v4.00)
! 1484: %%
! 1485: \@LN@mathhook{#1}%
! 1486: % \begin{old}\begin{verbatim}
! 1487: % % \@parmoderr
! 1488: % \end{verbatim}
! 1489: % \end{old}
! 1490: % Instead of complaining, you may just do your job.
! 1491: % (/New v4.00)
! 1492: %%
! 1493: \fi
! 1494: \fi
! 1495: }
! 1496:
! 1497: % (New v4.00) The shorthand just does what happened
! 1498: % with ~linenox0.sty~ before ~ednmath0.sty~ (New v4.1:
! 1499: % now ~mathrefs~ option) appeared, and
! 1500: % the hook is initialized to serve the same purpose.
! 1501: % So errors come just where Stephan had built them in,
! 1502: % and this is just the \LaTeX\ ~\marginpar~ behaviour.
! 1503:
! 1504: \def\@LN@postlabel#1{\g@addto@macro\@LN@labellist{#1\@lt}%
! 1505: \vadjust{\penalty-\@Mllbcodepen}}
! 1506: \def\@LN@mathhook#1{\@parmoderr}
! 1507:
! 1508: % (/New v4.00)
! 1509: %
! 1510: % \modulolinenumbers[3]
! 1511: % \firstlinenumber{1}
! 1512: % \section{%
! 1513: % The appearance of the line numbers
! 1514: % \unskip}\label{appearance}
! 1515: % \subsection{%
! 1516: % Basic code %% own subsec. v4.2.
! 1517: % \unskip}
! 1518: %
! 1519: % The line numbers are set as ~\tiny\sffamily\arabic{linenumber}~,
! 1520: % $10pt$ left of the text. With options to place it
! 1521: % right of the text, or . . .
! 1522: %
! 1523: % . . . here are the hooks:
! 1524:
! 1525: \def\makeLineNumberLeft{%
! 1526: \hss\linenumberfont\LineNumber\hskip\linenumbersep}
! 1527:
! 1528: \def\makeLineNumberRight{%
! 1529: \linenumberfont\hskip\linenumbersep\hskip\columnwidth
! 1530: \hb@xt@\linenumberwidth{\hss\LineNumber}\hss}
! 1531:
! 1532: \def\linenumberfont{\normalfont\tiny\sffamily}
! 1533:
! 1534: \newdimen\linenumbersep
! 1535: \newdimen\linenumberwidth
! 1536:
! 1537: \linenumberwidth=10pt
! 1538: \linenumbersep=10pt
! 1539:
! 1540: % Margin switching requires ~pagewise~ numbering mode, but
! 1541: % choosing the left or right margin for the numbers always
! 1542: % works.
! 1543:
! 1544: \def\switchlinenumbers{\@ifstar
! 1545: {\let\makeLineNumberOdd\makeLineNumberRight
! 1546: \let\makeLineNumberEven\makeLineNumberLeft}%
! 1547: {\let\makeLineNumberOdd\makeLineNumberLeft
! 1548: \let\makeLineNumberEven\makeLineNumberRight}%
! 1549: }
! 1550:
! 1551: \def\setmakelinenumbers#1{\@ifstar
! 1552: {\let\makeLineNumberRunning#1%
! 1553: \let\makeLineNumberOdd#1%
! 1554: \let\makeLineNumberEven#1}%
! 1555: {\ifx\c@linenumber\c@runninglinenumber
! 1556: \let\makeLineNumberRunning#1%
! 1557: \else
! 1558: \let\makeLineNumberOdd#1%
! 1559: \let\makeLineNumberEven#1%
! 1560: \fi}%
! 1561: }
! 1562:
! 1563: \def\leftlinenumbers{\setmakelinenumbers\makeLineNumberLeft}
! 1564: \def\rightlinenumbers{\setmakelinenumbers\makeLineNumberRight}
! 1565:
! 1566: \leftlinenumbers*
! 1567:
! 1568: % ~\LineNumber~ is a hook which is used for the modulo stuff.
! 1569: % It is the command to use for the line number, when you
! 1570: % customize ~\makeLineNumber~. Use ~\thelinenumber~ to
! 1571: % change the outfit of the digits.
! 1572: %
! 1573: %
! 1574: % We will implement two modes of operation:
! 1575: % \begin{itemize}
! 1576: % \item numbers ~running~ through (parts of) the text
! 1577: % \item ~pagewise~ numbers starting over with one on top of
! 1578: % each page.
! 1579: % \end{itemize}
! 1580: % Both modes have their own count register, but only one is
! 1581: % allocated as a \LaTeX\ counter, with the attached
! 1582: % facilities serving both.
! 1583:
! 1584: \newcounter{linenumber}
! 1585: \newcount\c@pagewiselinenumber
! 1586: \let\c@runninglinenumber\c@linenumber
! 1587:
! 1588: % Only the running mode counter may be reset, or preset,
! 1589: % for individual paragraphs. The pagewise counter must
! 1590: % give a unique anonymous number for each line.
! 1591: %
! 1592: % (New v4.3) ~\newcounter{linenumber}~
! 1593: % was the only ~\newcounter~ in the whole package, and
! 1594: % formerly I was near using ~\newcount~ instead. Yet
! 1595: % ~\newcounter~ may be quite useful for ~\includeonly~.
! 1596: % It also supports resetting ``subcounters'', but what
! 1597: % could these be? Well, ~edtable~ might introduce a
! 1598: % subcounter for columns.
! 1599: % (Note that \LaTeX's setting commands would work with
! 1600: % ~\newcount\c@linenumber~ already, apart from this.
! 1601: % And perhaps sometimes ~\refstepcounter{linenumber}~
! 1602: % wouldn't work---cf._my discussion of ~\stepcounter~ in
! 1603: % subsection_\ref{ss:MLN}, similarly ~\refstep...~ would
! 1604: % be quite useless.
! 1605: % Even the usual redefinitions of ~\thelinenumber~ would
! 1606: % work. It is nice, on the other hand, that
! 1607: % ~\thelinenumber~ is predefined here. \LaTeX's
! 1608: % initialization of the value perhaps just serves making
! 1609: % clear \LaTeX\ counters should always be changed
! 1610: % globally.---Shortened and improved the discussion here.)
! 1611: % (/New v4.3)
! 1612: %
! 1613: % (New v4.22)
! 1614: % ~\c@linenumber~ usually is---globally---incremented by
! 1615: % ~\stepcounter~ (at present), so resetting it locally would
! 1616: % raise the save stack problem of \TeX book p._301, moreover
! 1617: % it would be is useless, there is no hope of keeping the
! 1618: % values local (but see subsection_\ref{ss:ILN}). So I insert
! 1619: % ~\global~: (/New v4.22)
! 1620:
! 1621: \newcommand*\resetlinenumber[1][\@ne]{%
! 1622: \global % v4.22
! 1623: \c@runninglinenumber#1\relax}
! 1624:
! 1625: % (New v4.00)
! 1626: % \begin{old}\begin{verbatim}
! 1627: % % \newcommand\resetlinenumber[1][1]{\c@runninglinenumber#1}
! 1628: % \end{verbatim}
! 1629: % \end{old}
! 1630: % Added ~\relax~, being quite sure that this does no harm
! 1631: % and is quite important, as with ~\setcounter~ etc.
! 1632: % I consider this a bug fix (although perhaps no user has
! 1633: % ever had a problem with this). (/New v4.00)
! 1634: %
! 1635: % (v4.22: I had made much fuss about resetting subordinate
! 1636: % counters here---removed, somewhat postponed.)
! 1637: %
! 1638: %% TODO v4.4+:
! 1639: %% \newcommand*\resetlinenumber[1][\@ne]{%
! 1640: %% \ifx\c@linenumber\c@runninglinenumber
! 1641: %% \global\c@linenumber#1\relax
! 1642: %% \global\advance\c@linenumber\m@ne
! 1643: %% \stepLineNumber
! 1644: %% \else
! 1645: %% \PackageError{lineno}%% Shorthand!?
! 1646: %% {You can't reset line number in pagewise mode}%
! 1647: %% {This should suffice.}%
! 1648: %% \fi
! 1649: %% }
! 1650: %
! 1651: % \subsection{%
! 1652: % Running line numbers
! 1653: % \unskip}
! 1654: %
! 1655: % Running mode is easy, ~\LineNumber~ and ~\theLineNumber~
! 1656: % produce ~\thelinenumber~, which defaults to
! 1657: % ~\arabic{linenumber}~, using the ~\c@runninglinenumber~
! 1658: % counter. This is the default mode of operation.
! 1659:
! 1660: \def\makeRunningLineNumber{\makeLineNumberRunning}
! 1661:
! 1662: \def\setrunninglinenumbers{%
! 1663: \def\theLineNumber{\thelinenumber}%
! 1664: \let\c@linenumber\c@runninglinenumber
! 1665: \let\makeLineNumber\makeRunningLineNumber
! 1666: }
! 1667:
! 1668: \setrunninglinenumbers\resetlinenumber
! 1669:
! 1670: %
! 1671: % \subsection{%
! 1672: % Pagewise line numbers
! 1673: % \unskip}\label{ss:PW}
! 1674: %
! 1675: % Difficult, if you think about it. The number has to be
! 1676: % printed when there is no means to know on which page it
! 1677: % will end up, except through the aux-file. My solution
! 1678: % is really expensive, but quite robust.
! 1679: %
! 1680: % With version ~v2.00~ the hashsize requirements are
! 1681: % reduced, because we do not need one controlsequence for
! 1682: % each line any more. But this costs some computation time
! 1683: % to find out on which page we are.
! 1684: %
! 1685: % ~\makeLineNumber~ gets a hook to log the line and page
! 1686: % number to the aux-file. Another hook tries to find out
! 1687: % what the page offset is, and subtracts it from the counter
! 1688: % ~\c@linenumber~. Additionally, the switch
! 1689: % ~\ifoddNumberedPage~ is set true for odd numbered pages,
! 1690: % false otherwise.
! 1691:
! 1692: \def\setpagewiselinenumbers{%
! 1693: \let\theLineNumber\thePagewiseLineNumber
! 1694: \let\c@linenumber\c@pagewiselinenumber
! 1695: \let\makeLineNumber\makePagewiseLineNumber
! 1696: }
! 1697:
! 1698: \def\makePagewiseLineNumber{\logtheLineNumber\getLineNumber
! 1699: \ifoddNumberedPage
! 1700: \makeLineNumberOdd
! 1701: \else
! 1702: \makeLineNumberEven
! 1703: \fi
! 1704: }
! 1705:
! 1706: % Each numbered line gives a line to the aux file
! 1707: % \begin{verse}
! 1708: % ~\@LN{~<line>~}{~<page>~}~
! 1709: % \end{verse}
! 1710: % very similar to the ~\newlabel~ business, except that we need
! 1711: % an arabic representation of the page number, not what
! 1712: % there might else be in ~\thepage~.
! 1713:
! 1714: \def\logtheLineNumber{\protected@write\@auxout{}{%
! 1715: %%
! 1716: % (New v4.00) (UL)
! 1717: % As Daniel Doherty observed, the earlier line
! 1718: % \begin{old}\begin{verbatim}
! 1719: % % \string\@LN{\the\c@linenumber}{\noexpand\the\c@page}}}
! 1720: % \end{verbatim}
! 1721: % \end{old}
! 1722: % here may lead into an infinite loop when the user resets
! 1723: % the page number (think of ~\pagenumbering~, e.g.).
! 1724: % Stephan and I brief\/ly discussed the matter and decided
! 1725: % to introduce a ``physical''-page counter to which
! 1726: % ~\logtheLineNumber~ refers. It was Stephan's idea to use
! 1727: % ~\cl@page~ for reliably augmenting the ``physical''-page
! 1728: % counter. However, this relies on the output routine once
! 1729: % doing ~\stepcounter{page}~. Before Stephan's
! 1730: % suggestion, I had thought of appending the stepping to
! 1731: % \LaTeX's ~\@outputpage~.---So the macro definition ends
! 1732: % as follows.
! 1733: %%
! 1734: \string\@LN{\the\c@linenumber}{%
! 1735: %%
! 1736: % (New v4.2)
! 1737: %% \noexpand\number\n@LN@truepage}}}
! 1738: %%
! 1739: % The `truepage' counter must start with ~\c@~ so it works
! 1740: % with ~\include~, and the ~\@addtoreset~ below is needed
! 1741: % for the same purpose.
! 1742: %%
! 1743: \noexpand\the\c@LN@truepage}}}
! 1744:
! 1745: %% \newcount\n@LN@truepage
! 1746: %% \g@addto@macro\cl@page{\global\advance\n@LN@truepage\@ne}
! 1747: \newcount\c@LN@truepage
! 1748: \g@addto@macro\cl@page{\global\advance\c@LN@truepage\@ne}
! 1749: \@addtoreset{LN@truepage}{@ckpt}
! 1750:
! 1751: % (/New v4.2) I had thought of offering more
! 1752: % features of a \LaTeX\ counter. However, the user should
! 1753: % better \emph{not} have access to this counter. ~\c@page~
! 1754: % should suffice as a pagewise master counter.---To be sure,
! 1755: % along the present lines the user \emph{can} manipulate
! 1756: % ~\c@LN@truepage~ by ~\stepcounter{page}~. E.g., she might
! 1757: % do this in order to manually insert a photograph. Well,
! 1758: % seems not to harm.
! 1759: %
! 1760: % The above usage of ~\g@addto@macro~ and ~\cl@page~ may be
! 1761: % not as stable as Stephan intended. His proposal used
! 1762: % ~\xdef~ directly. But he used ~\cl@page~ as well, and who
! 1763: % knows \dots{} And as to ~\g@addto@macro~, I have introduced
! 1764: % it for list macros anyway.
! 1765: % (/UL) (/New v4.00)
! 1766: %
! 1767: % From the aux-file we get one macro ~\LN@P~<page> for each
! 1768: % page with line numbers on it. This macro calls four other
! 1769: % macros with one argument each. These macros are
! 1770: % dynamically defined to do tests and actions, to find out
! 1771: % on which page the current line number is located.
! 1772: %
! 1773: % We need sort of a pointer to the first page with line
! 1774: % numbers, initiallized to point to nothing:
! 1775:
! 1776: \def\LastNumberedPage{first}
! 1777: \def\LN@Pfirst{\nextLN\relax}
! 1778:
! 1779: % The four dynamic macros are initiallized to reproduce
! 1780: % themselves in an ~\xdef~
! 1781:
! 1782: \let\lastLN\relax % compare to last line on this page
! 1783: \let\firstLN\relax % compare to first line on this page
! 1784: \let\pageLN\relax % get the page number, compute the linenumber
! 1785: \let\nextLN\relax % move to the next page
! 1786:
! 1787: % During the end-document run through the aux-files, we
! 1788: % disable ~\@LN~. I may put in a check here later, to give
! 1789: % a rerun recommendation.
! 1790:
! 1791: \AtEndDocument{\let\@LN\@gobbletwo}
! 1792:
! 1793: % Now, this is the tricky part. First of all, the whole
! 1794: % definition of ~\@LN~ is grouped, to avoid accumulation
! 1795: % on the save stack. Somehow ~\csname~<cs>~\endcsname~ pushes
! 1796: % an entry, which stays after an ~\xdef~ to that <cs>.
! 1797: %
! 1798: % If ~\LN@P~<page> is undefined, initialize it with the
! 1799: % current page and line number, with the
! 1800: % \emph{pointer-to-the-next-page} pointing to nothing. And
! 1801: % the macro for the previous page will be redefined to point
! 1802: % to the current one.
! 1803: %
! 1804: % If the macro for the current page already exists, just
! 1805: % redefine the \emph{last-line-number} entry.
! 1806: %
! 1807: % Finally, save the current page number, to get the pointer to the
! 1808: % following page later.
! 1809:
! 1810: \def\@LN#1#2{{\expandafter\@@LN
! 1811: \csname LN@P#2C\@LN@column\expandafter\endcsname
! 1812: \csname LN@PO#2\endcsname
! 1813: {#1}{#2}}}
! 1814:
! 1815: \def\@@LN#1#2#3#4{\ifx#1\relax
! 1816: \ifx#2\relax\gdef#2{#3}\fi
! 1817: \expandafter\@@@LN\csname LN@P\LastNumberedPage\endcsname#1%
! 1818: \xdef#1{\lastLN{#3}\firstLN{#3}%
! 1819: \pageLN{#4}{\@LN@column}{#2}\nextLN\relax}%
! 1820: \else
! 1821: \def\lastLN##1{\noexpand\lastLN{#3}}%
! 1822: \xdef#1{#1}%
! 1823: \fi
! 1824: \xdef\LastNumberedPage{#4C\@LN@column}}
! 1825:
! 1826: % The previous page macro gets its pointer to the
! 1827: % current one, replacing the ~\relax~ with the cs-token
! 1828: % ~\LN@P~<page>.
! 1829:
! 1830: \def\@@@LN#1#2{{\def\nextLN##1{\noexpand\nextLN\noexpand#2}%
! 1831: \xdef#1{#1}}}
! 1832:
! 1833: % Now, to print a line number, we need to find the page,
! 1834: % where it resides. This will most probably be the page where
! 1835: % the last one came from, or maybe the next page. However, it can
! 1836: % be a completely different one. We maintain a cache,
! 1837: % which is ~\let~ to the last page's macro. But for now
! 1838: % it is initialized to expand ~\LN@first~, where the poiner
! 1839: % to the first numbered page has been stored in.
! 1840:
! 1841: \def\NumberedPageCache{\LN@Pfirst}
! 1842:
! 1843: % To find out on which page the current ~\c@linenumber~ is,
! 1844: % we define the four dynamic macros to do something usefull
! 1845: % and execute the current cache macro. ~\lastLN~ is run
! 1846: % first, testing if the line number in question may be on a
! 1847: % later page. If so, disable ~\firstLN~, and go on to the
! 1848: % next page via ~\nextLN~.
! 1849:
! 1850: \def\testLastNumberedPage#1{\ifnum#1<\c@linenumber
! 1851: \let\firstLN\@gobble
! 1852: \fi}
! 1853:
! 1854: % Else, if ~\firstLN~ finds out that we need an earlier
! 1855: % page, we start over from the beginning. Else, ~\nextLN~
! 1856: % will be disabled, and ~\pageLN~ will run
! 1857: % ~\gotNumberedPage~ with four arguments: the first line
! 1858: % number on this column, the page number, the column
! 1859: % number, and the first line on the page.
! 1860:
! 1861: \def\testFirstNumberedPage#1{\ifnum#1>\c@linenumber
! 1862: \def\nextLN##1{\testNextNumberedPage\LN@Pfirst}%
! 1863: \else
! 1864: \let\nextLN\@gobble
! 1865: \def\pageLN{\gotNumberedPage{#1}}%
! 1866: \fi}
! 1867:
! 1868: % We start with ~\pageLN~ disabled and ~\nextLN~ defined to
! 1869: % continue the search with the next page.
! 1870:
! 1871: \long\def \@gobblethree #1#2#3{}
! 1872:
! 1873: \def\testNumberedPage{%
! 1874: \let\lastLN\testLastNumberedPage
! 1875: \let\firstLN\testFirstNumberedPage
! 1876: \let\pageLN\@gobblethree
! 1877: \let\nextLN\testNextNumberedPage
! 1878: \NumberedPageCache
! 1879: }
! 1880:
! 1881: % When we switch to another page, we first have to make
! 1882: % sure that it is there. If we are done with the last
! 1883: % page, we probably need to run \TeX\ again, but for the
! 1884: % rest of this run, the cache macro will just return four
! 1885: % zeros. This saves a lot of time, for example if you have
! 1886: % half of an aux-file from an aborted run, in the next run
! 1887: % the whole page-list would be searched in vain again and
! 1888: % again for the second half of the document.
! 1889: %
! 1890: % If there is another page, we iterate the search.
! 1891:
! 1892: \def\testNextNumberedPage#1{\ifx#1\relax
! 1893: \global\def\NumberedPageCache{\gotNumberedPage0000}%
! 1894: \PackageWarningNoLine{lineno}%
! 1895: {Linenumber reference failed,
! 1896: \MessageBreak rerun to get it right}%
! 1897: \else
! 1898: \global\let\NumberedPageCache#1%
! 1899: \fi
! 1900: \testNumberedPage
! 1901: }
! 1902:
! 1903: % \linelabel{demo2}
! 1904: % \marginpar{\tiny\raggedright
! 1905: % Let's see if it finds the label
! 1906: % on page \pageref{demo},
! 1907: % line \ref{demo}, and back here
! 1908: % on page \pageref{demo2}, line
! 1909: % \ref{demo2}.
! 1910: % \unskip}%
! 1911: % To separate the official hooks from the internals there is
! 1912: % this equivalence, to hook in later for whatever purpose:
! 1913:
! 1914: \let\getLineNumber\testNumberedPage
! 1915:
! 1916: % So, now we got the page where the number is on. We
! 1917: % establish if we are on an odd or even page, and calculate
! 1918: % the final line number to be printed.
! 1919:
! 1920: \newif\ifoddNumberedPage
! 1921: \newif\ifcolumnwiselinenumbers
! 1922: \columnwiselinenumbersfalse
! 1923:
! 1924: \def\gotNumberedPage#1#2#3#4{\oddNumberedPagefalse
! 1925: \ifodd \if@twocolumn #3\else #2\fi\relax\oddNumberedPagetrue\fi
! 1926: \advance\c@linenumber\@ne
! 1927: \ifcolumnwiselinenumbers
! 1928: \subtractlinenumberoffset{#1}%
! 1929: \else
! 1930: \subtractlinenumberoffset{#4}%
! 1931: \fi
! 1932: }
! 1933:
! 1934: % You might want to run the pagewise mode with running line
! 1935: % numbers, or you might not. It's your choice:
! 1936:
! 1937: \def\runningpagewiselinenumbers{%
! 1938: \let\subtractlinenumberoffset\@gobble
! 1939: }
! 1940:
! 1941: \def\realpagewiselinenumbers{%
! 1942: \def\subtractlinenumberoffset##1{\advance\c@linenumber-##1\relax}%
! 1943: }
! 1944:
! 1945: \realpagewiselinenumbers
! 1946:
! 1947: % For line number references, we need a protected call to
! 1948: % the whole procedure, with the requested line number stored
! 1949: % in the ~\c@linenumber~ counter. This is what gets printed
! 1950: % to the aux-file to make a label:
! 1951:
! 1952: \def\thePagewiseLineNumber{\protect
! 1953: \getpagewiselinenumber{\the\c@linenumber}}%
! 1954:
! 1955: % And here is what happens when the label is refered to:
! 1956:
! 1957: \def\getpagewiselinenumber#1{{%
! 1958: \c@linenumber #1\relax\testNumberedPage
! 1959: \thelinenumber
! 1960: }}
! 1961:
! 1962: % %
! 1963: % A summary of all per line expenses:
! 1964: % \begin{description}\item
! 1965: % [CPU:] The ~\output~ routine is called for each line,
! 1966: % and the page-search is done.
! 1967: % \item
! 1968: % [DISK:] One line of output to the aux-file for each
! 1969: % numbered line
! 1970: % \item
! 1971: % [MEM:] One macro per page. Great improvement over v1.02,
! 1972: % which had one control sequence per line in
! 1973: % addition. It blew the hash table after some five
! 1974: % thousand lines.
! 1975: % \end{description}
! 1976: %
! 1977: % \subsection{%
! 1978: % Twocolumn mode (New v3.06)
! 1979: % \unskip}
! 1980: %
! 1981: % Twocolumn mode requires another patch to the ~\output~
! 1982: % routine, in order to print a column tag to the .aux
! 1983: % file.
! 1984:
! 1985: \AtBeginDocument{% v4.2, revtex4.cls (e.g.).
! 1986: % <- TODO v4.4+: Or better in \LineNoLaTeXOutput!?
! 1987: \let\@LN@orig@makecol\@makecol}
! 1988: \def\@LN@makecol{%
! 1989: \@LN@orig@makecol
! 1990: \setbox\@outputbox \vbox{%
! 1991: \boxmaxdepth \@maxdepth
! 1992: \protected@write\@auxout{}{%
! 1993: \string\@LN@col{\if@firstcolumn1\else2\fi}%
! 1994: }%
! 1995: \box\@outputbox
! 1996: }% \vbox
! 1997: } %% TODO cf. revtexln.sty.
! 1998:
! 1999: \def\@LN@col{\def\@LN@column} % v4.22, removed #1.
! 2000: \@LN@col{1}
! 2001:
! 2002: %
! 2003: % \subsection{%
! 2004: % Numbering modulo $m$, starting at $f$
! 2005: %% Numbering modulo 5
! 2006: % \unskip}\label{ss:Mod}
! 2007: %
! 2008: % Most users want to have only one in five lines numbered.
! 2009: % ~\LineNumber~ is supposed to produce the outfit of the
! 2010: % line number attached to the line, while ~\thelinenumber~
! 2011: % is used also for references, which should appear even if
! 2012: % they are not multiples of five.
! 2013: %
! 2014: % (New v4.00) Moreover, some users want to
! 2015: % control which line number should be printed first. Support
! 2016: % of this is now introduced here---see ~\firstlinenumber~
! 2017: % below.---~numline.sty~ by Michael Jaegermann and
! 2018: % James Fortune offers controlling which \emph{final}
! 2019: % line numbers should not be printed. What is
! 2020: % it good for? We ignore this here until some user demands
! 2021: % it.---Peter Wilson's ~ledmac.sty~ offers much different
! 2022: % choices of line numbers to be printed, due to Wayne Sullivan.
! 2023: % (/New v4.00)
! 2024: %
! 2025: % (New v4.22) ~\c@linenumbermodulo~ is rendered a
! 2026: % fake counter, as discussed since v4.00. So it can
! 2027: % no longer be set by ~\setcounter~. ~\modulolinenumbers~
! 2028: % serves this purpose. Well, does anybody want to do
! 2029: % what worked with ~\addtocounter~? (Then please tell
! 2030: % me.)---At least, ~\value~ still works. For the same
! 2031: % purpose I rename the fake `firstlinenumber' counter
! 2032: % ~\n@...~ to ~\c@...~. (/New v4.22)
! 2033: % \begin{old}\begin{verbatim}
! 2034: % % \newcount\c@linenumbermodulo % removed for v4.22
! 2035: % \end{verbatim}
! 2036: % \end{old}
! 2037: %
! 2038: %% Removed for v4.22:
! 2039: %% (UL) On my question why, e.g.,
! 2040: %% ~\chardef~ would not have sufficed, Stephan couldn't remember
! 2041: %% exactly; guessed that he wanted to offer \LaTeX\ counter
! 2042: %% facilities. However, the typical ones don't come this way.
! 2043: %% So I'm quite sure that I will change this next time.
! 2044: %%
! 2045: %% However, I observed at least two times that users gave a very
! 2046: %% high value to ~\c@linenumbermodulo~ in order to suppress
! 2047: %% printing of the line number. One of these users preferred an
! 2048: %% own way of handling line numbers, just wanted to use
! 2049: %% ~\linelabel~ and ~ednotes.sty~ features. Should we support this?
! 2050: %% I rather would like to advise them to
! 2051: %% ~\let\makeLineNumber\relax~. (/UL)
! 2052: %
! 2053: % (New v4.00) \par
! 2054: % ~\themodulolinenumber~ waits for being declared
! 2055: % ~\LineNumber~ by ~\modulolinenumbers~. (This has
! 2056: % been so before, no change.) Here is how it
! 2057: % looked before:
! 2058: % \begin{old}\begin{verbatim}
! 2059: % % \def\themodulolinenumber{{\@tempcnta\c@linenumber
! 2060: % % \divide\@tempcnta\c@linenumbermodulo
! 2061: % % \multiply\@tempcnta\c@linenumbermodulo
! 2062: % % \ifnum\@tempcnta=\c@linenumber\thelinenumber\fi
! 2063: % % }}
! 2064: % \end{verbatim}
! 2065: % \end{old}
! 2066: % (UL) This was somewhat slow. This arithmetic
! 2067: % happens at every line. This time I tend to declare an extra
! 2068: %% TODO v4.4+
! 2069: % line counter (as opposed to my usual recommendations to use
! 2070: % counters as rarely as possible) which is stepped every line.
! 2071: % It could be incremented in the same way as ~\c@LN@truepage~
! 2072: % is incremented via ~\cl@page~! This is another point in favour
! 2073: % of ~{linenumber}~ being a \LaTeX\ counter!
! 2074: % When this new counter equals ~\c@linenumbermodulo~, it is reset,
! 2075: % and ~\thelinenumber~ is executed.---It gets much slower by my
! 2076: % support of controlling the first line number below. I should
! 2077: % improve this.---On
! 2078: %% %% TODO v4.4+--pagewise!?
! 2079: % the other hand, time expense means very little nowadays,
! 2080: % while the number of \TeX\ counters still is limited.
! 2081: %
! 2082: % For the same purpose, moreover, attaching the line number
! 2083: % box could be intercepted earlier (in ~\MakeLineNo~),
! 2084: % without changing ~\LineNumber~. However, this may be
! 2085: % bad for the latter's announcement as a wizard interface
! 2086: % in section_\ref{s:UserCmds}.
! 2087: %%
! 2088: %% I wonder about Stephan's group. Its only effect is that
! 2089: %% ~\@tempcnta~ is restored after using it. What for is this?
! 2090: %% I tend to remove the group braces. %% TODO v4.4+
! 2091: % (/UL)
! 2092: %
! 2093: % Here is the new code. It is very near to my ~lnopatch.sty~
! 2094: % code which introduced the first line number feature
! 2095: % before.---I add starting with a ~\relax~ which is so often
! 2096: % recommended---without understanding this really. At least,
! 2097: % it will not harm.---Former group braces appear as
! 2098: % ~\begingroup~/~\endgroup~ here.
! 2099:
! 2100: \def\themodulolinenumber{\relax
! 2101: \ifnum\c@linenumber<\c@firstlinenumber \else
! 2102: \begingroup
! 2103: \@tempcnta\c@linenumber
! 2104: \advance\@tempcnta-\c@firstlinenumber
! 2105: \divide\@tempcnta\c@linenumbermodulo
! 2106: \multiply\@tempcnta\c@linenumbermodulo
! 2107: \advance\@tempcnta\c@firstlinenumber
! 2108: \ifnum\@tempcnta=\c@linenumber \thelinenumber \fi
! 2109: \endgroup
! 2110: \fi
! 2111: }
! 2112:
! 2113: % (/New v4.00)
! 2114: %
! 2115: % The user command to set the modulo counter:
! 2116: % (New v4.31) \dots\ a star variant is introduced to implement
! 2117: % Hillel Chayim Yisraeli's idea to print the first line number
! 2118: % after an interruption of the edited text by some editor's
! 2119: % text, regardless of the modulo. If it is 1, it is printed only
! 2120: % with ~\firstlinenumber{1}~. I.e., you use ~\modulolinenumbers*~
! 2121: % for the new feature, without the star you get the simpler
! 2122: % behaviour that we have had so far. And you can switch back
! 2123: % from the refined behaviour to the simple one by using
! 2124: % ~\modulolinenumbers~ without the star.---This enhancement
! 2125: % is accompanied by a new package option ~modulo*~ which just
! 2126: % executes ~\modulolinenumbers*~
! 2127: % (subsection_\ref{ss:v3opts}).---`With ~\firstlinenumber{1}~'
! 2128: % exactly means: `1' is printed if and only if the last
! 2129: % ~\firstlinenumber~ before or in the paragraph that follows
! 2130: % the ``interruption'' has argument `1' (or something
! 2131: % \emph{expanding} to `1', or (to) something that \TeX\
! 2132: % ``reads'' as 1, e.g.: a \TeX\ count register storing
! 2133: % 1).---At present, this behaviour may be unsatisfactory with
! 2134: % pagewise line-numbering $\dots$ I'll make an experimental
! 2135: % extra package if someone complains \dots
! 2136:
! 2137: \newcommand\modulolinenumbers{%
! 2138: \@ifstar
! 2139: {\def\@LN@maybe@moduloresume{%
! 2140: \global\let\@LN@maybe@normalLineNumber
! 2141: \@LN@normalLineNumber}%
! 2142: \@LN@modulolinenos}%
! 2143: {\let\@LN@maybe@moduloresume\relax \@LN@modulolinenos}%
! 2144: }
! 2145:
! 2146: \global\let\@LN@maybe@normalLineNumber\relax
! 2147: \let\@LN@maybe@moduloresume\relax
! 2148: \gdef\@LN@normalLineNumber{%
! 2149: \ifnum\c@linenumber=\c@firstlinenumber \else
! 2150: \ifnum\c@linenumber>\@ne
! 2151: \def\LineNumber{\thelinenumber}%
! 2152: \fi
! 2153: \fi
! 2154: %%
! 2155: % ~\def~ instead of ~\let~ enables taking account of a
! 2156: % redefinition of ~\thelinenumber~ in a present numbering
! 2157: % environment (e.g.).
! 2158: %%
! 2159: \global\let\@LN@maybe@normalLineNumber\relax}
! 2160:
! 2161: % Instead of changing ~\LineNumber~ directly by
! 2162: % ~LN@moduloresume~, these tricks enable ~\modulolinenumbers*~
! 2163: % to act as locally as I can make it. I don't know how to
! 2164: % avoid that the output routine switches back to the normal
! 2165: % modulo behaviour by a global change. (An ~\aftergroup~ may
! 2166: % fail in admittedly improbable cases.)
! 2167:
! 2168: \newcommand*\@LN@modulolinenos[1][\z@]{%
! 2169: %%
! 2170: % The definition of this macro is that of the former
! 2171: % ~\modulolinenumbers~. (/New v4.31)
! 2172: %%
! 2173: \let\LineNumber\themodulolinenumber
! 2174: \ifnum#1>\@ne
! 2175: \chardef % v4.22, note below
! 2176: \c@linenumbermodulo#1\relax
! 2177: \else\ifnum#1=\@ne
! 2178: % \begin{old}\begin{verbatim}
! 2179: % % \def\LineNumber{\thelinenumber}%
! 2180: % \end{verbatim}
! 2181: % \end{old}
! 2182: % (New v4.00) I am putting something here to enable
! 2183: % ~\firstlinenumber~ with $~\c@linenumbermodulo~=1$.
! 2184: % With ~lnopatch.sty~, a trick was offered for this purpose.
! 2185: % It is now obsolete.
! 2186: %
! 2187: \def\LineNumber{\@LN@ifgreat\thelinenumber}%
! 2188: %%
! 2189: % (/New v4.00)
! 2190: %%
! 2191: \fi\fi
! 2192: }
! 2193:
! 2194: % (New v4.00) The default of ~\@LN@ifgreat~ is
! 2195:
! 2196: \let\@LN@ifgreat\relax
! 2197:
! 2198: % The previous changes as soon as ~\firstlinenumber~ is used:
! 2199:
! 2200: \newcommand*\firstlinenumber[1]{%
! 2201: \chardef\c@firstlinenumber#1\relax
! 2202: %%
! 2203: % No counter, little values allowed only---OK?---(UL)
! 2204: % The change is local---OK? The good thing is that
! 2205: % ~\global\firstlinenumber{~<number>~}~ works. Moreover,
! 2206: % ~\modulolinenumbers~ acts locally as well. (/UL)
! 2207: %
! 2208: % (New v4.31)
! 2209: %%
! 2210: \let\@LN@ifgreat\@LN@ifgreat@critical}
! 2211:
! 2212: \def\@LN@ifgreat@critical{%
! 2213: \ifnum\c@linenumber<\c@firstlinenumber
! 2214: \expandafter \@gobble
! 2215: \fi}%
! 2216:
! 2217: % (/New v4.31)
! 2218: %
! 2219: % The default
! 2220: % value of ~\c@firstlinenumber~ %% v4.31
! 2221: % is 0. This is best for what one would expect from modulo
! 2222: % printing.
! 2223:
! 2224: \let\c@firstlinenumber=\z@
! 2225:
! 2226: %
! 2227: % For usage and effects of ~\modulolinenumbers~ and %% v4.31
! 2228: % ~\firstlinenumbers~, please consult section_\ref{s:UserCmds}.
! 2229: % Two details on ~\firstlinenumbers~ here:
! 2230: % (i)_~\firstlinenumber~ acts on a paragraph if and only if
! 2231: % (a)_the paragraph is broken into lines ``in line-numbering
! 2232: % mode'' (after ~\linenumbers~, e.g.);
! 2233: % (b)_it is the last occurrence of a ~\firstlinenumbers~
! 2234: % before or in the paragraph.
! 2235: % (The practical applications of this that I can imagine
! 2236: % don't seem appealing to me.)
! 2237: % Cf._the explanation above of how ~\modulolinenumbers~ and
! 2238: % ~\firstlinenumbers~ interact---for this and for (ii),
! 2239: % which is concerned with possible arguments for
! 2240: % ~\firstlinenumbers~.
! 2241: %
! 2242: % Note that the line numbers of the present section
! 2243: % demonstrate the two devices. (/New v4.00)
! 2244:
! 2245: %%\setcounter{linenumbermodulo}{5}
! 2246: \chardef\c@linenumbermodulo=5 % v4.2; ugly?
! 2247: \modulolinenumbers[1]
! 2248:
! 2249: % (New v4.22) The new implementation through ~\chardef~
! 2250: % decreases the functionality and raises certain compatibility
! 2251: % problems. I face this without fear. The maximum modulo value
! 2252: % is now ~255~. I expect that this suffices for usual applications.
! 2253: % However, some users have ``abused'' ~lineno.sty~ to get
! 2254: % ~ednotes.sty~ features without line numbers, so have set the
! 2255: % modulo to a value beyond the total number of lines in their
! 2256: % edition. This ought to be replaced by
! 2257: % ~\let\makeLineNumber\relax~. (/New v4.22)
! 2258: %
! 2259: % \section{%
! 2260: % Package options
! 2261: % \unskip}\label{s:Opts}
! 2262: %
! 2263: % (New v4.1)
! 2264: % The last heading formerly was the heading of what is now
! 2265: % subsection_\ref{ss:v3opts}. The options declared there were
! 2266: % said to execute user commands only. This was wrong already
! 2267: % concerning ~displaymath~ and ~hyperref~. At least, however,
! 2268: % these options were no or almost no occasion to skip definitions
! 2269: % or allocations. This is different with the options that we now
! 2270: % insert.
! 2271: %
! 2272: %% (New v4.2) v4.00 moved the ``options'' below the
! 2273: %% ``extensions''. This was bad with ~\do@mlineno~ in
! 2274: %% subsection_\ref{ss:v3opts} which is to control
! 2275: %% subsection_\ref{ss:display}---undone here. (/New v4.2)
! 2276: %
! 2277: % \subsection{%
! 2278: % Extended referencing to line numbers. (v4.2)
! 2279: % \unskip}
! 2280: % This subsection explains and declares package option ~addpageno~. %% v4.31
! 2281: %
! 2282: % If a line to whose number you refer by ~\ref~ is not on the
! 2283: % present page, it may be useful to add the number of the page
! 2284: % on which the line occurs---and perhaps it should not be added
! 2285: % otherwise. In general, you could use the Standard \LaTeX\
! 2286: % package varioref for this. However, the latter usually
! 2287: % produces verbose output like `on the preceding page'---
! 2288: % unless costumized---, while in critical editions, e.g., one
! 2289: % may prefer just adding the page number and some mark on the
! 2290: % left of the line number, irrespectively of how far the page is
! 2291: % apart etc. To support this, package option ~addpageno~
! 2292: % provides a command ~\vpagelineref~ to be used in place of
! 2293: % ~\ref~. This produces, e.g., `34.15' when referring to line_15
! 2294: % on page_34 while the present page is not 34. You can customize
! 2295: % the outcome, see the package file ~vplref.sty~ where the code
! 2296: % and further details are. You may conceive of
! 2297: % ~\vpagelineref~ as a certain customization of varioref's
! 2298: % ~\vref~.
! 2299: %
! 2300: % This implies that option ~addpageno~ requires the files
! 2301: % ~vplref.sty~ and ~varioref.sty~. ~addpageno~ automatically
! 2302: % loads both of them. Yet you can also load ~varioref.sty~
! 2303: % on your own to use its package options.
! 2304: %
! 2305: % Of course, you might better introduce a shorter command name
! 2306: % for ~\vpagelineref~ for your work, while we cannot predict
! 2307: % here what shorthand will fit your work. E.g.,
! 2308: % ~\newcommand{\lref}{\vpagelineref}~.
! 2309: %
! 2310: % If you really want to add the page number in \emph{any} case,
! 2311: % use, e.g., some ~\myref~ instead of ~\ref~, after
! 2312: % \[~newcommand*{\myref}{\pageref{#1}.\ref{#1}}~\]
! 2313: % or what you like. You don't need the ~addpageno~ option in
! 2314: % this case.
! 2315: %
! 2316: % ~addpageno~ is due to a suggestion by Sergei Mariev.
! 2317:
! 2318: \DeclareOption{addpageno}{%
! 2319: \AtEndOfPackage{\RequirePackage{vplref}[2005/04/25]}}
! 2320:
! 2321: % \subsection{%
! 2322: % \scs{linelabel} in math mode
! 2323: % \unskip}\label{ss:MathRef}
! 2324: %
! 2325: % We have made some first steps towards allowing ~\linelabel~ in
! 2326: % math mode. Because our code for this is presently experimental,
! 2327: % we leave it to the user to decide for the experiment by calling
! 2328: % option ~mathrefs~. We are in a hurry now and thus leave the
! 2329: % code, explanations, and discussion in the separate package
! 2330: % ~ednmath0.sty~. Maybe we later find the time to improve the
! 2331: % code and move the relevant content of ~ednmath0.sty~ to here.
! 2332: % The optimal situation would be to define ~\linelabel~ from
! 2333: % the start so it works in math mode, omitting the ~mathrefs~
! 2334: % option.
! 2335: %
! 2336: % Actually, this package even provides adjustments for analogously
! 2337: % allowing ~ednotes.sty~ commands in math mode. Loading the package
! 2338: % is postponed to ~\AtBeginDocument~ when we know whether these
! 2339: % adjustments are needed.
! 2340:
! 2341: \DeclareOption{mathrefs}{\AtBeginDocument
! 2342: {\RequirePackage{ednmath0}[2004/08/20]}}
! 2343:
! 2344: %
! 2345: % \subsection{%
! 2346: % Arrays, tabular environments (Revised v4.11)
! 2347: % \unskip}\label{ss:Tab}
! 2348: %
! 2349: % This subsection explains and declares package options %% v4.31
! 2350: % ~edtable~, ~longtable~, and ~nolongtablepatch~.
! 2351: %
! 2352: % The standard \LaTeX\ tabular environments come as single
! 2353: % boxes, so the ~lineno.sty~ versions before v4.00 treated them as
! 2354: % (parts of) single lines, printing (at most) one line number
! 2355: % beside each and stepping the line number counter once only.
! 2356: % Moreover, ~\linelabel~s got lost. Of course, tables are
! 2357: % usually so high that you will want to treat each row like a
! 2358: % line. (Christian Tapp even desires that the lines of table
! 2359: % entries belonging to a single row are treated like ordinary
! 2360: % lines.) Footnotes get lost in such environments as well, which
! 2361: % was bad for ~ednotes.sty~.
! 2362: %
! 2363: % We provide adjustments to count lines, print their numbers
! 2364: % etc.\ as desired at least for \emph{some} \LaTeX\ tabular
! 2365: % environments. (Like with other details, ``some'' is to some
! 2366: % extent explained in ~edtable.sty~.) We do this similarly as
! 2367: % with option ~mathrefs~ before. We leave code
! 2368: % and explanations in the separate package ~edtable.sty~.
! 2369: % (For wizards: this package provides adjustments for
! 2370: % ~ednotes.sty~ as well. However, in the present case we don't try
! 2371: % to avoid them unless ~ednotes.sty~ is loaded.)
! 2372: % Package option ~edtable~
! 2373: % defines---by loading ~edtable.sty~---an environment ~{edtable}~
! 2374: % which is able to change some \LaTeX\ tabular environments
! 2375: % with the desired effects. (v4.11: ~edtable.sty~ v1.3 counts
! 2376: % \LaTeX's ~{array}~ [etc.\@] as a ``tabular environment'' as
! 2377: % well.)
! 2378: %
! 2379: % The ~{edtable}~ environment doesn't help with ~longtable.sty~,
! 2380: % however. To make up for this, ~{longtable}~ is adjusted in a
! 2381: % different way---and this happens only when another ~lineno.sty~
! 2382: % option ~longtable~ is called. In this case, option ~edtable~
! 2383: % needn't be called explicitly: option ~longtable~ works as if
! 2384: % ~edtable~ had been called.
! 2385: %
! 2386: % Now, we are convinced that vertical spacing around
! 2387: % ~{longtable}~ works wrongly---see \LaTeX\ bugs database
! 2388: % tools/3180 and 3485, or see explanations in the package
! 2389: % ~ltabptch.sty~ (which is to be obtained from CTAN folder
! 2390: % \path{macros/latex/ltabptch}). Our conviction is so strong
! 2391: % that the ~longtable~ option loads---after ~longtable.sty~---the
! 2392: % patch package ~ltabptch.sty~. If the user doesn't want this
! 2393: % (maybe preferring her own arrangement with the vertical
! 2394: % spacing), she can forbid it by calling ~nolongtablepatch~.
! 2395: %
! 2396: % The following code just collects some choices, which are
! 2397: % then executed in section_\ref{ss:ExOpt}. We use an ~\if...~
! 2398: % without ~\newif~ since ~\if...true~ and ~\if...false~
! 2399: % would occur at most two times and only within the present
! 2400: % package. (~\AtEndOfClass{\RequirePackage{edtable}}~
! 2401: % could be used instead, I just overlooked this. Now I don't
! 2402: % change it because it allows to change the version requirement
! 2403: % at one place only.)
! 2404:
! 2405: \let\if@LN@edtable\iffalse
! 2406:
! 2407: \DeclareOption{edtable}{\let\if@LN@edtable\iftrue}
! 2408:
! 2409: \DeclareOption{longtable}{\let\if@LN@edtable\iftrue
! 2410: \PassOptionsToPackage{longtable}{edtable}}
! 2411:
! 2412: \DeclareOption{nolongtablepatch}{%
! 2413: \PassOptionsToPackage{nolongtablepatch}{edtable}}
! 2414:
! 2415: % (/New v4.1)
! 2416: %
! 2417: % \subsection{%
! 2418: % Switch among settings
! 2419: % \unskip}\label{ss:v3opts}
! 2420: %
! 2421: % There is a bunch of package options that execute %% v4.2
! 2422: %% There is a bunch of package options, all of them executing
! 2423: %% executing only user commands (see below). %% Cf. start of section.
! 2424: % user commands only.
! 2425: %
! 2426: % Options ~left~ (~right~) put the line numbers on the left
! 2427: % (right) margin. This works in all modes. ~left~ is the
! 2428: % default.
! 2429:
! 2430: \DeclareOption{left}{\leftlinenumbers*}
! 2431:
! 2432: \DeclareOption{right}{\rightlinenumbers*}
! 2433:
! 2434: % Option ~switch~ (~switch*~) puts the line numbers on the
! 2435: % outer (inner) margin of the text. This requires running
! 2436: % the pagewise mode, but we turn off the page offset
! 2437: % subtraction, getting sort of running numbers again. The
! 2438: % ~pagewise~ option may restore true pagewise mode later.
! 2439:
! 2440: \DeclareOption{switch}{\setpagewiselinenumbers
! 2441: \switchlinenumbers
! 2442: \runningpagewiselinenumbers}
! 2443:
! 2444: \DeclareOption{switch*}{\setpagewiselinenumbers
! 2445: \switchlinenumbers*%
! 2446: \runningpagewiselinenumbers}
! 2447:
! 2448: % In twocolumn mode, we can switch the line numbers to
! 2449: % the outer margin, and/or start with number 1 in each
! 2450: % column. Margin switching is covered by the ~switch~
! 2451: % options.
! 2452:
! 2453: \DeclareOption{columnwise}{\setpagewiselinenumbers
! 2454: \columnwiselinenumberstrue
! 2455: \realpagewiselinenumbers}
! 2456:
! 2457: % The options ~pagewise~ and ~running~ select the major
! 2458: % linenumber mechanism. ~running~ line numbers refer to a real
! 2459: % counter value, which can be reset for any paragraph,
! 2460: % even getting multiple paragraphs on one page starting
! 2461: % with line number one. ~pagewise~ line numbers get a
! 2462: % unique hidden number within the document, but with the
! 2463: % opportunity to establish the page on which they finally
! 2464: % come to rest. This allows the subtraction of the page
! 2465: % offset, getting the numbers starting with 1 on top of each
! 2466: % page, and margin switching in twoside formats becomes
! 2467: % possible. The default mode is ~running~.
! 2468: %
! 2469: % The order of declaration of the options is important here
! 2470: % ~pagewise~ must come after ~switch~, to overide running
! 2471: % pagewise mode. ~running~ comes last, to reset the running
! 2472: % line number mode, e.g, after selecting margin switch mode
! 2473: % for ~pagewise~ running. Once more, if you specify all
! 2474: % three of the options ~[switch,pagewise,running]~, the
! 2475: % result is almost nothing, but if you later say
! 2476: % ~\pagewiselinenumbers~, you get margin switching, with
! 2477: % real pagewise line numbers.
! 2478: %
! 2479: \DeclareOption{pagewise}{\setpagewiselinenumbers
! 2480: \realpagewiselinenumbers}
! 2481:
! 2482: \DeclareOption{running}{\setrunninglinenumbers}
! 2483:
! 2484: % The option ~modulo~ causes only those linenumbers to be
! 2485: % printed which are multiples of five.
! 2486:
! 2487: \DeclareOption{modulo}{\modulolinenumbers\relax}
! 2488:
! 2489: % Option ~modulo*~ modifies ~modulo~ in working like
! 2490: % ~\modulolinenumbers*~---see section_\ref{s:UserCmds}.
! 2491:
! 2492: \DeclareOption{modulo*}{\modulolinenumbers*\relax}
! 2493:
! 2494: % The package option ~mathlines~ switches the behavior of
! 2495: % the ~{linenomath}~ environment with its star-form.
! 2496: % Without this option, the ~{linenomath}~ environment does
! 2497: % not number the lines of the display, while the star-form
! 2498: % does. With this option, its just the opposite.
! 2499: %
! 2500: %%% 1999-06-10: renamed ~displaymath~ to ~mathlines~.
! 2501:
! 2502: \DeclareOption{mathlines}{\linenumberdisplaymath}
! 2503:
! 2504: % ~displaymath~ now calls for wrappers of the standard
! 2505: % \LaTeX\ display math environment. This was previously
! 2506: % done by ~mlineno.sty~.
! 2507: %
! 2508: % (New v4.3) Option `displaymath' becomes default according
! 2509: % to Erik \mbox{Luijten}'s suggestion. I was finally convinced
! 2510: % of this as soon as I discovered how to avoid a spurious line
! 2511: % number above ~\begin{linenomath}~ (subsection_\ref{ss:DM}).
! 2512: % ~\endlinenomath~ provides ~\ignorespaces~, so what could go
! 2513: % wrong now?
! 2514:
! 2515: \DeclareOption{displaymath}{\PackageWarningNoLine{lineno}{%
! 2516: Option [displaymath] is obsolete -- default now!}}
! 2517: %%
! 2518: %%\let\do@mlineno\relax
! 2519: %%\DeclareOption{displaymath}{\let\do@mlineno\@empty}
! 2520: % (/New v4.3)
! 2521: %
! 2522: % \subsection{%
! 2523: % Compatibility with \texttt{hyperref} %% own subsec. v4.3.
! 2524: % \unskip}
! 2525: % The ~hyperref~ package, via ~nameref~, requires three more
! 2526: % groups in the second argment of a ~\newlabel~. Well, why
! 2527: % shouldn't it get them? (New v3.07) The presence of the
! 2528: % ~nameref~ package is now detected automatically
! 2529: % ~\AtBeginDocument~. (/New v3.07) (Fixed in v3.09) We try
! 2530: % to be smart, and test ~\AtBeginDocument~ if the ~nameref~
! 2531: % package is loaded, but ~hyperref~ postpones the loading of
! 2532: % ~nameref~ too, so this is all in vain.
! 2533: %
! 2534: % (New v4.3) But we can also test at the first ~\linelabel~.
! 2535: % Regarding the error-message for misplaced ~\linelabel~ from v4.11:
! 2536: % previously, ~\linenumbers~ rendered ~\linelabel~ the genuine
! 2537: % version of ~\linelabel~ from the start on. This doesn't work
! 2538: % now, since ~\@LN@linelabel~ may change its meaning after the
! 2539: % first ~\linenumbers~ and before a next one (if there is some).
! 2540: % (/New v4.3)
! 2541:
! 2542: \DeclareOption{hyperref}{\PackageWarningNoLine{lineno}{%
! 2543: Option [hyperref] is obsolete.
! 2544: \MessageBreak The hyperref package is detected automatically.}}
! 2545:
! 2546: \AtBeginDocument{%
! 2547: \@ifpackageloaded{nameref}{%
! 2548: %%
! 2549: % (New v4.3) ``Global'' is merely ``symbolic'' ~\AtBeginDoc...~.
! 2550: % If ~nameref~ is not detected here, the next ~\@LN@linelabel~
! 2551: % will do almost the same, then globally indeed.
! 2552: %%
! 2553: \gdef\@LN@ExtraLabelItems{{}{}{}}%
! 2554: }{%
! 2555: \global\let\@LN@@linelabel\@LN@linelabel
! 2556: \gdef\@LN@linelabel{%
! 2557: %%
! 2558: % ~\@ifpackageloaded~ is ``preamble only'', its---very
! 2559: % internal---preamble definition is replicated here:
! 2560: %%
! 2561: \expandafter
! 2562: \ifx\csname ver@nameref.sty\endcsname\relax \else
! 2563: \gdef\@LN@ExtraLabelItems{{}{}{}}%
! 2564: \fi
! 2565: %%
! 2566: % Now aim at the ``usual'' behaviour:
! 2567: %%
! 2568: \global\let\@LN@linelabel\@LN@@linelabel
! 2569: \global\let\@LN@@linelabel\relax
! 2570: \@LN@linelabel
! 2571: }%
! 2572: }%
! 2573: }
! 2574:
! 2575: % (/New v4.3)
! 2576: %
! 2577: % (New v4.1)
! 2578: % \subsection{%
! 2579: % A note on calling so many options
! 2580: % \unskip}
! 2581: %
! 2582: % The number of package options may stimulate worrying about how to
! 2583: % \emph{enter} all the options that one would like to use---they may
! 2584: % not fit into one line. Fortunately, you can safely break code lines
! 2585: % after the commas separating the option names in the ~\usepackage~
! 2586: % command (no comment marks needed).
! 2587: %
! 2588: % \subsection{%
! 2589: % Execute options
! 2590: % \unskip}\label{ss:ExOpt}
! 2591: %
! 2592: % We stop declaring options and execute the ones that are
! 2593: % called by the user. (/New v4.1)
! 2594:
! 2595: \ProcessOptions
! 2596:
! 2597: % (New v4.1) Now we know whether ~edtable.sty~ is wanted
! 2598: % and (if it is) with which options it is to be called.
! 2599:
! 2600: \if@LN@edtable \RequirePackage{edtable}[2005/03/07] \fi
! 2601:
! 2602: % (/New v4.1)
! 2603: %
! 2604: % \section{%
! 2605: % Former package extensions
! 2606: % \label{s:Xt}\unskip}
! 2607: %
! 2608: % The extensions in this section were previously supplied
! 2609: % in separate ~.sty~ files.
! 2610: %
! 2611: % \subsection{%
! 2612: % $display math$
! 2613: % \unskip}\label{ss:display}
! 2614: %% (New v4.32)
! 2615: % (New v4.3) From now on, you no longer need to type
! 2616: % the ~{linenomath}~ environment with the ~\[~, ~{equation}~,
! 2617: % and ~{eqnarray}~ environments---and you no longer need to
! 2618: % use the former package option ~displaymath~ for this feature.
! 2619: % (/New v4.3)
! 2620: %% (/New v4.32)
! 2621: %
! 2622: % The standard \LaTeX\ display math environments are
! 2623: % wrapped in a ~{linenomath}~ environment.
! 2624: %
! 2625: % (New 3.05) The ~[fleqn]~ option of the standard
! 2626: % \LaTeX\ classes defines the display math
! 2627: % environments such that line numbers appear just
! 2628: % fine. Thus, we need not do any tricks when
! 2629: % ~[fleqn]~ is loaded, as indicated by presents of
! 2630: % the ~\mathindent~ register. (/New 3.05)
! 2631: %
! 2632: % (New 3.05a) for ~{eqnarray}~s we rather keep the
! 2633: % old trick. (/New 3.05a)
! 2634: %
! 2635: % (New 3.08) Wrap ~\[~ and ~\]~ into ~{linenomath}~,
! 2636: % instead of ~{displaymath}~. Also save the definition
! 2637: % of ~\equation~, instead of replicating the current
! 2638: % \LaTeX\ definition. (/New 3.08)
! 2639:
! 2640: %%\ifx\do@mlineno\@empty
! 2641: \@ifundefined{mathindent}{
! 2642:
! 2643: %% \AtBeginDocument{%
! 2644: \let\LN@displaymath\[%
! 2645: \let\LN@enddisplaymath\]%
! 2646: \renewcommand\[{\begin{linenomath}\LN@displaymath}%
! 2647: \renewcommand\]{\LN@enddisplaymath\end{linenomath}}%
! 2648: %
! 2649: \let\LN@equation\equation
! 2650: \let\LN@endequation\endequation
! 2651: \renewenvironment{equation}%
! 2652: {\linenomath\LN@equation}%
! 2653: {\LN@endequation\endlinenomath}%
! 2654: %% }
! 2655:
! 2656: }{}% \@ifundefined{mathindent} -- 3rd arg v4.2, was \par!
! 2657:
! 2658: %%\AtBeginDocument{%
! 2659: \let\LN@eqnarray\eqnarray
! 2660: \let\LN@endeqnarray\endeqnarray
! 2661: \renewenvironment{eqnarray}%
! 2662: {\linenomath\LN@eqnarray}%
! 2663: {\LN@endeqnarray\endlinenomath}%
! 2664: %%}
! 2665:
! 2666: %%\fi
! 2667:
! 2668: % (UL) Indeed. The \LaTeX\ macros are saved for
! 2669: % unnumbered mode, which is detected by ~\linenomath~.
! 2670: % (/UL)
! 2671: %
! 2672: % \subsection{%
! 2673: % Line numbers in internal vertical mode
! 2674: % \unskip}\label{ss:ILN}
! 2675: %
! 2676: % The command ~\internallinenumbers~ adds line numbers in
! 2677: % internal vertical mode, but with limitations: we assume
! 2678: % fixed baseline skip.
! 2679: %
! 2680: % (v4.22) v3.10 provided a global (~\global\advance~)
! 2681: % as well as a local version (star-form, using
! 2682: % ~\c@internallinenumber~). ~\resetlinenumbers~ acted
! 2683: % locally and was here used with the global version---save
! 2684: % stack danger, \TeX book p._301---in v4.00 I
! 2685: % disabled the global version therefore. Now I find that
! 2686: % it is better to keep a global version, and the now global
! 2687: % ~\resetlinenumbers~ is perfect for this. The global version
! 2688: % allows continuing the ``internal'' numbers in the ensuing
! 2689: % ``external'' text, and---unless reset by brackets
! 2690: % argument---continuing the above series of line numbers.
! 2691: % As with v3.10, the local version always starts with
! 2692: % line number one. A new ~\@LN@iglobal~ steps ~\global~ly
! 2693: % in the global version, otherwise it is ~\relax~.
! 2694: % (I also remove all my stupid discussions as of v4.00.
! 2695: % And I use ~\newcommand~.) (v4.22)
! 2696:
! 2697: \let\@LN@iglobal\global % v4.22
! 2698:
! 2699: \newcommand\internallinenumbers{\setrunninglinenumbers
! 2700: \let\@@par\internallinenumberpar
! 2701: \ifx\@par\@@@par\let\@par\internallinenumberpar\fi
! 2702: \ifx\par\@@@par\let\par\internallinenumberpar\fi
! 2703: \ifx\@par\linenumberpar\let\@par\internallinenumberpar\fi
! 2704: \ifx\par\linenumberpar\let\par\internallinenumberpar\fi
! 2705: \@ifnextchar[{\resetlinenumber}%]
! 2706: {\@ifstar{\let\c@linenumber\c@internallinenumber
! 2707: \let\@LN@iglobal\relax % v4.22
! 2708: \c@linenumber\@ne}{}}%
! 2709: }
! 2710:
! 2711: \let\endinternallinenumbers\endlinenumbers
! 2712: \@namedef{internallinenumbers*}{\internallinenumbers*}
! 2713: \expandafter\let\csname endinternallinenumbers*\endcsname\endlinenumbers
! 2714:
! 2715: \newcount\c@internallinenumber
! 2716: \newcount\c@internallinenumbers
! 2717:
! 2718: \newcommand\internallinenumberpar{%
! 2719: \ifvmode\@@@par\else\ifinner\@@@par\else\@@@par
! 2720: \begingroup
! 2721: \c@internallinenumbers\prevgraf
! 2722: \setbox\@tempboxa\hbox{\vbox{\makeinternalLinenumbers}}%
! 2723: \dp\@tempboxa\prevdepth
! 2724: \ht\@tempboxa\z@
! 2725: \nobreak\vskip-\prevdepth
! 2726: \nointerlineskip\box\@tempboxa
! 2727: \endgroup
! 2728: \fi\fi
! 2729: }
! 2730:
! 2731: \newcommand\makeinternalLinenumbers{%
! 2732: \ifnum\c@internallinenumbers>\z@ % v4.2
! 2733: \hb@xt@\z@{\makeLineNumber}%
! 2734: \@LN@iglobal % v4.22
! 2735: \advance\c@linenumber\@ne
! 2736: \advance\c@internallinenumbers\m@ne
! 2737: \expandafter\makeinternalLinenumbers\fi
! 2738: }
! 2739: % TODO v4.4+: star: line numbers right!? cf. lnocapt.sty
! 2740:
! 2741: %
! 2742: % \subsection{%
! 2743: % Line number references with offset
! 2744: % \unskip}
! 2745: %
! 2746: % This extension defines macros to refer to line
! 2747: % numbers with an offset, e.g., to refer to a line
! 2748: % which cannot be labeled directly (display math).
! 2749: % This was formerly knows as ~rlineno.sty~.
! 2750: %
! 2751: % To refer to a pagewise line number with offset:
! 2752: % \begin{quote}
! 2753: % ~\linerefp[~<OFFSET>~]{~<LABEL>~}~
! 2754: % \end{quote}
! 2755: % To refer to a running line number with offset:
! 2756: % \begin{quote}
! 2757: % ~\linerefr[~<OFFSET>~]{~<LABEL>~}~
! 2758: % \end{quote}
! 2759: % To refer to a line number labeled in the same mode as currently
! 2760: % selected:
! 2761: % \begin{quote}
! 2762: % ~\lineref[~<OFFSET>~]{~<LABEL>~}~
! 2763: % \end{quote}
! 2764:
! 2765: \newcommand\lineref{%
! 2766: \ifx\c@linenumber\c@runninglinenumber
! 2767: \expandafter\linerefr
! 2768: \else
! 2769: \expandafter\linerefp
! 2770: \fi
! 2771: }
! 2772:
! 2773: \newcommand*\linerefp[2][\z@]{{%
! 2774: \let\@thelinenumber\thelinenumber
! 2775: \edef\thelinenumber{\advance\c@linenumber#1\relax
! 2776: \noexpand\@thelinenumber}%
! 2777: \ref{#2}%
! 2778: }}
! 2779:
! 2780: % This goes deep into \LaTeX's internals.
! 2781:
! 2782: \newcommand*\linerefr[2][\z@]{{%
! 2783: \def\@@linerefadd{\advance\c@linenumber#1}%
! 2784: \expandafter\@setref\csname r@#2\endcsname
! 2785: \@linerefadd{#2}%
! 2786: }}
! 2787:
! 2788: \newcommand*\@linerefadd[2]{\c@linenumber=#1\@@linerefadd\relax
! 2789: \thelinenumber}
! 2790:
! 2791: %% TODO v4.4+: Insert `LN' in internal command names?
! 2792: %
! 2793: % \subsection{%
! 2794: % Numbered quotation environments
! 2795: % \unskip}
! 2796: %
! 2797: % The ~{numquote}~ and ~{numquotation}~
! 2798: % environments are like ~{quote}~ and
! 2799: % ~{quotation}~, except there will be line
! 2800: % numbers.
! 2801: %
! 2802: % An optional argument gives the number to count
! 2803: % from. A star ~*~ (inside or outside the closing
! 2804: % ~}~) prevent the reset of the line numbers.
! 2805: % Default is to count from one.
! 2806: %
! 2807: % (v4.22: A local version using ~\c@internallinenumber~
! 2808: % might be useful, see subsection_\ref{ss:ILN}.) %% TODO v4.4+
! 2809:
! 2810: \newcommand\quotelinenumbers
! 2811: {\@ifstar\linenumbers{\@ifnextchar[\linenumbers{\linenumbers*}}}
! 2812:
! 2813: \newdimen\quotelinenumbersep
! 2814: \quotelinenumbersep=\linenumbersep
! 2815: \let\quotelinenumberfont\linenumberfont
! 2816:
! 2817: \newcommand\numquotelist
! 2818: {\leftlinenumbers
! 2819: \linenumbersep\quotelinenumbersep
! 2820: \let\linenumberfont\quotelinenumberfont
! 2821: \addtolength{\linenumbersep}{-\@totalleftmargin}%
! 2822: \quotelinenumbers
! 2823: }
! 2824:
! 2825: \newenvironment{numquote} {\quote\numquotelist}{\endquote}
! 2826: \newenvironment{numquotation} {\quotation\numquotelist}{\endquotation}
! 2827: \newenvironment{numquote*} {\quote\numquotelist*}{\endquote}
! 2828: \newenvironment{numquotation*}{\quotation\numquotelist*}{\endquotation}
! 2829:
! 2830: %
! 2831: % \subsection{%
! 2832: % Frame around a paragraph
! 2833: % \unskip}
! 2834: %
! 2835: % The ~{bframe}~ environment draws a frame around
! 2836: % some text, across page breaks, if necessary.
! 2837: %
! 2838: % This works only for plain text paragraphs,
! 2839: % without special height lines. All lines must be
! 2840: % ~\baselineskip~ apart, no display math.
! 2841:
! 2842: \newenvironment{bframe}
! 2843: {\par
! 2844: \@tempdima\textwidth
! 2845: \advance\@tempdima 2\bframesep
! 2846: \setbox\bframebox\hb@xt@\textwidth{%
! 2847: \hskip-\bframesep
! 2848: \vrule\@width\bframerule\@height\baselineskip\@depth\bframesep
! 2849: \advance\@tempdima-2\bframerule
! 2850: \hskip\@tempdima
! 2851: \vrule\@width\bframerule\@height\baselineskip\@depth\bframesep
! 2852: \hskip-\bframesep
! 2853: }%
! 2854: \hbox{\hskip-\bframesep
! 2855: \vrule\@width\@tempdima\@height\bframerule\@depth\z@}%
! 2856: \nointerlineskip
! 2857: \copy\bframebox
! 2858: \nobreak
! 2859: \kern-\baselineskip
! 2860: \runninglinenumbers
! 2861: \def\makeLineNumber{\copy\bframebox\hss}%
! 2862: }
! 2863: {\par
! 2864: \kern-\prevdepth
! 2865: \kern\bframesep
! 2866: \nointerlineskip
! 2867: \@tempdima\textwidth
! 2868: \advance\@tempdima 2\bframesep
! 2869: \hbox{\hskip-\bframesep
! 2870: \vrule\@width\@tempdima\@height\bframerule\@depth\z@}%
! 2871: }
! 2872:
! 2873: \newdimen\bframerule
! 2874: \bframerule=\fboxrule
! 2875:
! 2876: \newdimen\bframesep
! 2877: \bframesep=\fboxsep
! 2878:
! 2879: \newbox\bframebox
! 2880:
! 2881: %
! 2882: %
! 2883: % \section{%
! 2884: % Move \scs{vadjust} items (New v4.00)
! 2885: % \unskip}\label{s:MVadj}
! 2886: %
! 2887: % This section completes reviving ~\pagebreak~, ~\nopagebreak~,
! 2888: % ~\vspace~, and the star and optional form of ~\\~. This was
! 2889: % started in section_\ref{ss:output} and resumed in
! 2890: % section_\ref{ss:MLN} and subsection_\ref{ss:calls}.
! 2891: % The problem was explained in section_\ref{ss:output}:
! 2892: % ~\vadjust~ items come out at a bad position, and the
! 2893: % \LaTeX\ commands named before work with ~\vadjust~ indeed.
! 2894: % Our solution was sketched there as well.
! 2895: %
! 2896: % According to the caveat in subsection_\ref{ss:OnOff} concerning
! 2897: % ~\ifLineNumbers~, the \LaTeX\ commands enumerated may go
! 2898: % wrong if you switch line numbering inside or at the end of
! 2899: % a paragraph.
! 2900: %% %% TODO v4.4+
! 2901: %
! 2902: % \subsection{%
! 2903: % Redefining \scs{vadjust}
! 2904: % \unskip}\label{ss:PVadj}
! 2905: %
! 2906: % ~\vadjust~ will temporarily be changed into the following
! 2907: % command.
! 2908:
! 2909: \def\PostponeVadjust#1{%
! 2910: \global\let\vadjust\@LN@@vadjust
! 2911: %%
! 2912: % This undoes a ~\global\let\vadjust\PostponeVadjust~ which will
! 2913: % start each of the refined \LaTeX\ commands. The ~\global~s
! 2914: % are most probably superfluous. They might be useful should one
! 2915: % ~\vadjust~ appear in a group starting after the change of
! 2916: % ~\vadjust~ into ~\PostponeVadjust~.
! 2917: % (UL) Even the undoing may be superfluous, cf._discussion
! 2918: % in section_\ref{ss:ReDef} below. (UL)
! 2919: %%
! 2920: \vadjust{\penalty-\@Mppvacodepen}%
! 2921: \g@addto@macro\@LN@vadjustlist{#1\@lt}%
! 2922: }
! 2923: \let\@LN@@vadjust\vadjust
! 2924: \global\let\@LN@vadjustlist\@empty
! 2925: \global\let\@LN@do@vadjusts\relax
! 2926:
! 2927: % These ~\global~s are just to remind that
! 2928: % all the changes of the strings after ~\let~ should be
! 2929: % ~\global~ (\TeX book p._301). ~\@LN@vadjustlist~ collects
! 2930: % the ~\vadjust~ items of a paragraph. ~\PassVadjustList~
! 2931: % tears one ~\vadjust~ item for the current line out of
! 2932: % ~\@LN@vadjustlist~ and puts it into ~\@LN@do@vadjusts~.
! 2933: % The latter is encountered each line in ~\MakeLineNo~
! 2934: % (section_\ref{ss:MLN}), while those \LaTeX\ ~\vadjust~
! 2935: % commands will come rather rarely. So I decided that
! 2936: % ~\@LN@do@vadjust~ is ~\relax~ until a ~\vadjust~ item
! 2937: % is waiting. In the latter case, ~\@LN@do@vadjusts~
! 2938: % is turned into a list macro which resets itself to
! 2939: % ~\relax~ when the other contents have been placed in
! 2940: % the vertical list.---~\PassVadjustList~ is invoked by
! 2941: % the output routine (section_\ref{ss:output}), so the
! 2942: % ~\box255~ must be put back.
! 2943:
! 2944: \def\PassVadjustList{%
! 2945: \unvbox\@cclv
! 2946: \expandafter \@LN@xnext \@LN@vadjustlist \@@
! 2947: \@tempa \@LN@vadjustlist
! 2948: \ifx\@LN@do@vadjusts\relax
! 2949: \gdef\@LN@do@vadjusts{\global\let\@LN@do@vadjusts\relax}%
! 2950: \fi
! 2951: \expandafter \g@addto@macro \expandafter \@LN@do@vadjusts
! 2952: \expandafter {\@tempa}%
! 2953: }
! 2954:
! 2955: %
! 2956: % \subsection{%
! 2957: % Redefining the \LaTeX\ commands
! 2958: % \unskip}\label{ss:ReDef}
! 2959: %
! 2960: % Now we change ~\pagebreak~ etc.\
! 2961: % so that they use ~\PostponeVadjust~ in place of ~\vadjust~.
! 2962: % We try to do this as independently as possible of the
! 2963: % implementation of the \LaTeX\ commands to be redefined.
! 2964: % Therefore, we don't just copy macro definition code from any
! 2965: % single implementation (say, latest \LaTeX) and insert our
! 2966: % changes, but attach a conditional
! 2967: % ~\global\let\vadjust\PostponeVadjust~
! 2968: % to their left ends in a way which should work rather
! 2969: % independantly of their actual code.
! 2970: % However, ~\vadjust~ should be the primitive again after
! 2971: % execution of the command. So the ~\global\let...~ may be used
! 2972: % only if it's guaranteed that a ~\vadjust~ is near.---(UL)
! 2973: % Sure? In line numbering mode, probably each ~\vadjust~
! 2974: % coming from a \LaTeX\ command should be ~\PostponeVadjust~.
! 2975: % ~\marginpar~s and floats seem to be the only cases which
! 2976: % are not explicitly dealt with in the present section.
! 2977: % This would be a way to avoid ~\@LN@nobreaktrue~!
! 2978: % Of course, the ~\vadjust~s that the present package uses
! 2979: % then must be replaced by ~\@LN@@vadjust~.---Maybe
! 2980: % next time. (/UL)
! 2981: %% %% TODO v4.4+
! 2982: %
! 2983: % The next command and something else will be added to the
! 2984: % \LaTeX\ commands we are concerned with here.
! 2985:
! 2986: \DeclareRobustCommand\@LN@changevadjust{%
! 2987: \ifvmode\else\ifinner\else
! 2988: \global\let\vadjust\PostponeVadjust
! 2989: \fi\fi
! 2990: }
! 2991:
! 2992: % (UL) What about math mode? Math display? Warn? (/UL)
! 2993: %% %% TODO v4.4+
! 2994: %
! 2995: % ~\@tempa~ will now become a two place macro which adds first
! 2996: % argument (single token), enclosed by ~\ifLineNumbers~\,\dots
! 2997: % ~\fi~ to the left of second argument. As long as we need it,
! 2998: % we can't use the star form of ~\DeclareRobustCommand~ or
! 2999: % the like, because AMS-\LaTeX\ uses ~\@tempa~ for ~\@ifstar~.
! 3000: % (New v4.41) And for the same reason, that ~\CheckCommand*~
! 3001: % had to be raised! (/New v4.41)
! 3002:
! 3003: \CheckCommand*\@parboxrestore{\@arrayparboxrestore\let\\\@normalcr}
! 3004:
! 3005: \def\@tempa#1#2{%
! 3006: \expandafter \def \expandafter#2\expandafter{\expandafter
! 3007: \ifLineNumbers\expandafter#1\expandafter\fi#2}%
! 3008: }
! 3009:
! 3010: % (UL) This ~\ifLineNumber~ can be fooled by
! 3011: % ~\linenumbers~ ahead etc. It might be better to place
! 3012: % a signal penalty in any case and let the output routine
! 3013: % decide what to do.
! 3014: %%
! 3015: %% And when this has been done, remove warnings about this.
! 3016: % (/UL)
! 3017: %
! 3018: % We use the occasion to switch off linenumbers where they
! 3019: % don't work anyway and where we don't want them,
! 3020: % especially in footnotes:
! 3021:
! 3022: \@tempa\nolinenumbers\@arrayparboxrestore
! 3023:
! 3024: % We hope this suffices $\dots$ let's check one thing
! 3025: % at least: [(New v4.41) see ~\CheckCommand~ above (/New v4.41)]
! 3026: %
! 3027: % Now for the main theme of the section.
! 3028: % The next lines assume that ~\vspace~, ~\pagebreak~, and
! 3029: % ~\nopagebreak~ use ~\vadjust~ whenever they occur outside
! 3030: % vertical mode; moreover, that they don't directly read
! 3031: % an argument. Indeed ~\pagebreak~ and ~\nopagebreak~ first
! 3032: % call something which tests for a left bracket ahead,
! 3033: % while ~\vspace~ first tests for a star.
! 3034:
! 3035: \@tempa\@LN@changevadjust\vspace
! 3036: \@tempa\@LN@changevadjust\pagebreak
! 3037: \@tempa\@LN@changevadjust\nopagebreak
! 3038:
! 3039: % ~\\~, however, uses ~\vadjust~ only in star or optional form.
! 3040: % We relax independency of implementation in assuming
! 3041: % that ~\@normalcr~ is the fragile version of ~\\~
! 3042: % (and we use ~\@ifstar~!).
! 3043: %%
! 3044: %% \@ifstar reimplemented 1995/10/16, but seems to be much older.
! 3045: %% TODO v4.4+:
! 3046: %% \def\@LN@cr{%
! 3047: %% \@ifnextchar*{\@LN@changevadjust\@normalcr}%
! 3048: %% {\@ifnextchar[{\@LN@changevadjust\@normalcr}\@normalcr}%
! 3049: %% }
! 3050: %% ---same number of tokens, expansion step less.
! 3051: %%
! 3052: % (Using a copy of ~\\~ would be safer, but an ugly repetition
! 3053: % of ~\protect~.)
! 3054: %% %% TODO v4.4+
! 3055:
! 3056: \DeclareRobustCommand\\{%
! 3057: \ifLineNumbers
! 3058: \expandafter \@LN@cr
! 3059: \else
! 3060: \expandafter \@normalcr
! 3061: \fi
! 3062: }
! 3063: \def\@LN@cr{%
! 3064: \@ifstar{\@LN@changevadjust\@normalcr*}%
! 3065: {\@ifnextchar[{\@LN@changevadjust\@normalcr}\@normalcr}%
! 3066: }
! 3067:
! 3068: % Moreover we hope that ~\newline~ never leads to a ~\vadjust~,
! 3069: % although names of some commands invoked by ~\\~ contain
! 3070: % ~newline~. At last, this seems to have been OK since 1989 or
! 3071: % even earlier.
! 3072: %
! 3073: % \modulolinenumbers[1]
! 3074: % \firstlinenumber{0}
! 3075: % Let's have a few tests.\vspace*{.5\baselineskip}
! 3076: % Testing ~\pagebreak~ and ~\nopagebreak~ would be too expensive
! 3077: % here, but---oops!---we have just experienced a successful
! 3078: % ~\vspace*{.5\baselineskip}~. A
! 3079: % ~\\*[.5\baselineskip]~\\*[.5\baselineskip] may look even more
! 3080: % drastical, but this time we are happy about it. Note that the
! 3081: % line numbers have moved with the lines. Without our changes,
! 3082: % one line number\vadjust{\kern.5\baselineskip} would have
! 3083: % ``anticipated'' the move of the next line, just as you can
! 3084: % observe it now.
! 3085: % (/New v4.00)
! 3086: %
! 3087: % \switchlinenumbers
! 3088: %
! 3089: % \subsection{%
! 3090: % Reminder on obsoleteness
! 3091: % \unskip}
! 3092: %
! 3093: % (New v4.1) We have completed inclusion of the earlier
! 3094: % extension packages ~linenox0.sty~, ~linenox1.sty~, and
! 3095: % ~lnopatch.sty~. If one of them is loaded, though,
! 3096: % we produce an error message before something weird happens.
! 3097: % We avoid ~\newif~ because the switchings occur so rarely.
! 3098:
! 3099: \AtBeginDocument{%
! 3100: \let\if@LN@obsolete\iffalse
! 3101: \@ifpackageloaded{linenox0}{\let\if@LN@obsolete\iftrue}\relax
! 3102: \@ifpackageloaded{linenox1}{\let\if@LN@obsolete\iftrue}\relax
! 3103: \@ifpackageloaded{lnopatch}{\let\if@LN@obsolete\iftrue}\relax
! 3104: \if@LN@obsolete
! 3105: \PackageError{lineno}{Obsolete extension package(s)}{%
! 3106: With lineno.sty version 4.00 or later,\MessageBreak
! 3107: linenox0/linenox1/lnopatch.sty must no longer be loaded.}%
! 3108: \fi
! 3109: }
! 3110:
! 3111: %
! 3112: % \modulolinenumbers[1]
! 3113: % \section{%
! 3114: % The final touch
! 3115: % \unskip}
! 3116: %
! 3117: % There is one deadcycle for each line number.
! 3118:
! 3119: \advance\maxdeadcycles 100
! 3120:
! 3121: \endinput
! 3122:
! 3123: %
! 3124: % \section{%
! 3125: % The user commands
! 3126: % \unskip}\label{s:UserCmds}
! 3127: %
! 3128: % The user commands to turn on and off line numbering
! 3129: % are
! 3130: % \begin{description}\item
! 3131: % [|\linenumbers] \ \par
! 3132: % Turn on line numbering in the current mode.
! 3133: %
! 3134: % \item
! 3135: % [|\linenumbers*] \ \par$\qquad$
! 3136: % and reset the line number to 1.
! 3137: % \def\NL{<number>]}\item
! 3138: %% %% Boldface italic occurs here, which is evil. (UL)
! 3139: % [|\linenumbers[\NL] \ \par$\qquad$
! 3140: % and start with <number>.
! 3141: % \item
! 3142: % [|\nolinenumbers] \ \par
! 3143: % Turn off line numbering.
! 3144: % \item
! 3145: % [|\runninglinenumbers*[\NL] \ \par
! 3146: % Turn on ~running~ line numbers, with the same optional
! 3147: % arguments as ~\linenumbers~. The numbers are running
! 3148: % through the text over pagebreaks. When you turn
! 3149: % numbering off and on again, the numbers will continue,
! 3150: % except, of cause, if you ask to reset or preset the
! 3151: % counter.
! 3152: % \item
! 3153: % [|\pagewiselinenumbers] \ \par
! 3154: % Turn on ~pagewise~ line numbers. The lines on each
! 3155: % page are numbered beginning with one at the first
! 3156: % ~pagewise~ numbered line.
! 3157: % \item
! 3158: % [|\resetlinenumber[\NL] \ \par
! 3159: % Reset ~[~Set~]~ the line number to 1
! 3160: % ~[~<number>~]~.
! 3161: % \item
! 3162: % [|\setrunninglinenumbers] \ \par
! 3163: % Switch to ~running~ line number mode. Do \emph{not}
! 3164: % turn it on or off.
! 3165: % \item
! 3166: % [|\setpagewiselinenumbers] \ \par
! 3167: % Switch to ~pagewise~ line number mode. Do \emph{not}
! 3168: % turn it on or off.
! 3169: % \item
! 3170: % [|\switchlinenumbers*] \ \par
! 3171: % Causes margin switching in pagewise modes. With the
! 3172: % star, put the line numbers on the inner margin.
! 3173: % \item
! 3174: % [|\leftlinenumbers*] \ \par
! 3175: % \item
! 3176: % [|\rightlinenumbers*] \ \par
! 3177: % Set the line numbers in the left/right margin. With the
! 3178: % star this works for both modes of operation, without
! 3179: % the star only for the currently selected mode.
! 3180: % \item
! 3181: % [|\runningpagewiselinenumbers] \ \par
! 3182: % When using the pagewise line number mode, do not
! 3183: % subtract the page offset. This results in running
! 3184: % line numbers again, but with the possibility to switch
! 3185: % margins. Be careful when doing line number
! 3186: % referencing, this mode status must be the same while
! 3187: % setting the paragraph and during references.
! 3188: % \item
! 3189: % [|\realpagewiselinenumbers] \ \par
! 3190: % Reverses the effect of ~\runningpagewiselinenumbers~.
! 3191: % \item
! 3192: % [|\modulolinenumbers[\NL] \ \par
! 3193: % Give a number only to lines which are multiples of
! 3194: % ~[~<number>~]~. If <number> is not specified, the
! 3195: % current value in the counter ~linenumbermodulo~ is
! 3196: % retained. <number>=1 turns this off without changing
! 3197: % ~linenumbermodulo~. The counter is initialized to 5.
! 3198: %%
! 3199: %% %% TODO v4.4+: `counter', he says. Cf._above.
! 3200: %%
! 3201: %% (New v4.31)
! 3202: % \item
! 3203: % [|\modulolinenumbers*[\NL] \ \par
! 3204: % Like ~\modulolinenumbers~, the only difference being
! 3205: % that the first line number after a ~\linenumbers~
! 3206: % (or ~\runninglinenumbers~, ~\pagewiselinenumbers~,
! 3207: % ~\quotelinenumbers~) is printed regardless of the
! 3208: % modulo---yet `1' is printed only after (or \dots)
! 3209: % ~\firstlinenumber{1}~.
! 3210: % This also applies to the first line of a
! 3211: % ~{linenumbers}~ or respective environment.
! 3212: % See subsection_\ref{ss:Mod} for another explanation.
! 3213: % The behaviour may be unsatisfactory with pagewise
! 3214: % line-numbering.
! 3215: %% (/New v4.31)
! 3216: %% (New v4.00)
! 3217: % \item
! 3218: % [|\firstlinenumber] \ \par
! 3219: % ~\firstlinenumber{~<filino>~}~ brings about that
! 3220: % (after it) line numbers less than <filino> do
! 3221: % \emph{not} appear in the margin. Moreover, with
! 3222: % ~\modulolinenumbers[~<number>~]~, just the line
! 3223: % numbers which are <filino> plus a multiple of
! 3224: % <number> are printed.---If you had
! 3225: % ~\firstlinenumber{~<pos>~}~ with some $\mbox{<pos>}>0$
! 3226: % and want to switch to printing multiples of, e.g.,
! 3227: % 4, you best do ~\modulolinenumbers[4]~ and
! 3228: % ~\firstlinenumber{0}~. (See subsection_\ref{ss:Mod}
! 3229: % for technical details.)
! 3230: %% (/New v4.00)
! 3231: % \item
! 3232: % [|\linenumberdisplaymath] \ \par
! 3233: % Number the lines of a display math in a ~{linenomath}~
! 3234: % environment, but do not in a ~{linenomath*}~
! 3235: % environment. This is used by the package option
! 3236: % ~[mathlines]~.
! 3237: % \item
! 3238: % [|\nolinenumberdisplaymath] \ \par
! 3239: % Do not Number the lines of a display math in a
! 3240: % ~{linenomath}~ environment, but do in a
! 3241: % ~{linenomath*}~ environment. This is the default.
! 3242: % \item
! 3243: % [|\linelabel] \ \par
! 3244: % Set a ~\linelabel{~<foo>~}~ to the line number where
! 3245: % this commands is in. Refer to it with the \LaTeX\
! 3246: % referencing commands ~\ref{~<foo>~}~ and
! 3247: % ~\pageref{~<foo>~}~.
! 3248: % \end{description}
! 3249: % The commands can be used globally, locally within groups
! 3250: % or as environments. It is important to know that they
! 3251: %%
! 3252: %% %% TODO: \linelabel? others?
! 3253: %%
! 3254: % take action only when the ~\par~ is executed. The
! 3255: %%
! 3256: %% %% TODO: sure? ~\modulo...~, e.g.? well, in a sense ...
! 3257: %%
! 3258: % ~\end{~<mode>~linenumbers}~ commands provide a ~\par~.
! 3259: % Examples:
! 3260: % \begin{verse}
! 3261: % ~{\linenumbers~ <text> ~\par}~ \\
! 3262: % \ \\
! 3263: % ~\begin{linenumbers}~ \\
! 3264: % <text> \\
! 3265: % ~\end{linenumbers}~ \\
! 3266: % \ \\
! 3267: % <paragraph> ~{\linenumbers\par}~ \\
! 3268: % \ \\
! 3269: % ~\linenumbers~ \\
! 3270: % <text> ~\par~ \\
! 3271: % ~\nolinenumbers~ \\
! 3272: % \ \\
! 3273: % ~\linenumbers~ \\
! 3274: % <paragraph> ~{\nolinenumbers\par}~ \\
! 3275: % \end{verse}
! 3276: % (New v4.00)
! 3277: % However, the examples containing <paragraph> show what you
! 3278: % should \emph{not} do, at least if you use ~\pagebreak~,
! 3279: % ~\nopagebreak~, ~\vspace~, ~\\*~ or
! 3280: % ~\\[~<space>~]~---cf._section_\ref{s:MVadj}.
! 3281: %
! 3282: % The same care should be applied to the ``wizard'' devices
! 3283: % ~\ifLineNumbers~ (subsection_\ref{ss:OnOff}) and
! 3284: % ~\PostponeVadjust~ (section_\ref{ss:PVadj}).
! 3285: % (/New v4.00)
! 3286: %
! 3287: % (New v4.11) Oh, and the commands and environments of
! 3288: % section_{s:Xt} are missing. Sorry, I am in a hurry now.
! 3289: % May be next time.% %% TODO v4.4+
! 3290: % ---And the environments ~{linenomath}~ and ~{linenomath*}~should
! 3291: % get an own paragraph. In short, each math display, equation,
! 3292: % or ~{eqnarray}~ should be ``wrapped'' in one of ~{linenomath}~
! 3293: % and ~{linenomath*}~.
! 3294: %
! 3295: % \subsection{%
! 3296: % Customization hooks
! 3297: % \unskip}
! 3298: %
! 3299: % There are several hooks to customize the appearance of the
! 3300: % line numbers, and some low level hooks for special
! 3301: % effects.
! 3302: % \begin{description}\item
! 3303: % [|\thelinenumber] \ \par
! 3304: % This macro should give the representation of the line
! 3305: % number in the \LaTeX-counter ~linenumber~. The
! 3306: % default is provided by \LaTeX: \par$\qquad$
! 3307: % ~\arabic{linenumber}~
! 3308: % \item
! 3309: % [|\makeLineNumberLeft] \ \par
! 3310: % This macro is used to attach a line number to the left
! 3311: % of the text page. This macro should fill an ~\hbox to 0pt~
! 3312: % which will be placed at the left margin of the
! 3313: % page, with the reference point aligned to the line to
! 3314: % which it should give a number. Please use the macro
! 3315: % ~\LineNumber~ to refer to the line number.
! 3316: %
! 3317: % The default definition is \par$\qquad$
! 3318: % ~\hss\linenumberfont\LineNumber\hskip\linenumbersep~
! 3319: % \item
! 3320: % [|\makeLineNumberRight] \ \par
! 3321: % Like ~\makeLineNumberLeft~, but for line numbers on
! 3322: % the right margin.
! 3323: %
! 3324: % The default definition is \par$\qquad$
! 3325: % ~\linenumberfont\hskip\linenumbersep\hskip\textwidth~ \par$\qquad$
! 3326: % ~\hbox to\linenumberwidth{\hss\LineNumber}\hss~
! 3327: % \item
! 3328: % [|\linenumberfont] \ \par
! 3329: % This macro is initialized to \par$\qquad$
! 3330: % ~\normalfont\tiny\sffamily~
! 3331: % \item
! 3332: % [|\linenumbersep] \ \par
! 3333: % This dimension register sets the separation of the
! 3334: % linenumber to the text. Default value is ~10pt~.
! 3335: % \item
! 3336: % [|\linenumberwidth] \ \par
! 3337: % This dimension register sets the width of the line
! 3338: % number box on the right margin. The distance of the
! 3339: % right edge of the text to the right edge of the line
! 3340: % number is ~\linenumbersep~ + ~\linenumberwidth~. The
! 3341: % default value is ~10pt~.
! 3342: % \item
! 3343: % [|\theLineNumber] (for wizards) \ \par
! 3344: % This macro is called for printing a ~\newlabel~ entry
! 3345: % to the aux-file. Its definition depends on the mode.
! 3346: % For running line numbers it's just ~\thelinenumber~,
! 3347: % while in pagewise mode, the page offset subtraction
! 3348: % is done in here.
! 3349: % \item
! 3350: % [|\makeLineNumber] (for wizards) \ \par
! 3351: % This macro produces the line numbers. The definition
! 3352: % depends on the mode. In the running line numbers
! 3353: % mode it just expands ~\makeLineNumberLeft~.
! 3354: % \item
! 3355: % [|\LineNumber] (for wizards) \ \par
! 3356: % This macro is called by ~\makeLineNumber~ to typeset
! 3357: % the line number. This hook is changed by the modulo
! 3358: % mechanism
! 3359: %% %%%.
! 3360: % and by ~\firstlinenumber~.
! 3361: %% %% New v4.00
! 3362: % \end{description}
! 3363: %%
! 3364: %% TODO: \stepLineNumber---another wizard command!?
! 3365: %% Not sure, may be retreated.
! 3366: % \end{document}%D
! 3367: ------------------------------------------------------------------------------
! 3368: %SSTOPP
! 3369: %% TODO v4.4+: Check for unwanted comment marks in new comments
! 3370: %% (resulting from manual aligning): search `New v4.2'
! 3371: %% and/or ` % '!
! 3372: %% TODO v4.4+: Check for missing comment marks where a paragraph
! 3373: %% should end/start. Also to prevent empty "code" lines.
! 3374: %% Especially, new comments at section ends must be
! 3375: %% followed by comment mark lines.
! 3376: %% And prevent ~\par~s from blank lines in definitions!
! 3377: %% See `visual space' above.
! 3378: %% For proper appearance in lineno.tex, note that a comment
! 3379: %% in a final code line changes behaviour.
! 3380: %% TODO v4.4+: Require README for redistribution?
! 3381: %% TODO v4.4+: Since discussions of code have increased so much, it
! 3382: %% would be appropriate not to give to this file
! 3383: %% extension `.sty' (e.g., `dty'!??). ?? Is quickly read though!
! 3384: %% A .sty extraction may be possible even if the present
! 3385: %% file is neither a .doc nor a .dtx. (!???)
! 3386: %% Use awk line below (etc.) for .doc at least; + .ins or so.
! 3387: %% ^ must not be caps! To escape awk.
! 3388: %% TODO v4.4+: Underfull lines!? (due to long code quotations)
! 3389: %% TODO v4.4+: Sometimes paragraph indents may be appropriate.
! 3390: %% TODO Swap first line (`\iffalse...') with corresponding below.
! 3391: Or do *not* swap, maybe nawk is more reliable.
! 3392: %% TODO v4.4+: Ponder Stephan's mail from 2004/09/02.
! 3393: %% TODO v4.4+:
! 3394: %% use \@ET@makeLineNumber.
! 3395: %% plus almost all `(UL)'
! 3396: %% plus lots of bad boxes messages
! 3397: %% change v4.3 TODOs when postponed
! 3398: %% remove {old} environments.
! 3399:
! 3400: ------------------------------------------------------------------------------
! 3401:
! 3402: # awk command lines for v4.00, mixed with former ones:
! 3403:
! 3404: echo "Don't bother about unknown 'iffalse'." # SHELL1
! 3405: nawk '/A[W]K/' lineno.sty | nawk -f - lineno.sty >lineno.tex; # SHELL1
! 3406: latex lineno; latex lineno; latex lineno; latex lineno; # SHELL1
! 3407:
! 3408: BEGIN{DOC=-1; # AWK DOC A W K
! 3409: BEGINCODE = "\\begin{code}\\begin{verbatim}"; # AWK
! 3410: ENDCODE = "\\end{verbatim}\n\\end{code}"; } # AWK
! 3411: BEGINCODE = "% \\begin{macrocode}"; # DOC A W K
! 3412: ENDCODE = "% \\end{macrocode}"; } # DOC A W K
! 3413: /^[ \t]*$/ { ECNT++; next; } # AWK DOC A W K
! 3414: /\\documentclass/{ sub("article","ltxdoc") } # DOC A W K
! 3415: /%D$/ { sub("^%* *",""); sub("%D$",""); # DOC A W K
! 3416: print > "lineno.drv"; next } # DOC A W K
! 3417: /^%%/ { next; } # AWK DOC A W K
! 3418: /^%/ { if (!DOC) { print ENDCODE; } # AWK DOC A W K
! 3419: DOC=1; ECNT=0; # AWK DOC A W K
! 3420: sub("^% *",""); # AWK
! 3421: sub("^% *","% "); # DOC A W K
! 3422: print; next; } # AWK DOC A W K
! 3423: /%VERSION/ { sub("%VERSION",""); print; next; } # AWK
! 3424: /%SSTOPP/ { exit } # AWK
! 3425: DOC<0 { next } # AWK DOC A W K
! 3426: /^-+-$/ { if (!DOC) print ENDCODE; exit } # AWK DOC A W K
! 3427: { if (DOC) { ECNT=DOC=0; print BEGINCODE; } # AWK DOC A W K
! 3428: while (ECNT>0) { print " "; ECNT--; } # AWK DOC A W K
! 3429: print $0; } # AWK DOC A W K
! 3430:
! 3431: # New v4.00, UL: know nothing about awk; found present solution
! 3432: # in hours of trial and error.
! 3433:
! 3434: % Earlier (should be inhibited by %SSTOPP above and otherwise):
! 3435: echo "expect errors for unknown commands 'iffalse' and 'fi'";# SHELL0 SHELL#1
! 3436: awk '/A[W]K/' lineno.sty | awk -f - lineno.sty >lineno.tex; # SHELL0
! 3437: latex lineno; latex lineno; latex lineno; latex lineno; # SHELL0
! 3438: nawk '/A[W]K/' lineno4.sty | nawk -f - lineno4.sty >lineno4.tex; # SHELL#1
! 3439: latex lineno4; latex lineno4; latex lineno4; latex lineno4; # SHELL#1
! 3440:
! 3441: awk '/DOC A [W] K/' lineno.sty | awk -f - lineno.sty >lineno.doc; # DOC SH
! 3442:
! 3443: BEGIN{DOC=-1; # A#WK DOC A W K
! 3444: BEGINCODE = "\\begin{code}\\begin{verbatim}"; # A#WK
! 3445: ENDCODE = "\\end{verbatim}\n\\end{code}"; } # A#WK
! 3446: BEGINCODE = "% \\begin{macrocode}"; # DOC A W K
! 3447: ENDCODE = "% \\end{macrocode}"; } # DOC A W K
! 3448: /^[ \t]*$/ { ECNT++; next; } # A#WK DOC A W K
! 3449: /\\documentclass/{ sub("article","ltxdoc") } # DOC A W K
! 3450: /%D$/ { sub("^%* *",""); sub("%D$",""); # DOC A W K
! 3451: print > "lineno.drv"; next } # DOC A W K
! 3452: /^%%/ { next; } # A#WK DOC A W K
! 3453: /^%/ { if (!DOC) { print ENDCODE; } # A#WK DOC A W K
! 3454: DOC=1; ECNT=0; # A#WK DOC A W K
! 3455: sub("^% *",""); # A#WK
! 3456: sub("^% *","% "); # DOC A W K
! 3457: print; next; } # A#WK DOC A W K
! 3458: DOC<0 { next } # A#WK DOC A W K
! 3459: /^-+-$/ { if (!DOC) print ENDCODE; exit } # A#WK DOC A W K
! 3460: { if (DOC) { ECNT=DOC=0; print BEGINCODE; } # A#WK DOC A W K
! 3461: while (ECNT>0) { print " "; ECNT--; } # A#WK DOC A W K
! 3462: print $0; } # A#WK DOC A W K
! 3463:
! 3464:
! 3465: ------------------------------------------------------------------------------
! 3466:
! 3467: If you are looking here because of the two top lines of the file:
! 3468:
! 3469: A .tex documentation of this macro file can be obtained by
! 3470:
! 3471: sh lineno.sty
! 3472:
! 3473: under UNIX.--You may find this hint little helpful. One
! 3474: reason may be that the awk versions to which you have access
! 3475: don't work suitably. Another reason may be that you don't have
! 3476: access to UNIX (in some sense). However, a .tex, .dvi, or .pdf
! 3477: version of such a documentation should be available from CTAN,
! 3478: in the same folder as the present file. When we typed this, that
! 3479: folder was /macros/latex/contrib/lineno. If this has changed in
! 3480: the meantime, a CTAN search should lead you to a folder
! 3481: containing such a documentation. Or you may get help from one of
! 3482: the e-mail addresses above.
! 3483:
! 3484:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>