Mojca Miklavec wrote:
Paul Tremblay wrote:
What is the best way to number lines of poetry?
1 This is the first line This is the second line ...
5 this is the fifth ...
10 this is the tenth.
This is a solution, written in plain TeX. I hope it is commented well enough so that you can change it if necessary. You have to surrond the code with \start...\stop..., but I hope you can do it, otherwise ask again on the list.
You can change the current line number any time by simply typing \lineno=999. You probably have to set \lineno to 0 every time you start typesetting a poem and restore \everypar={} after you are done with the current poem (in the definition of \startnumberedpoem ... \stopnumberedpoem of course, not manually).
The code attaches some stuff before every paragraph and there's a macro that checks if the current paragraph number is divisible by five. It is a macro with square complexity, so if you want to typeset Iliad or Odyssey :), please let me know so that I'll change it to be more efficient :)
The code has a small drawback: you have to write \\ for blank lines. After I wrote the maco I noticed some comments about redefining the \par command in Appendix D of the TeXBOOK, typesetting verbatim. If I manage to fix that too, I'll post it here.
%%%%%%%%%%%%%%%%%%
% new counter for counting lines % it is set to 0 at the beginning, % but you can redefine it any time by saying \lineno=7 or similar \newcount\lineno % if 0, nothing happens, if 1, no line number will be printed % and the line number won't advance for one \newcount\isemptyline
% templineno = lineno + 5 % do { % templineno = templineno - 5 % } while (templineno > 5); % % if (templineno == 0) { % print lineno % }
% only prints \the\lineno if it is divisible by 5 \def\printonlyfives{% % define a new counter 'templineno' \newcount\templineno % set the temporary counter to the line counter \templineno=\lineno % subtract 5 from the temporary counter as long as the counter is positive \advance\templineno by5 \loop\advance\templineno by-5\ifnum\templineno>5\repeat % if the line number is divisible by 5, the temporary counter is 0 % and the line number will be printed out \ifnum\templineno=0{\the\lineno}\fi}
% add this before every paragraph: % - if this is not an empty line % - add one to the line number % - print the line number (if divisible by five) % - hfill (for right alignment) \everypar={\ifnum\isemptyline=0 \advance\lineno by1 \printonlyfives\fi\hfill}
% (if '\\' is already defined for something else, % you can use some other command name here) % this will switch off line numbering, make a new line % and switch line numbering on again \def\\{\isemptyline=1\crlf\isemptyline=0}
\obeylines \dorecurse{30}{the text goes here\par}
\setuplinenumbering [start=2, step=2, distance=-1em] \startlinenumbering \startlines \fakewords{5}{8} \fakewords{5}{8} \fakewords{5}{8} \fakewords{5}{8} \fakewords{5}{8} \fakewords{5}{8} \fakewords{5}{8} \fakewords{5}{8} \stoplines \stoplinenumbering \setupparagraphnumbering[state=start,distance=-1em] \fakewords{5}{8} \par \fakewords{5}{8} \par \fakewords{5}{8} \par \fakewords{5}{8} \par \fakewords{5}{8} \par \fakewords{5}{8} \par \fakewords{5}{8} \par \fakewords{5}{8} \par -- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------