[XeTeX] Bidipoem for dialogue poetry

Paul Isambert zappathustra at free.fr
Sun Oct 10 18:03:12 CEST 2010


  Le 10/10/2010 17:26, Gareth Hughes a écrit :
> Paul Isambert wrote:
>> That one is harder. Line number are no simple matter with traditional TeX.
>> Question: does bidipoem starts a new paragraph with every line? Then
>> something might be doable with \everypar.
>> Just try this in the poem environment: \everypar{test}. If ``test''
>> appears at the beginning of every line, then I might try to find a
>> solution.
> Hmm. Within the environment \everypar has no effect, but given outside
> the traditional poem, but within the font changing environment, it
> prints on each line including the  the 'zeroth' line. I'm not sure if
> this is the right way to do this, how might this work?

Ok, the following works on your file, but I don't know how robust it is:

%%%

\newcount\LineNumber \newcount\templinenumber
\newdimen\linenumberskip \linenumberskip=6em
\chardef\linestep=2
\def\poemlinenumber{%
   \advance\LineNumber1
   \templinenumber=\LineNumber
   \computelinenumber
   }
\def\computelinenumber{%
   \ifnum\templinenumber>\linestep
     \advance\templinenumber-\linestep
     \expandafter\computelinenumber
   \else
     \ifnum\templinenumber=\linestep
       \leavevmode\rlap{\kern\linenumberskip\the\LineNumber}%
     \fi
   \fi
   }
\newenvironment{numberedpoem}
   {\everypar{\everypar{\poemlinenumber}}%
    \begin{traditionalpoem}}
   {\end{traditionalpoem}}

%%%

You poem should now be enclosed in the "numberedpoem" environment.
You can change \linestep (on line 3) to any value; if it is set /n/, 
every /n/th line number is printed.
You can change \linenumberskip (on line 2), which sets the distance of 
the line number to the margin.
This is not thoroughly tested! Sorry for the syntax, it's not LaTeX-like 
(but you made me -- although you didn't ask! -- download so many 
packages so your file can work than I need a little revenge :) ).

Best,
Paul


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/xetex/attachments/20101010/24d3d2e4/attachment.html>


More information about the XeTeX mailing list