[comp.text.tex] How do I combine Midnight Macros dolines with LaTeX \item ?

grodan@cyklop.nada.kth.se (Mats G L|fdahl) (05/29/91)

Hi,

I recently picked up the midnight macros, since the dolines.tex stuff
seemed to be useful for what I'm trying to do.

I'm working on a LaTeX style for theatre manuscripts where the macros
for lines are made with \item. With a line I mean something a role 
character says, like 
	Hamlet:	To be or not to be, that is 
                the question.
that is created with essentially
	\item[Hamlet:] To be or not to be, that is the question.

In many cases one wants to decide the line breaks from the input and
get 
	Hamlet:	To be or not to be, 
		that is the question.
from
	\vitem[Hamlet:]	To be or not to be,
               		that is the question.

The trouble is to write the \vitem command ('v' for verse). I thought
I'd be able to combine the midnight doline stuff with LaTeX items, but
I can't seem to get it right.

I tried a number of approaches, inspired from the manual pp.10-11, but
with no success: 
-------------------------------------------------------------------------
\def\beforelines{\def\enddolines{}}  		% 'Hamlet:' ends up _after_
\def\everyline#1{\hbox{#1}}            	 	% the text.
\def\afterlines{\par}
\let\enddolines=\relax
\def\vitem[#1]{\item[#1]\begindolines}
-------------------------------------------------------------------------  
...
\def\vitem[#1]{\begindolines\item[#1]}          % Gives LaTeX error
-------------------------------------------------------------------------
\def\beforelines{\def\enddolines{}\item}        % I get:
...						% [Hamlet:] To be or not to be,
\def\vitem{\begindolines}			% that is the question.
-------------------------------------------------------------------------


Does anybody out there know how to combine the doline stuff with
\item? I'll be equally glad for other solutions to my problem, but I
don't want solutions built on making \vitem start a group (or
environment), that is ended by the next command. I've implemented that
already, in a plain TeX version, but I'm not very happy with it.

                    /Mats

--
 -----------------------------------------------------------------------------
 Mats Lofdahl, Stockholm Observatory, S-133 36 Saltsjobaden | +46 - 8 16 44 75 
 -----------------------------------------------------------------------------
 Internet: lofdahl@astro.su.se | Bitnet: grodan@sekth | Sunet: royacs::lofdahl
 -----------------------------------------------------------------------------

marcel@cs.caltech.edu (Marcel van der Goot) (05/31/91)

Mats G L|fdahl (grodan@cyklop.nada.kth.se) wrote:
> In many cases one wants to decide the line breaks from the input and get 
>	Hamlet:	To be or not to be, 
>		that is the question.
> from
>	\vitem[Hamlet:]	To be or not to be,
>              		that is the question.
>
> The trouble is to write the \vitem command ('v' for verse). I thought
> I'd be able to combine the midnight doline stuff with LaTeX items, but
> I can't seem to get it right.

Your first solution seems the most promising, since the other two
expand \item at the wrong moment. The reason for the weird behavior
of the first solution (namely, to put the item label after the item),
is that \item prints the label with the help of \everypar. \everypar
is a token sequence that is inserted when a new paragraph starts, i.e.,
when you switch from vertical to horizontal mode. However, \begindolines
does not force such a switch; therefore the text of the item is set
in vertical mode, and the label is not printed in the proper place.

One can force the switch to horizontal mode by something like
\leavevmode or \noindent. However, if you just insert that, the
line breaks will be wrong: the hboxes produced by \everyline will be
put next to each other instead of under each other.

Here are two solutions that more or less work:

\def\beforelines{\def\enddolines{}}
\def\everyline#1{\hbox{\strut\ignorespaces #1}}
\def\afterlines{\par}
\def\finishdolines{\egroup}
\let\enddolines=\relax
\def\vitem[#1]{\item[#1]\leavevmode\vtop\bgroup\begindolines}

Or the same definitions except for

\let\finishdolines=\relax
\def\vitem[#1]{\item[#1]\leavevmode\par\begindolines}

In both solutions all lines of the verse have the same indentation.
In the first solution, the verse starts on the same line as the label,
and the indentation is determined by the (actual) width of the label.
Therefore, if, in the particular list environment you are using, some
labels are wider than \labelwidth, then not all verses will be indented
equally. (E.g., in the (article style) description environment, \labelwidth
is 0.)

The second solution puts the label on a separate line, the verse below
it. In that case, the indentation of the verse is determined by
\leftmargin of the list environment, which is the same for all verses.
(In article style, try the enumerate environment rather than the
description environment.)

The disadvantage (or is it an advantage?) of the first solution is that
it does not allow page breaks within the verse; the second solution does
allow page breaks. Both solutions have the problem that the text of a
\vitem has to be terminated by an empty line. (If you want an empty line
in a verse, type "~" on the line.)

I would suggest that you use your own list environment with the
proper parameter settings, rather than description or enumerate or so
(see section 5.7) --- but you had probably thought of that yourself.

Note that if only few verses need to be typeset, it is easier to
just denote each line break by "\\" as in LaTeX's verse environment.


                                          Marcel van der Goot
 .----------------------------------------------------------------
 | Blauw de viooltjes,                    marcel@vlsi.cs.caltech.edu
 |    Rood zijn de rozen;
 | Een rijm kan gezet
 |    Met plaksel en dozen.
 |