Debian Codegraph @

texmf-dist/source/latex/play/play.dtx

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