ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: how to number poetry?
Date: Mon, 18 Jul 2005 15:44:37 +0200	[thread overview]
Message-ID: <42DBB245.1000003@wxs.nl> (raw)
In-Reply-To: <6faad9f0050718051840eba60b@mail.gmail.com>

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
-----------------------------------------------------------------

      reply	other threads:[~2005-07-18 13:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-13 20:59 Paul Tremblay
2005-07-14 17:14 ` Paul Tremblay
2005-07-18 12:18 ` Mojca Miklavec
2005-07-18 13:44   ` Hans Hagen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42DBB245.1000003@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).