# Defining a screenplay dialog environment for breaking across pages

Edit: consider this a followup to the answer here https://tex.stackexchange.com/a/63847/64528

I'm trying to create a LaTeX/XeTeX template for screenwriting, specifically to output from an Emacs major mode I wrote.

I'd like to define an environment "dialog" that behaves in a rather special way when breaking across pages, i.e. if a page break occurs within the environment text, the paragraph "(MORE)" will be appended at the bottom of the text on the first page, then, on the following page, the character name will be repeated with the string " (CONT'D)" appended.

An approximated example of how this would look:

        BOBBY DARIN
Lorem ipsum dolor sit amet,
hendrerit tempor tellus. Donec
pretium posuere tellus. Proin quam
nisl, tincidunt et, mattis eget,
convallis nec, purus. Cum sociis
natoque penatibus et magnis dis
parturient montes, nascetur
ridiculus mus.
(MORE)

------------ page break ------------

BOBBY DARIN (CONT'D)
Nulla posuere. Donec
vitae dolor. Nullam tristique diam
non turpis. Cras placerat accumsan
nulla. Nullam rutrum. Nam
vestibulum accumsan nisl. Lorem
ipsum dolor sit amet, consectetuer
tempor tellus. Donec pretium
posuere tellus. Proin quam nisl,
tincidunt et, mattis eget.


The caveat is, of course, that this is a template, and as such the input remains variable, thus this cannot be split manually.

Just to make matters more difficult, sometimes the initial character name may appear with the " (CONT'D)" string already, e.g. "BOBBY DARIN (CONT'D)", in which case it ought not to be repeated on the second page...

The current environment, which does not attempt to do any of this:

\newenvironment{dialog}[1]{
\begingroup
\leftskip=1.5in
\hspace*{1.2in}\parbox[t]{4in}{#1}
\parskip=0pt\par\nopagebreak[4]
\rightskip=2in
}{\par\endgroup}


Does anyone know how to accomplish this?

Some notes:

• I don't think tables will work, because the "dialog" text would essentially be in a single cell
• The character name on the second page can't really be in the page header.
• If anyone is wondering, yes I have been in touch with the Celtx people and no they won't give me their LaTeX class/template. – rnkn Oct 19 '14 at 0:45
• You could adapt/use the code from show-continued-for-nested-description-list-item-on-page-break. That is, with the code in that answer your could write \Option{CHARACTER NAME} to give the dialog for a given character. – Andrew Mar 3 '15 at 0:03
• @Andrew thanks, using that method I think I'm halfway there. – rnkn Mar 24 '15 at 3:41