summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/play/play.dtx
blob: f0be91f547dc5fba1c2711803961646b94ed33a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
% \iffalse meta-comment
%% play - Typesetting Drama with LaTeX2e
%
% Copyright (c) 1999 James Kilfiger
%
% The play package
% This program can redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or (at your option) any later
% version.
% \fi
%% \CheckSum{159}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
%\iffalse
%<*driver>
\documentclass{ltxdoc}
\begin{document}
\DocInput{play.dtx}
\end{document}
%</driver>
%\fi
%\title{Typesetting Drama with \LaTeX}
%\author{James Kilfiger |mapdn@csv.warwick.ac.uk|}
%\date{26th March 1999}
%\maketitle
%
%\begin{abstract}
%  A package and a class for typesetting plays and versed plays. 
%  It is especially
%  designed for typesetting short extracts of plays.
%\end{abstract}
% 
% \section{Usage}
% This is a small package for typesetting plays. It provides two new 
% environments: |play| and |verseplay|. The first is for prose dramas, and 
% second for plays in verse.  The environments are implemented as
% lists, and the 
% character's names are introduced by |\item| with an optional argument.
%
%   The verseplay environment takes an optional argument for the width of 
% the box for the names of the characters, it defaults to 8em.
%
%   In addition there are three commands: |\shortdirection|, which typesets its 
% argument emphasized and in brackets, |\longdirection| which typesets its 
% argument emphasized and displayed, and |\phantomline| which is intended for 
% making long indentations when one character finishes the line of verse 
% started by another. 
%
% If the class form is used then |\act|, |\scene| and |\setting|
% commands are defined, to introduce acts and scenes (these commands
% take no argument) And to describe a setting
%
% If the |lineno| option is given to the package or class then
% verseplays will be numbered, every five lines.  This may be adjusted
% by the |linemodulo| counter. Setting |linemodulo| to zero turns off
% line numbering.  Line numbering the play environment is beyond the
% scope of this package, but may be achieved with the |lineno| package
%
%   When quoting from a play the entire environment should be embedded
% in a quote environment.
%
%   The typesetting in this file is based on the recommendations in the the
% \emph{MHRA Style Book}~\cite{MRHA}.
%
% I have adapted a number of ideas from  Antti-Juhani Kaijanaho's |plari|
% class~\cite{plari}. Particularly the |\act|, |\scene|, and |\setting| commands.
% However the implementation of these commands is my own.
% \section{Changes}
% I've included a |\speaker| command, for better markup. See the
% examples below.  I've provided a |thesetting| environment, which is
% how it should have been done from the start.  The |\setting| command
% is preseverved.  I've added started forms of the act and scene
% commands. These started forms take 1 argument, the title of the
% scene or act.  They format of the character's names is now more
% flexible the commands |\speakerfont| and |\speakerdelim| may be set,
% with |\renewcommand|. Similarly there are |\shortdirectionopen| and
% |shortdirectionclosed| which are the delimiters of short directions
% (normally `(' and `)') and |\directionfont| normally |\em|
% 
% \begin{thebibliography}{2}
% \bibitem{MRHA}\emph{MRHA Style book}, Glanville Price, et.~al., fifth
% edition (London: MRHA, 1996)
% \bibitem{plari} The |plari| class, Available from\\
% |CTAN:macros/latex/contrib/supported/plari|
% \end{thebibliography}
%  \section{A sample}
%   \begin{verbatim}
%   \begin{play}
%   \speaker{Brassbound}It will teach other scoundrels to respect widows and 
%   orphans. Do you forget there is such a thing as justice?
%   \speaker{Lady Cicely}\shortdirection{gaily shaking out the finished coat}
%   Oh, if you are going to dress yourself in ermine and call yourself
%   Justice, I give you up. You are just your uncle over again; only he
%   gets \pounds5000 a year for it, and you do it for nothing.
%   \longdirection{She holds up the coat to see whether any further repairs
%   are needed but, seeing none, folds it carefully away.}
%   \speaker{Brassbound \shortdirection{sulkily}} You twist my words very
%   cleverly. [taken from \emph{Captain Brassbound's Conversion \textsc{ii}]
%   \end{play}
%   
%   \begin{verseplay}[9em]
%   \speaker{Macbeth}Prithee, peace!\\
%      I dare do all that may become a man;\\
%      Who dares do more is none.
%   \speaker{Lady Macbeth}\phantomline{Who dares do more is none.}What beast 
%   was't then\\
%      That made you break this enterprise to me?\\
%      When you durst do it, then you were a man;\\
%      And to be more tha what you were, you would\\
%      Be so much more the man. Nor time nor place\\
%      Did then adhere, and you would make both;\\
%      They have made themselves, and that their fitness now\\
%      Does unmake you.
%   \end{verseplay}
% \end{verbatim}
%\StopEventually{\relax}
%\section{Implementation}
% We start by declaring ourself. We generate the correct header
% for a package or class.
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
%<*justpackage>
\ProvidesPackage{play}[1999/03/26 A LaTeX package for typesetting plays]
%</justpackage>
%<*class>
\ProvidesClass{play}[1999/03/26 A LaTeX class for typesetting plays]
%</class>
%    \end{macrocode}
%
% The definitions for line numbering are taken in part from the lineno
% package. 
% The line numbering
% commands are, by default, set to |\relax|.
%
%    \begin{macrocode}
\DeclareOption{lineno}{
  \newcommand{\PLthemoduloline}{\@tempcnta=\c@line
    \divide\@tempcnta\c@linemodulo
    \multiply\@tempcnta\c@linemodulo
    \ifnum\@tempcnta=\c@line\arabic{line}\fi}
  \newcommand{\@PLtypemodline}{%
    \ifnum\value{linemodulo}=0%
    \else
      \marginpar{\scriptsize\PLthemoduloline}%
    \fi}
  \newcommand{\@PLputline}{%
    \@PLtypemodline
    \refstepcounter{line}}%
}
%    \end{macrocode}
%
% If we are generating a class then we load the book class, with all the
% remaining options. 
%    \begin{macrocode}
%<*class>
\DeclareOption*{%
  \PassOptionsToClass{\CurrentOption}{book}}
%</class>
\ProcessOptions\relax
%<*class>
\LoadClass{book}
%    \end{macrocode}
%
% For the class we define Act, scene and setting macros.  These are not
% required for the package (which is intended for typesetting quotes
% from plays), and so are omitted.  The Act and scene macros use Chapter
% and section. Another reason for not defining them in the package is
% that we cannot be sure that |\chapter| will be defined. One can
% redefine |\actname| and |\scenename| if `Act' and `Scene' are not what
% is required. The |\setting| command should come before the
% |\begin{play}| command. 
% An environment is a much more sencible way of doing the setting. So
% I've included that also. 
% The starred forms of act and scene take an argument, the title of
% the act or scene.
% This whole section is a mess and need total revision
%    \begin{macrocode}
\newcounter{act}
\newcounter{scene}[act]
\renewcommand{\theact}{\Roman{act}}
\renewcommand{\thescene}{\theact.\arabic{scene}}
\newcommand{\actname}{Act}
\newcommand{\scenename}{Scene}

\DeclareRobustCommand\act{\@ifstar{\@sact}{\@act}}

\newcommand{\@act}{%
  \refstepcounter{act}
  \chapter*{\actname~\theact}
  \addcontentsline{toc}{chapter}{\actname~\theact}}

\newcommand{\@sact}[1]{%
  \refstepcounter{act}
  \chapter*{#1}
  \addcontentsline{toc}{chapter}{#1}}

\DeclareRobustCommand{\scene}{\@ifstar{\@sscene}{\@scene}}

\newcommand{\@scene}{%
  \refstepcounter{scene}
  \section*{\scenename~\arabic{scene}}
   \addcontentsline{toc}{section}{\scenename~\arabic{scene}}}

\newcommand{\@sscene}[1]{%
  \refstepcounter{scene}
  \section*{#1}
  \addcontentsline{toc}{section}{\scenename~\arabic{scene}}}

\DeclareRobustCommand{\setting}[1]{\thesetting #1\endthesetting}
\newenvironment{thesetting}{\em\quotation}{\endquotation}
%</class>
%    \end{macrocode}
%
% Here is the stuff for linenumbering. Providecommands are used to stop
% errors caused if these macros weren't defined by the lineno option. 
% The |\typeline| command can be used to put a line number on arbitrary
% lines. 
%    \begin{macrocode}
\newcounter{line}
\newcounter{linemodulo}\setcounter{linemodulo}{5}
\providecommand{\@PLtypemodline}{\relax}
\providecommand\@PLthemoduloline{\relax}
\providecommand{\typeline}{\marginpar{\scriptsize\theline}}
\providecommand{\@PLputline}{\relax}
%    \end{macrocode}
%
% The commands |\shortdirection| and |\longdirection| are for
% instructions to the actors (or whoever). They are formated
% differently. A short direction after a character's name is best put in
% the argument to |\item|. Long directions before the first line of
% dialogue should be put before the |\begin{play}| line, to avoid
% missing |\item| errors.
%    \begin{macrocode}
\newcommand\shortdirectionopen{(}
\newcommand\shortdirectionclose{)}
\newcommand\directionfont{\em}
\DeclareRobustCommand*{\speaker}[1]{\item[#1]}
\DeclareRobustCommand*{\shortdirection}[1]{\shortdirectionopen
                                           {\directionfont#1\/}%
                                           \shortdirectionclose}
\DeclareRobustCommand{\longdirection}[1]%
           {{\list{}{\setlength{\topsep}{0pt}}\item\directionfont#1\endlist}}
%    \end{macrocode}
% The phantom line is a phantom of it's argument.
% This causes problems if the character's name is longer than the 8em
% (or whatever) used to typeset their name in.
%    \begin{macrocode}
\DeclareRobustCommand*{\phantomline}[1]{\leavevmode\phantom{#1}}
%    \end{macrocode}
%
% The playlabel is the format for the character's name. I've just kept
% it as a name is small caps. Should I add a colon?
%    \begin{macrocode}
\newcommand*\speakerfont{\scshape}
\newcommand*\speakerdelim{}
\newcommand*{\@PLplaylabel}[1]{{\speakerfont#1\speakerdelim\hfil}}
%    \end{macrocode}
%
% The |verseplay| environment is modeled on the verse environment. It takes
% an optional argument for the width of the box the names are typeset
% in. The character names are set flush to the left margin. Note that it
% is the |\\| command which generates the lineno. Understanding this is
% the key to good linenumbering.
%    \begin{macrocode}
\newenvironment{verseplay}[1][8em]{%
  \list{}{%
    \setcounter{line}{0}
    \refstepcounter{line}
    \def\\{\@PLputline\@centercr}
    \setlength\labelwidth{#1}
    \setlength\itemindent{-3em}
    \setlength\leftmargin{\labelwidth}
    \setlength{\itemsep}{0pt}
    \setlength{\parsep}{0pt}
    \addtolength\leftmargin{-\itemindent}
    \addtolength\leftmargin{\labelsep}
    \setlength\listparindent{\itemindent}
    \let\makelabel=\@PLplaylabel
  }
}
{\endlist}
%    \end{macrocode}
%
% The |play| environment is modeled on the description environment. (In
% fact apart from the typesetting of the label as \textsc{sc} instead of
% \textbf{bold} it is the description environment)
%    \begin{macrocode}
\newenvironment{play}{%
  \list{}{%
    \setlength{\labelwidth}{0pt}
    \setlength{\labelsep}{1em}
    \setlength{\leftmargin}{1em}
    \setlength{\itemsep}{0pt}
    \setlength{\parsep}{0pt}
    \let\makelabel=\@PLplaylabel
  }
}
{\endlist}
% </package>
%    \end{macrocode}
% \Finale