362 \fi}
363
\list@clearing@reg Clears the lists for\read@linelist
364\newcommand*{\list@clearing@reg}{%
365 \list@clear{\line@list}%
366 \list@clear{\insertlines@list}%
367 \list@clear{\actionlines@list}%
368 \list@clear{\actions@list}}
\get@linelistfile ledmac can take advantage of the LaTeX ‘safe file input’ macros to get the line-list file.
369\newcommand*{\get@linelistfile}[1]{%
370 \InputIfFileExists{#1}{%
371 \global\noteschanged@false
372 \begingroup
373 \catcode‘\[=1 \catcode‘\]=2
374 \makeatletter \catcode‘\^^M=9}{%
375 \led@warn@NoLineFile{#1}%
376 \global\noteschanged@true
377 \begingroup}%
378}
379
This version of \read@linelist creates list macros containing data for the entire section, so they could get rather large. It would be no more difficult to read the line-list file incrementally rather than all at once: we could read, at the start of each paragraph, only the commands relating to that paragraph. But this would require that we have two line-lists open at once, one for reading, one for writing, and on systems without version numbers we’d have to do some file renaming outside of LaTeX for that to work. We’ve retained this slower approach to avoid that sort of hacking about, but have provided the\pausenumberingand
\resumenumberingmacros to help you if you run into macro memory limitations (see p. 11 above).
19.5 Commands within the line-list file
This section defines the commands that can appear within a line-list file. They all have very short names because we are likely to be writing very large numbers of them out. One macro, \@l, is especially short, since it will be written to the line-list file once for every line of text in a numbered section. (Another of these commands, \@lab, will be introduced in a later section, among the cross- referencing commands it is associated with.)
When these commands modify the various page and line counters, they de- liberately do not say \global. This is because we want them to affect only the counter values within the current group when nested calls of \@ref occur. (The code assumes throughout that the value of \globaldefsis zero.)
The macros withactionin their names contain all the code that modifies the action-code list: again, this is so that they can be turned off easily for nested calls of \@ref.
\@l
\@l@reg
\@ldoes everything related to the start of a new line of numbered text.
In order to get the \setlinenum to work I had to slip in some new code at the start of the macro, to get the timing of the actions correct. The problem was that my original naive implementation of\setlinenumhad a unfortunate tendency to change the number of the last line of thepreceding paragraph. The new code is sort of based on the page number handling and\setlineIt seems that a lot of fiddling with the line number internals is required.
In November 2004 in order to accurately determine page numbers I added these to the macro. It is now:
\@l{hpage counter numberi}{hprinted page numberi}
I don’t (yet) use the printed number (i.e., the\thepage) but it may come in handy later. The macro\fix@pagechecks if a new page has started.
380\newcommand{\@l}[2]{%
381 \fix@page{#1}%
382 \@l@reg}
383\newcommand*{\@l@reg}{%
384 \ifx\l@dchset@num\relax \else
385 \advance\absline@num \@ne
386 \set@line@action
387 \let\l@dchset@num=\relax
388 \advance\absline@num \m@ne
389 \advance\line@num \m@ne
390 \fi
Now we are back to the original code.
First increment the absolute line-number, and perform deferred actions relating to page starts and sub-lines.
391 \advance\absline@num \@ne
392 \ifx\next@page@num\relax \else
393 \page@action
394 \let\next@page@num=\relax
395 \fi
396 \ifx\sub@change\relax \else
397 \ifnum\sub@change>\z@
398 \sublines@true
399 \else
400 \sublines@false
401 \fi
402 \sub@action
403 \let\sub@change=\relax
404 \fi
Fix the lock counters, if necessary. A value of 1 is advanced to 2; 3 advances to 0; other values are unchanged.
405 \ifcase\@lock
19.5 Commands within the line-list file 61
406 \or
407 \@lock \tw@
408 \or \or
409 \@lock \z@
410 \fi
411 \ifcase\sub@lock
412 \or
413 \sub@lock \tw@
414 \or \or
415 \sub@lock \z@
416 \fi
Now advance the visible line number, unless it’s been locked.
417 \ifsublines@
418 \ifnum\sub@lock<\tw@
419 \advance\subline@num \@ne
420 \fi
421 \else
422 \ifnum\@lock<\tw@
423 \advance\line@num \@ne \subline@num \z@
424 \fi
425 \fi}
426
\@page \@page{hnumi}marks the start of a new output page; its argument is the number of that page.
First we reset the visible line numbers, if we’re numbering by page, and store the page number itself in a count.
427\newcommand*{\@page}[1]{%
428 \ifbypage@
429 \line@num \z@ \subline@num \z@
430 \fi
431 \page@num=#1\relax
And we set a flag that tells\@lthat a new page number is to be set, because other associated actions shouldn’t occur until the next line-start occurs.
432 \def\next@page@num{#1}}
433
\last@page@num
\fix@page
\fix@pagebasically replaces\@page. It determines whether or not a new page has been started, based on the page values held by \@l.
434\newcount\last@page@num
435 \last@page@num=-10000
436\newcommand*{\fix@page}[1]{%
437 \ifnum #1=\last@page@num
438 \else
439 \ifbypage@
440 \line@num=\z@ \subline@num=\z@
441 \fi
442 \page@num=#1\relax
443 \last@page@num=#1\relax
444 \def\next@page@num{#1}%
445 \fi}
446
\@pend
\@pendR
\@lopL
\@lopR
These don’t do anything at this point, but will have been added to the auxiliary file(s) if the ledpar package has been used. They are just here to stop ledmac from moaning if the ledpar is used for one run and then not for the following one.
447\newcommand*{\@pend}[1]{}
448\newcommand*{\@pendR}[1]{}
449\newcommand*{\@lopL}[1]{}
450\newcommand*{\@lopR}[1]{}
451
\sub@on
\sub@off
The\sub@onand\sub@offmacros turn sub-lineation on and off: but not directly, since such changes don’t really take effect until the next line of text. Instead they set a flag that notifies\@lof the necessary action.
452\newcommand*{\sub@on}{\ifsublines@
453 \let\sub@change=\relax
454 \else
455 \def\sub@change{1}%
456 \fi}
457\newcommand*{\sub@off}{\ifsublines@
458 \def\sub@change{-1}%
459 \else
460 \let\sub@change=\relax
461 \fi}
462
\@adv The\@adv{hnumi}macro advances the current visible line number by the amount specified as its argument. This is used to implement\advanceline.
463\newcommand*{\@adv}[1]{\ifsublines@
464 \advance\subline@num by #1\relax
465 \ifnum\subline@num<\z@
466 \led@warn@BadAdvancelineSubline
467 \subline@num \z@
468 \fi
469 \else
470 \advance\line@num by #1\relax
471 \ifnum\line@num<\z@
472 \led@warn@BadAdvancelineLine
473 \line@num \z@
474 \fi
475 \fi
476 \set@line@action}
477
\@set The\@set{hnumi}macro sets the current visible line number to the value speci- fied as its argument. This is used to implement\setline.
19.5 Commands within the line-list file 63
478\newcommand*{\@set}[1]{\ifsublines@
479 \subline@num=#1\relax
480 \else
481 \line@num=#1\relax
482 \fi
483 \set@line@action}
484
\l@d@set
\l@dchset@num
The\l@d@set{hnumi}macro sets the line number for the next\pstart... to the value specified as its argument. This is used to implement\setlinenum.
\l@dchset@numis a flag to the\@lmacro. If it is not\relaxthen a linenumber change is to be done.
485\newcommand*{\l@d@set}[1]{%
486 \line@num=#1\relax
487 \advance\line@num \@ne
488 \def\l@dchset@num{#1}}
489\let\l@dchset@num\relax
490
\page@action \page@actionadds an entry to the action-code list to change the page number.
491\newcommand*{\page@action}{%
492 \xright@appenditem{\the\absline@num}\to\actionlines@list
493 \xright@appenditem{\next@page@num}\to\actions@list}
\set@line@action \set@line@actionadds an entry to the action-code list to change the visible line number.
494\newcommand*{\set@line@action}{%
495 \xright@appenditem{\the\absline@num}\to\actionlines@list
496 \ifsublines@
497 \@l@dtempcnta=-\subline@num
498 \else
499 \@l@dtempcnta=-\line@num
500 \fi
501 \advance\@l@dtempcnta by -5000
502 \xright@appenditem{\the\@l@dtempcnta}\to\actions@list}
\sub@action \sub@actionadds an entry to the action-code list to turn sub-lineation on or off, according to the current value of the\ifsublines@flag.
503\newcommand*{\sub@action}{%
504 \xright@appenditem{\the\absline@num}\to\actionlines@list
505 \ifsublines@
506 \xright@appenditem{-1001}\to\actions@list
507 \else
508 \xright@appenditem{-1002}\to\actions@list
509 \fi}
\lock@on
\do@lockon
\do@lockonL
\lock@on adds an entry to the action-code list to turn line number locking on.
The current setting of the sub-lineation flag tells us whether this applies to line numbers or sub-line numbers.
Adding commands to the action list is slow, and it’s very often the case that a lock-on command is immediately followed by a lock-off command in the line-list file, and therefore really does nothing. We use a look-ahead scheme here to detect such pairs, and add nothing to the line-list in those cases.
510\newcommand*{\lock@on}{\futurelet\next\do@lockon}
511\newcommand*{\do@lockon}{%
512 \ifx\next\lock@off
513 \global\let\lock@off=\skip@lockoff
514 \else
515 \do@lockonL
516 \fi}
517\newcommand*{\do@lockonL}{%
518 \xright@appenditem{\the\absline@num}\to\actionlines@list
519 \ifsublines@
520 \xright@appenditem{-1005}\to\actions@list
521 \ifnum\sub@lock=\z@
522 \sub@lock \@ne
523 \else
524 \ifnum\sub@lock=\thr@@
525 \sub@lock \@ne
526 \fi
527 \fi
528 \else
529 \xright@appenditem{-1003}\to\actions@list
530 \ifnum\@lock=\z@
531 \@lock \@ne
532 \else
533 \ifnum\@lock=\thr@@
534 \@lock \@ne
535 \fi
536 \fi
537 \fi}
538
\lock@off
\do@lockoff
\do@lockoffL
\skip@lockoff
\lock@offadds an entry to the action-code list to turn line number locking off.
539\newcommand*{\do@lockoffL}{%
540 \xright@appenditem{\the\absline@num}\to\actionlines@list
541 \ifsublines@
542 \xright@appenditem{-1006}\to\actions@list
543 \ifnum\sub@lock=\tw@
544 \sub@lock \thr@@
545 \else
546 \sub@lock \z@
547 \fi
548 \else
549 \xright@appenditem{-1004}\to\actions@list
550 \ifnum\@lock=\tw@
551 \@lock \thr@@
552 \else
19.5 Commands within the line-list file 65
553 \@lock \z@
554 \fi
555 \fi}
556\newcommand*{\do@lockoff}{\do@lockoffL}
557\newcommand*{\skip@lockoff}{\global\let\lock@off=\do@lockoff}
558\global\let\lock@off=\do@lockoff
559
\n@num
\n@num@reg
This macro implements the \skipnumberingcommand. It uses a new action code, namely 1007.
560\newcommand*{\n@num}{\n@num@reg}
561\newcommand*{\n@num@reg}{%
562 \xright@appenditem{\the\absline@num}\to\actionlines@list
563 \xright@appenditem{-1007}\to\actions@list}
564
\@ref
\insert@count
\@ref marks the start of a passage, for creation of a footnote reference. It takes two arguments:
• #1, the number of entries to add to \insertlines@list for this reference.
This value, here and within\edtext, which computes it and writes it to the line-list file, will be stored in the count\insert@count.
565 \newcount\insert@count
• #2, a sequence of other line-list-file commands, executed to determine the ending line-number. (This may also include other\@ref commands, corre- sponding to uses of \edtextwithin the first argument of another instance of \edtext.)
\dummy@ref When nesting of \@refcommands does occur, it’s necessary to temporarily rede- fine\@ref within\@ref, so that we’re only doing one of these at a time.
566\newcommand*{\dummy@ref}[2]{#2}
\@ref@reg The first thing \@ref(i.e. \@ref@reg) itself does is to add the specified number of items to the\insertlines@list list.
567\newcommand*{\@ref}[2]{%
568 \@ref@reg{#1}{#2}}
569\newcommand*{\@ref@reg}[2]{%
570 \global\insert@count=#1\relax
571 \loop\ifnum\insert@count>\z@
572 \xright@appenditem{\the\absline@num}\to\insertlines@list
573 \global\advance\insert@count \m@ne
574 \repeat
Next, process the second argument to determine the page and line numbers for the end of this lemma. We temporarily equate \@ref to a different macro that just executes its argument, so that nested\@refcommands are just skipped this time. Some other macros need to be temporarily redefined to suppress their action.
575 \begingroup
576 \let\@ref=\dummy@ref
577 \let\page@action=\relax
578 \let\sub@action=\relax
579 \let\set@line@action=\relax
580 \let\@lab=\relax
581 #2
582 \global\endpage@num=\page@num
583 \global\endline@num=\line@num
584 \global\endsubline@num=\subline@num
585 \endgroup
Now store all the information about the location of the lemma’s start and end in\line@list.
586 \xright@appenditem%
587 {\the\page@num|\the\line@num|%
588 \ifsublines@ \the\subline@num \else 0\fi|%
589 \the\endpage@num|\the\endline@num|%
590 \ifsublines@ \the\endsubline@num \else 0\fi}\to\line@list
Finally, execute the second argument of \@ref again, to perform for real all the commands within it.
591 #2}
592