| 1 |
%% `edtable.sty'---Uwe LĂĽck, direction Christian Tapp. |
| 2 |
%% LaTeX package for tables with line numbers and |
| 3 |
%% editorial notes. |
| 4 |
%% |
| 5 |
%% Copyright (C) 2003-2005 Uwe LĂĽck |
| 6 |
%% |
| 7 |
\def\fileversion{1.3c} \def\filedate{2005/10/03} |
| 8 |
%% |
| 9 |
%% This file can be redistributed and/or modified under |
| 10 |
%% the terms of the LaTeX Project Public License; either |
| 11 |
%% version 1.3 of the License, or any later version. |
| 12 |
%% The latest version of this license is in |
| 13 |
%% http://www.latex-project.org/lppl.txt |
| 14 |
%% We did our best to help you, but there is NO WARRANTY. |
| 15 |
%% |
| 16 |
%% Please send your comments via |
| 17 |
%% |
| 18 |
%% https://github.com/latex-lineno/lineno |
| 19 |
%% |
| 20 |
%% * USAGE: * |
| 21 |
% |
| 22 |
% *Requirements/overview:* |
| 23 |
% |
| 24 |
% The package is made for the background of the LaTeX2e macro |
| 25 |
% package and enhances functionality of the following packages: |
| 26 |
% 1.) Stephan I. Böttcher's `lineno.sty' for printing line |
| 27 |
% numbers in the margin and a \label version \linelabel |
| 28 |
% relating labels to line numbers; |
| 29 |
% 2.) our `ednotes.sty' for indicating variant readings and |
| 30 |
% other editorial remarks in separate footnote apparatuses; |
| 31 |
% 3.) David Carlisle's `longtable.sty' for multi-page tables. |
| 32 |
% %% TODO: supertabular etc.!? |
| 33 |
% 4.) our `ltabptch.sty' for a patch of `longtable.sty' |
| 34 |
% (i.e., optionally, see below). |
| 35 |
% |
| 36 |
% Actually, only the first package is necessary for using the |
| 37 |
% present one. The present one needs your line numbering commands |
| 38 |
% according to the first one and its documentation to which we |
| 39 |
% refer here. We likewise refer to the remaining packages for the |
| 40 |
% details of their functionality. |
| 41 |
% |
| 42 |
% `lineno.sty' version 4.1 and (in case it is used) `ednotes.sty' |
| 43 |
% version 0.8 (onwards) are needed. For obtaining recent versions |
| 44 |
% of required packages, see the CTAN folder |
| 45 |
% /macros/latex/contrib/ednotes. |
| 46 |
% |
| 47 |
% *Install/load:* |
| 48 |
% 1.) To be used, the present file must be put into a folder |
| 49 |
% that (La)TeX searches. You should have obtained a file |
| 50 |
% containing more detailed hints about this. |
| 51 |
% 2.) We recommend loading this file *not* by |
| 52 |
% \usepackage[<options>]{edtable} but by loading `lineno.sty' |
| 53 |
% or `ednotes.sty' with package option `edtable'. |
| 54 |
% 3.) To use the package options `longtable' and |
| 55 |
% `nolongtablepatch' that are described below, enter them |
| 56 |
% as options for `lineno.sty' or `ednotes.sty'. |
| 57 |
% |
| 58 |
% *User Commands:* |
| 59 |
% |
| 60 |
% 1. The package defines an environment `edtable' -- for its |
| 61 |
% syntax we consider two cases: |
| 62 |
% (a) Let <stdtable> be a tabular environment "like `tabular'". |
| 63 |
% "Like" here means: (i) we have tested it with `tabular', but |
| 64 |
% it should work with many more (e.g., from the `array' and |
| 65 |
% `tabularx' packages) -- which share certain properties of |
| 66 |
% implementation and requirements. Sorry, you must try, or we |
| 67 |
% hope you will (and tell us). (For wizards: <stdtable> may |
| 68 |
% probably be anything using a single \halign and \tabskip=0pt.) |
| 69 |
% Definitively: |
| 70 |
% (ii) LaTeX's standard `array' and other environments are *not* |
| 71 |
% "like" `tabular'. Namely, environments that work only in math |
| 72 |
% mode are not meant here. They are considered below in `b.'. |
| 73 |
% (iii) `longtable' from the `longtable' package of the `tools' |
| 74 |
% bundle neither is meant. An option of the present package |
| 75 |
% deals with it as described below. Neither `supertabular' is |
| 76 |
% meant. |
| 77 |
% (iv) In general, usage with tabular environments that can |
| 78 |
% break across pages as in (iii) is not recommended, at least |
| 79 |
% when working with `ednotes.sty'. Even if some worked here, a |
| 80 |
% shortcoming with `ednotes.sty' would be that the footnotes can |
| 81 |
% appear on bad pages. |
| 82 |
% -- Now the syntax is: |
| 83 |
% \begin{edtable}{<stdtable>}<args><entries>\end{edtable} |
| 84 |
% -- where <args> and <entries> are usual arguments and entries |
| 85 |
% for <stdtable>. So an example is: |
| 86 |
% \begin{edtable}{tabular}{cc} |
| 87 |
% left upper & right upper \\ left lower & right lower |
| 88 |
% \end{edtable} |
| 89 |
% This produces just what <stdtable> does in an extra line, |
| 90 |
% only adding line numbers in the margin and processing `ednotes' |
| 91 |
% commands in the entries appropriately. |
| 92 |
% (b) Let <stdarray> be an "array environment" like -- standard |
| 93 |
% LaTeX's `array'! "Like" here means (i) ... analogously to |
| 94 |
% <stdtable> above. (ii) "Text" ... oh, sorry, this is not clear |
| 95 |
% to me at present, and I am in a hurry. %% TODO |
| 96 |
% (iii) Nothing from the `amsmath' package seems to work here, |
| 97 |
% sorry, I have tried a lot ... (iv) For standard LaTeX's |
| 98 |
% `eqnarray', it is better to try the `linenomath' environment |
| 99 |
% of `lineno.sty' [with package option `mathlines']. Its |
| 100 |
% modifications in `amsmath' produce (at best) a spurious line |
| 101 |
% number with the `linenomath' environment (up to now). |
| 102 |
% -- Now the syntax is: |
| 103 |
% \begin{edtable}[<$$$>]{<stdarray>} |
| 104 |
% <args><entries>\end{edtable} |
| 105 |
% -- where <args> and <entries> are usual arguments and entries |
| 106 |
% for <stdarray>. <$$$> can be one of `$' or `$$'. Indeed, the |
| 107 |
% <stdtable> syntax above (without [<$$$>]) *does not work* |
| 108 |
% inside $...$ or $$...$$. -- An example: |
| 109 |
% \begin{edtable}[$$]{array}{cc} |
| 110 |
% a_{11} & a_{12} \\ a_{21} & a_{22} |
| 111 |
% \end{edtable} |
| 112 |
% Now, this produces just what <stdarray> does in an extra line |
| 113 |
% etc. as with <stdtable>. However, \linelabel and `ednotes.sty' |
| 114 |
% footnotes may need the `mathrefs' option of `lineno.sty'. For |
| 115 |
% the difference between `[$]' and `[$$]', see below. |
| 116 |
% |
| 117 |
% 2. When working with `ednotes.sty', in |
| 118 |
% \Anote{L1\<L2\>L3}{NOTE} |
| 119 |
% L2 may contain &'s and \\'s, but L1, L3 must not! Analogously |
| 120 |
% for \Bnote, etc., \Anotelabel...\donote..., etc. -- Well this |
| 121 |
% holds for <stdtable>, hardly for <stdarray> ... %% TODO |
| 122 |
% |
| 123 |
% 3. On positioning: You may have wondered about `extra line' |
| 124 |
% above. This means that `edtable' starts a new line at |
| 125 |
% \begin{edtable} and at \end{edtable}. %% TODO: sure!? |
| 126 |
% (a) It should be placed within a `center', `flushleft', or |
| 127 |
% `flushright' environment for proper (vertical) spacing, but |
| 128 |
% also works without. However, with <stdarray> and optional |
| 129 |
% parameter `$$' of `edtable' (i.e., \begin{edtable}[$$]...), |
| 130 |
% you can obtain the usual math display spacing *within a |
| 131 |
% paragraph*; especially, the vertical space is less when the |
| 132 |
% previous line is short ... and so on. |
| 133 |
% (b) Horizontal positioning of line numbers (usually) needs a |
| 134 |
% second run (after changing a table)! %% TODO: automatic warning. |
| 135 |
% (For wizards: It may fail if some of \leftskip, \rightskip, |
| 136 |
% \linewidth, and \@totalleftmargin are used in an unusual way.) |
| 137 |
% A <dimen> register \ETextraoffset is provided whose value is |
| 138 |
% 0pt by default and which additionally moves line numbers |
| 139 |
% to the left (right) if given a positive (negative) value. |
| 140 |
% %% TODO: any use? |
| 141 |
% |
| 142 |
% *Package options:* |
| 143 |
% |
| 144 |
% 1. Option `longtable' adjusts the `longtable' environment |
| 145 |
% defined by David Carlisle's longtable.sty for use with |
| 146 |
% `lineno.sty' and `ednotes.sty'. The option makes `longtable' |
| 147 |
% environments appear with line numbers in the margin, according |
| 148 |
% to `lineno.sty', and process `ednotes.sty' commands if line |
| 149 |
% numbering is active according to `lineno.sty'. |
| 150 |
% [We maintain an alternative package with just this function |
| 151 |
% in a slightly different implementation.] %% -> ulnltab.sty. |
| 152 |
% Lemmas may go across table entries as with `edtable' (see above). |
| 153 |
% ---There might be options like `supertabular' for adjusting |
| 154 |
% other tabular environments that cannot be handled by the |
| 155 |
% `edtable' environment provided here---they have not been |
| 156 |
% implemented yet! %% TODO |
| 157 |
% |
| 158 |
% 2. Option `nolongtablepatch' avoids loading/asking for |
| 159 |
% `ltabptch.sty'. I.e.: according to LaTeX bugs database, |
| 160 |
% tools/3180 and tools/3485, there have been problems with |
| 161 |
% vertical spacing around `longtable' environments. By default |
| 162 |
% the present package loads our `ltabptch.sty' or asks for it. |
| 163 |
% Option `nolongtablepatch' overrides this. This is useful when |
| 164 |
% you don't want to have the patch, especially when you use an |
| 165 |
% "emergency stop" installation of TeX. |
| 166 |
% |
| 167 |
% *Wizard interface:* |
| 168 |
% Macros \@ET@makeLineNumber, \@ET@use@outerhook, |
| 169 |
% \@ET@execute@outerhook, \@ET@ampnotes \@ET@startlinewith, |
| 170 |
% \@ET@trivialize@linelabel are provided as tools for adjusting |
| 171 |
% tabular environments for use with `lineno.sty' and |
| 172 |
% `ednotes.sty'. \@ET@step@linenumber is \let \stepLineNumber |
| 173 |
% (from `lineno.sty'), but could be used as a hook for |
| 174 |
% something different. See Environment `edtable' and Option |
| 175 |
% `longtable' below for examples of application. |
| 176 |
% %% TODO: specification here. |
| 177 |
% |
| 178 |
% |
| 179 |
%% * Acknowledgements: * |
| 180 |
% |
| 181 |
% Stephan I. Böttcher told us how to do it in extensive discussion |
| 182 |
% and by providing some first code lines. We changed these essentially |
| 183 |
% in some respects, but kept his general ideas and some parts of his |
| 184 |
% macros, the latter even without knowing what we are doing. |
| 185 |
% |
| 186 |
% v1.3 is due to a request by Martin Brandenburg. |
| 187 |
% |
| 188 |
% * Now for internals: * |
| 189 |
% |
| 190 |
\NeedsTeXFormat{LaTeX2e}[1994/12/01] |
| 191 |
% 1994/12/01: \newenvironment* etc. %% TODO: more recent needed? |
| 192 |
\ProvidesPackage{edtable}[\filedate\space v\fileversion\space |
| 193 |
arrays with lineno + ednotes (ul)] |
| 194 |
% |
| 195 |
% Alternative ideas for implementation: |
| 196 |
% 1. There is a German package `TABMAC' enhancing `EDMAC' (cf. |
| 197 |
% documentation of `ednotes.sty'). We could have rewritten its |
| 198 |
% macros so it would work with `lineno.sty' and `ednotes.sty' |
| 199 |
% in place of `EDMAC'. [TODO: "tabmac.sty"] |
| 200 |
% 2. We redefine `longtable' by Option `longtable' because |
| 201 |
% there seems to be only one reasonable use of the `longtable' |
| 202 |
% environment in the course of a critical edition. This may be |
| 203 |
% different for environments like `array' and `tabular' which |
| 204 |
% can be used within text lines. Therefore, these environments |
| 205 |
% are not redefined. |
| 206 |
% 3. One might use \everycr, however: (a) it is executed |
| 207 |
% before the first row, (b) it is executed in fake lines that |
| 208 |
% `longtable' uses. |
| 209 |
% 4. As an alternative to \everycr, there is the approach of |
| 210 |
% redefining \cr and \crcr for setting \noalign. This needs |
| 211 |
% redefining \@tabularcr etc.---not nice. We use this approach |
| 212 |
% here for `longtable' which uses a stretching \tabskip. |
| 213 |
% For \tabskip=0pt, we attach line numbers by a template. |
| 214 |
% |
| 215 |
% \RequirePackage{lineno}[2004/10/06] |
| 216 |
% Wanted to check lineno version--causes unknown option error. |
| 217 |
% See LaTeX bug latex/3730. |
| 218 |
|
| 219 |
% Options: |
| 220 |
|
| 221 |
%% TODO: underful page with `longtable.sty'!? |
| 222 |
\let\if@ET@longtable\iffalse % \newif\if@ET@longtable@ |
| 223 |
\DeclareOption{longtable}{\let\if@ET@longtable\iftrue} |
| 224 |
\let\if@ET@ltabptch\iftrue |
| 225 |
\DeclareOption{nolongtablepatch}{\let\if@ET@ltabptch\iffalse} |
| 226 |
\ProcessOptions |
| 227 |
|
| 228 |
% Redefine \longtable if option: |
| 229 |
\if@ET@longtable |
| 230 |
% Stephan's direction for attaching a line number to each row |
| 231 |
% is using \noalign in the course of \\. |
| 232 |
% However, (1) the user should not worry about closing the table |
| 233 |
% with \\ or without, and (2) the line number thing should not |
| 234 |
% happen twice if \\ is the last token before \end{longtable}. |
| 235 |
% Our solution: attach something to the beginning of \endlongtable |
| 236 |
% which attaches line number unless an unsucceeded \\ has done it. |
| 237 |
% This thing is activated by each row start and turned off by \\. |
| 238 |
% Since the switch at row start may happen to be in a pbox, |
| 239 |
% let it act globally on \endlongtable. (The \crcr at the beginning |
| 240 |
% of \endlongtable must not be changed directly, since original |
| 241 |
% \crcr may be required in table entries using \oalign etc.) |
| 242 |
% |
| 243 |
\RequirePackage{longtable}% |
| 244 |
% \IfFileExists{longtable.sty}{\RequirePackage{longtable}}% |
| 245 |
% {\RequirePackage{longtabl}}% |
| 246 |
% For Atari problem, it suffices to rename `longtable.sty' |
| 247 |
% into `longtabl.sty'. |
| 248 |
% |
| 249 |
% Patch for tools/3180 and tools/3485 of LaTeX bug database: |
| 250 |
\if@ET@ltabptch |
| 251 |
\IfFileExists{ltabptch.sty}{\RequirePackage{ltabptch}}{% |
| 252 |
\PackageError{edtable}{% |
| 253 |
ltabptch.sty (for improving spacing around\MessageBreak |
| 254 |
longtable) missing! Be sure to use it always\MessageBreak |
| 255 |
or never!% |
| 256 |
}{% |
| 257 |
To omit ltabptch.sty *and* escape this error,\MessageBreak |
| 258 |
use package option `nolongtablepatch'.% |
| 259 |
}% |
| 260 |
} |
| 261 |
\fi |
| 262 |
\let\@ET@@longtable\longtable |
| 263 |
\def\longtable{% |
| 264 |
\ifLineNumbers |
| 265 |
\expandafter\@ET@longtable |
| 266 |
\else |
| 267 |
\let\@ET@sw@cr\@ET@crcr % ... in \endlongtable. |
| 268 |
\expandafter\@ET@@longtable |
| 269 |
\fi |
| 270 |
} |
| 271 |
\def\@ET@longtable{% |
| 272 |
% Since we have made it anyway, we use the method of redefining |
| 273 |
% \halign for inserting the activating row start as well. |
| 274 |
% However, redefinition must be repeated before every \LT@bchunk. |
| 275 |
% \longtable and \LT@get@withs are good places for this. |
| 276 |
\@ET@startlinewith\@ET@sw@cr@on |
| 277 |
\@ET@trivialize@linelabel |
| 278 |
\@ET@use@outerhook |
| 279 |
\@ET@ampnotes |
| 280 |
\let\LT@tabularcr\@ET@LT@tabularcr |
| 281 |
\expandafter\def\expandafter\LT@get@widths\expandafter |
| 282 |
{\LT@get@widths\@ET@startlinewith\@ET@sw@cr@on} |
| 283 |
% Admittedly, we could make it less of a hack by using @{...} |
| 284 |
% ---we could then leave \LT@get@widths untouched. |
| 285 |
\@ET@@longtable |
| 286 |
} |
| 287 |
\def\@ET@sw@cr@on{\global\let\@ET@sw@cr\@ET@cr@attach} |
| 288 |
% We are hacking a longtable version offering |
| 289 |
% \def\LT@tabularcr{% |
| 290 |
% \relax\iffalse{\fi\ifnum0=`}\fi |
| 291 |
% \@ifstar |
| 292 |
% {\def\crcr{\LT@crcr\noalign{\nobreak}}\let\cr\crcr |
| 293 |
% \LT@t@bularcr}% |
| 294 |
% {\LT@t@bularcr}} |
| 295 |
% We need a redefinition of \cr which is not overridden by \@ifstar: |
| 296 |
\def\@ET@LT@tabularcr{% |
| 297 |
\relax\iffalse{\fi\ifnum0=`}\fi |
| 298 |
\def\cr{\@ET@sw@cr}% |
| 299 |
% So \crcr is affected by change of \@ET@sw@cr, cf. below. |
| 300 |
\let\crcr\cr |
| 301 |
\@ifstar |
| 302 |
{\gdef\@ET@sw@nobreak{\nobreak |
| 303 |
\global\let\@ET@sw@nobreak\relax}% |
| 304 |
% {\def\cr{\@ET@sw@cr\noalign{\nobreak}}\let\cr\crcr |
| 305 |
% Why didn't this work? %% TODO: try shorter again. |
| 306 |
\LT@t@bularcr}% |
| 307 |
\LT@t@bularcr |
| 308 |
% {\let\cr\@ET@sw@cr \let\crcr\cr |
| 309 |
% \LT@t@bularcr}% This accompanied \def\cr... above. |
| 310 |
} |
| 311 |
% Attach \@ET@sw@cr to beginning of \endlongtable: |
| 312 |
\expandafter\def\expandafter\endlongtable\expandafter |
| 313 |
{\expandafter\@ET@sw@cr\endlongtable} |
| 314 |
\def\@ET@cr@attach{% Actually attaching line numbers. |
| 315 |
\@ET@crcr\noalign{% Basically Stephan's approach. |
| 316 |
% If we were not careful, following box containing line number |
| 317 |
% could fool interline glue after longtable, even if tools/3485 |
| 318 |
% is repaired in some way. This box should have same depth as |
| 319 |
% the line composed previously. |
| 320 |
\nobreak %% \@ET@ex... might cause page break. 2003/10/30. |
| 321 |
\setbox\z@\@ET@makeLineNumber |
| 322 |
\ht\z@-\prevdepth \dp\z@\prevdepth \box\z@ |
| 323 |
\@ET@step@linenumber |
| 324 |
\global\let\@ET@sw@cr\@ET@crcr % ... if called by \\. |
| 325 |
% This also resets the \crcr starting \LT@echunk following |
| 326 |
% \@xargarraycr or \@yargarraycr in \LT@argtabularcr. |
| 327 |
% \let...\relax seems to suffice at well, but in case ... |
| 328 |
\@ET@execute@outerhook %% 2003/10/30. |
| 329 |
\@ET@sw@nobreak |
| 330 |
% \@ET@execute@outerhook |
| 331 |
}% |
| 332 |
} |
| 333 |
\let\@ET@crcr\crcr |
| 334 |
\global\let\@ET@sw@nobreak\relax % Just to remind ... |
| 335 |
\fi |
| 336 |
|
| 337 |
\let\@ET@step@linenumber\stepLineNumber |
| 338 |
% \def\@ET@step@linenumber{\global\advance\c@linenumber\@ne} |
| 339 |
\def\@ET@makeLineNumber{\hb@xt@\z@{\makeLineNumber}} |
| 340 |
%% TODO: export to lineno.sty!? |
| 341 |
% Special \halign: |
| 342 |
% For `array' etc., we insert line numbers by a leftmost template. |
| 343 |
% @{...} in the last argument of `array' etc. is difficult for this |
| 344 |
% since `tabular*' has an additional argument. So we redefine |
| 345 |
% \halign to put something to the right of the next \bgroup. |
| 346 |
% Now, as a macro, \halign would break in an \edef or \xdef. |
| 347 |
% Horribly, this danger has become quite real in longtable.sty's |
| 348 |
% definition of \LT@bchunk. Only its latest version 4.10 has |
| 349 |
% preceded \halign by a \noexpand (for mathtext.sty which |
| 350 |
% redefines \halign as well). We need not rely on such a |
| 351 |
% provision if we let \halign expand to \the<token register> |
| 352 |
% for some token register. However, using \toks@ or \@temptokena |
| 353 |
% is neither very safe---might be filled by macro ahead with |
| 354 |
% something new. So reserve an own token register. |
| 355 |
\newtoks\@ET@toks |
| 356 |
\@ET@toks{\@ET@specialhalign} |
| 357 |
% v1.3: In 'AMSmath', there are \halign's followed by explicit |
| 358 |
% left braces. Thus '\def\@ET@specialhalign#1\bgroup{%' broke. |
| 359 |
%% TODO ... |
| 360 |
\def\@ET@specialhalign{% |
| 361 |
\ifmeasuring@ \expandafter\@firstoftwo |
| 362 |
% v1.3 2005/03/04, for `amsmath'. |
| 363 |
\else \expandafter\@secondoftwo |
| 364 |
\fi |
| 365 |
{\let\halign\@ET@@halign \halign}% |
| 366 |
{\@ifnextchar\bgroup\@ET@replace@arg\@ET@sphalign@to}} |
| 367 |
%% TODO: change back, commenting out code above, report |
| 368 |
%% error with `alignat'. |
| 369 |
% \@ifnextchar\bgroup\@ET@replace@arg\@ET@sphalign@to} |
| 370 |
% If `amsmath' not loaded (v1.3): |
| 371 |
\AtBeginDocument{\@ifundefined{measuring@true}{% |
| 372 |
\let\ifmeasuring@\iffalse}\relax} |
| 373 |
\def\@ET@replace@arg#1{% |
| 374 |
\def\@EN@tempa{#1}\def\@EN@tempb{\bgroup}% Corr. after v1.3b. |
| 375 |
\ifx\@EN@tempa\@EN@tempb |
| 376 |
\def\@EN@tempa{\@ET@sphalign@to\bgroup}% |
| 377 |
\else |
| 378 |
\def\@EN@tempa{\@ET@sphalign@to{#1}}% |
| 379 |
% This may be wrong, #1 might be `t' from `to' ... |
| 380 |
\fi |
| 381 |
\@EN@tempa} |
| 382 |
\def\@ET@sphalign@to#1\bgroup{% |
| 383 |
\let\halign\@ET@@halign % Reset for nested arrays. |
| 384 |
\halign#1\bgroup |
| 385 |
% \ifmeasuring@\else % For `amsmath', moved backwards. |
| 386 |
\@ET@startline % [Wizard interface, via \@ET@starlinewith.] |
| 387 |
% \fi |
| 388 |
} |
| 389 |
% Wizard interface: |
| 390 |
\def\@ET@startlinewith{% Next token precedes preamble. |
| 391 |
% \let\@ET@@halign\halign % Or \AtBeginDocument? |
| 392 |
% ... indeed: bad loop with long longtable (\LT@get@widths!?) |
| 393 |
\def\halign{\the\@ET@toks}% |
| 394 |
\let\@ET@startline |
| 395 |
} |
| 396 |
\AtBeginDocument{\let\@ET@@halign\halign} |
| 397 |
% Or save it at start of environment only |
| 398 |
% (don't repeat inside longtable). |
| 399 |
% |
| 400 |
% Outer hook for inserts: (wizard interface) |
| 401 |
\def\@ET@execute@outerhook{% To be placed outside inner mode. |
| 402 |
\@ET@outerhook \global\let\@ET@outerhook\@empty |
| 403 |
} |
| 404 |
\global\let\@ET@outerhook\@empty % Just to remind: global! |
| 405 |
% \@EN@hookfn (ednotes) sends to outer hook: |
| 406 |
\def\@ET@use@outerhook{% Wizard interface. |
| 407 |
\def\@EN@hookfn{\g@addto@macro\@ET@outerhook}% |
| 408 |
}%% TODO: move last line to `ednotes', \let\@ET@use...\@empty. |
| 409 |
%% But this requires re-installing both packages |
| 410 |
%% at the same time. See the `ampnotes' thing as well. |
| 411 |
% |
| 412 |
% Trivialize \linelabel: (wizard interface) |
| 413 |
\def\@ET@trivialize@linelabel{\let\linelabel\@ET@linelabel} |
| 414 |
\def\@ET@linelabel{% |
| 415 |
\protected@edef\@currentlabel{\theLineNumber}% |
| 416 |
\label |
| 417 |
} |
| 418 |
% Change ampersand at \Anote etc.: (wizard interface) |
| 419 |
%% 2003/10/31. |
| 420 |
% & is changed by \Anote etc. No \begin...\endgroup, |
| 421 |
% next \\ or & after % note/donote command switches back. |
| 422 |
% ---Global change seems to break table setup. |
| 423 |
\begingroup |
| 424 |
\gdef\@ET@hideamps{\catcode`\&\active} |
| 425 |
\@ET@hideamps |
| 426 |
\gdef\@ET@ampnotes{% |
| 427 |
\let&\@ET@hideamp |
| 428 |
%% & would be undefined after \\ in lemma. |
| 429 |
\let\@ET@EN@rnote\@EN@note |
| 430 |
\def\@EN@note{\@ET@hideamps\@ET@EN@rnote}% |
| 431 |
\let\@ET@EN@rnotelb\@EN@notelabel |
| 432 |
\def\@EN@notelabel{\@ET@hideamps\@ET@EN@rnotelb}% |
| 433 |
} |
| 434 |
%% TODO: & and \\ in \@EN@lemmaexpands!? |
| 435 |
\endgroup |
| 436 |
\def\@ET@hideamp{&} |
| 437 |
|
| 438 |
\newenvironment*{edtable}[2][]{% |
| 439 |
% #1 $ or $$, #2 standard environment name. |
| 440 |
%% TODO: star version!? cf. lineno.sty's `numquote'. |
| 441 |
\def\@ET@mode{#1}% |
| 442 |
\def\@ET@currenvir{#2}% |
| 443 |
\ifhmode \ifnum\the\lastpenalty=-\@M\else |
| 444 |
% \par must be executed for printing/stopping line numbers: |
| 445 |
\@centercr\relax \noindent |
| 446 |
\fi \fi |
| 447 |
\ifvmode \noindent \fi % Otherwise linenumbers are indented |
| 448 |
% -- however, not recommended. |
| 449 |
\@ET@use@outerhook |
| 450 |
\@ET@trivialize@linelabel |
| 451 |
\@ET@ampnotes |
| 452 |
\@ET@startlinewith\@ET@normal@startline |
| 453 |
\global\advance\c@linenumber\m@ne % Stepping correction. |
| 454 |
% (Must come after closing previous paragraph.) |
| 455 |
% Calculate offset: |
| 456 |
\global\advance\c@ET@array\@ne |
| 457 |
% Saving/calling width of table (`longtable's algorithm). |
| 458 |
% Test if there is \@flushglue on the left (center or flushleft): |
| 459 |
\edef\@EN@tempa{\the\@flushglue}% |
| 460 |
% ... v1.3: fool this for "$$". |
| 461 |
\in@{$$}{#1\@nil}% \in@{#1}{#2} searches #1 in #2#1 ... |
| 462 |
\edef\@EN@tempb{\the\ifin@\@flushglue\else\leftskip\fi}% |
| 463 |
\ifx\@EN@tempa\@EN@tempb |
| 464 |
% Assume \@ET@offset is 0pt else here. |
| 465 |
\@ET@offset\linewidth |
| 466 |
\advance\@ET@offset-% |
| 467 |
\@ifundefined\@ET@arraywidth@csn % Shortened for v1.3. |
| 468 |
{\linewidth\G@refundefinedtrue |
| 469 |
\PackageWarningNoLine{edtab}{^^JLine numbers at |
| 470 |
\@ET@currenvir\space need \jobname.aux}}% |
| 471 |
{\csname\@ET@arraywidth@csn\endcsname}% |
| 472 |
% Test if \@flushglue on the right (center): |
| 473 |
% ... v1.3: fool it again. Repeat \in@ in case ... |
| 474 |
\in@{$$}{#1\@nil}% |
| 475 |
\edef\@EN@tempb{\the\ifin@\@flushglue\else\rightskip\fi}% |
| 476 |
\ifx\@EN@tempa\@EN@tempb \divide\@ET@offset\tw@ \fi |
| 477 |
\fi |
| 478 |
\advance\@ET@offset\@totalleftmargin |
| 479 |
\advance\@ET@offset\ETextraoffset % Offset ready. |
| 480 |
\setbox\@tempboxa\hbox\bgroup |
| 481 |
% v1.3: `alignat' complains later when this is \vbox instead. |
| 482 |
% \vbox\bgroup % Tried in vain. |
| 483 |
\ifx\@ET@mode\@empty\else $\fi |
| 484 |
\csname#2\endcsname |
| 485 |
}{% |
| 486 |
\csname end\@ET@currenvir \endcsname |
| 487 |
\ifx\@ET@mode\@empty\else $\fi |
| 488 |
\egroup |
| 489 |
\@ET@step@linenumber % Stepping correction. |
| 490 |
\if@filesw |
| 491 |
\immediate\write\@auxout{% |
| 492 |
\gdef\expandafter\noexpand |
| 493 |
\csname\@ET@arraywidth@csn\endcsname |
| 494 |
{\the\wd\@tempboxa}}% |
| 495 |
%% TODO: warning if changed!? |
| 496 |
\fi |
| 497 |
% No automatic line number at array line: |
| 498 |
\nolinenumbers |
| 499 |
\@ET@mode\ensuremath{\vcenter{\box\@tempboxa}}\@ET@mode % v1.3. |
| 500 |
\@ET@execute@outerhook |
| 501 |
\ifhmode \@centercr\relax \fi |
| 502 |
% \par must be executed for proper restart of printing line numbers |
| 503 |
% (think so). |
| 504 |
\@endpetrue % Outside \@flushglue environment, avoid indent ahead. |
| 505 |
%% TODO: slightly change for math mode around? Or give an error |
| 506 |
%% in math mode. |
| 507 |
} |
| 508 |
%% TODO: make \edtable \outer!? |
| 509 |
\def\@ET@normal@startline{% |
| 510 |
\@ET@step@linenumber |
| 511 |
\llap{\@ET@makeLineNumber \hskip\@ET@offset}% |
| 512 |
} |
| 513 |
\newdimen\@ET@offset |
| 514 |
\newdimen\ETextraoffset |
| 515 |
%% TODO: export to lineno.sty!? |
| 516 |
\newcount\c@ET@array |
| 517 |
\def\@ET@arraywidth@csn{ET@a@\romannumeral\c@ET@array} |
| 518 |
% |
| 519 |
%% TODO: .dtx |
| 520 |
\endinput |
| 521 |
|
| 522 |
%% VERSION HISTORY: |
| 523 |
v0.22 2003/01/13 First version, named `edtab02.sty', sent around, |
| 524 |
together with ednotes.sty. |
| 525 |
v0.23 2003/01/22 Added version history. |
| 526 |
v0.24 2003/01/27 Copyright notice. |
| 527 |
%%% v0.3 2003/03/03 Requires linenox0.sty. %% RETREATED |
| 528 |
%% TODO: reconsider, see `lineno[x].sty'. |
| 529 |
v0.25 2003/03/05 Added <[email protected]>. |
| 530 |
v0.26 2003/03/23 Added \@ET@startlinewith to wizard command list; |
| 531 |
moved redefinition \LT@get@widths from option code |
| 532 |
into \@ET@longtable so this really happens in |
| 533 |
line number mode only; moved \let\@ET@@halign\halign |
| 534 |
from \@ET@startlinewith to \AtBeginDocument. |
| 535 |
v0.27 2003/06/02 Added \ifvmode \noindent \fi to `edtable' definition; |
| 536 |
2003/06/10 added `lemma cannot run' to instructions. |
| 537 |
v0.28 2003/10/31 \@ET@cr@attach: moved \@ET@execu..., added \nobreak. |
| 538 |
Added \@ET@ampnotes and documentation: now working |
| 539 |
across entries. |
| 540 |
v1.0 2004/05/13 `ednotes.sty' etc., updated copyright. Renamed as |
| 541 |
`edtable.sty' for TUGboat article. |
| 542 |
\RequirePackage{lineno}, changed doc. accordingly. |
| 543 |
Removed `may be released under different name'. |
| 544 |
v1.10 2004/07/27 Looking for `longtabl.sty' for my Atari! |
| 545 |
2004/08/22 Added warning (screen/documentation) concerning |
| 546 |
ltabptch.sty. |
| 547 |
2004/08/23 Added suggestion of option `nolongtablepatch'; |
| 548 |
LPPL v1.3. |
| 549 |
v1.2 2004/08/31 Rearranged preamble concerning maintenance, |
| 550 |
removed `preliminary release'. |
| 551 |
2004/10/06 \newif -> \let...; option `nolongtablepatch'; |
| 552 |
changed documentation accordingly and for |
| 553 |
loading edtable.sty by lineno/ednotes option; |
| 554 |
\let\@ET@step@linenumber\stepLineNumber; use |
| 555 |
\ifLineNumbers. |
| 556 |
2004/10/07 Needed version numbers. |
| 557 |
2004/10/08 ltabptch warning -> error! |
| 558 |
2004/10/11 Disabled \RequirePackage{lineno}[...]; undid |
| 559 |
the `longtabl.sty' thing from 2004/07/27. |
| 560 |
2004/10/12 latex/3730. |
| 561 |
v1.2a 2004/11/07 LPPL v1.3a. |
| 562 |
v1.2b 2005/01/10 Contact via http. |
| 563 |
v1.3b 2005/03/04 Support for environments like `array' |
| 564 |
environment. The description of `edtable' was |
| 565 |
wrong in this respect! |
| 566 |
v1.3 2005/03/07 Adaptations in documentation, and extended usage |
| 567 |
instructions very much, correcting some |
| 568 |
errors as well. Acknowledgement to M. B. |
| 569 |
v1.3a 2005/03/09 Corrected numbering in `usage'. |
| 570 |
v1.3c 2005/03/15 \@centercr\relax, TODO on math mode. |
| 571 |
2005/04/09 `editory' -> `editorial'. |