# [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{%
\templinenumber=\LineNumber
\computelinenumber
}
\def\computelinenumber{%
\ifnum\templinenumber>\linestep
\expandafter\computelinenumber
\else
\ifnum\templinenumber=\linestep
\leavevmode\rlap{\kern\linenumberskip\the\LineNumber}%
\fi
\fi
}
\newenvironment{numberedpoem}
{\everypar{\everypar{\poemlinenumber}}%

%%%

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