summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/frankenstein/unsupported/drama.sty
blob: b74e90f9742e3b853a2e696bdaf0d36218b131c6 (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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
%^^A* legal notices
% \iffalse
%
%   This program is part of the Frankenstein bundle for LaTeX.  
%
%   Copyright 1995-2001 Matt Swift <swift@alum.mit.edu>.
%
%   This file contains both the code and documentation for the
%   drama LaTeX package.  It will work ONLY if it is placed in a
%   proper directory.  Files called README, INSTALL, drama.tex
%   and drama.ins should have also been distributed to you
%   with this file.  See them for more information on how to typeset
%   the documentation with LaTeX and how to generate a version of this
%   file that will work faster than this one.
%
%   This program is free software; you may redistribute it and/or
%   modify it under the conditions of the LaTeX Project Public
%   License, either version 1.2 or (at your option) any later version.
%   The latest version of this license is in
%   http://www.latex-project.org/lppl.txt, and version 1.2 or later is
%   part of all distributions of LaTeX version 1999/12/01 or later.
%
%   This program is distributed in the hope that it will be useful,
%   but without any warranty; without even the implied warranty of
%   merchantability or fitness for a particular purpose.  See the
%   LaTeX Project Public License for more details.
%
% \fi  
%
%^^A* checks
%
%^^A NOTE:  The character table, with two %'s, will get written to all files.
%% \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         \~}
%
% \CheckSum{314}
%
%^^A** abstract
% \begin{abstract}
%   Defines macros for typesetting a basic production-style stage script.
% 
%   This package is useful but may have problems and is unsupported.
% \end{abstract}
% \tableofcontents
%
% \part{Discussion}
%
%  I am close to handling the insertion of a ``continued'' message at the top
%  of the page when a speech is broken across the page.  But it's not there
%  yet.
%
% \DescribeEnv{script}
%   This is the only environment so far, for a basic production-style stage
%   script.  It is implemented as a bitstyle: see the \package{bits} package
%   for details of use.  I think you only need to issue an
%   \cs\author\marg{author's name} and \cs\date\marg{date} command.  Also,
%   create an empty file called \file{bits.cfg} on your system (or put the
%   \cs\author declaration in it).
%
%  Options come in pairs (boldface is default):
%  \begin{description}
%    \item[\textmd{oneact}/multiact] Multiact scripts use act numbers; oneacts
%    just have scenes.
%  \end{description}
%
% \DescribeMacro\character
%   \cs\character\marg{full description}\marg{name}\marg{csname} defines a new
%   character.  \meta{full description} is used in the dramatis personae
%   listing.  \meta{name} is the name to use to refer to the character in stage
%   directions, and to introduce their speeches.  \cs\character defines a
%   command |\|\meta{csname} which prints \meta{name} in the font given in
%   \cs\DirectStyle.  Use this in stage directions.  It is an abbreviation
%   macro of category \cat{Character}; following spacing is handled
%   automatically for you. See the \package{abbrevs} package for details.  Also
%   defined is the command
% \DescribeMacro\SpeakAppend
%   |\|\meta{csname}|says|, which is used to introduce the character's
%   speeches.  The suffix ``says'' can be changed by redefining \cs\SpeakAppend
%   before using \cs\character.  You can also define it before loading the
%   \package{drama} package.
%
% \DescribeMacro\scene
% \DescribeMacro\act
%   Use \cs\scene and \cs\act to start acts and scenes.
%
% \DescribeMacro\direct
% \DescribeMacro\setstage
%   \cs\direct\marg{stage directions}.  Use \cs\setstage\marg{stage directions}
%   at the beginning of scenes and acts.
%
% \StopEventually{}
%
% \part{Implementation}
%
% \section{Version control}
%
%  \begin{macro}{\fileinfo}
%  \begin{macro}{\DoXUsepackagE}
%  \begin{macro}{\HaveECitationS}
%  \begin{macro}{\fileversion}
%  \begin{macro}{\filedate}
%  \begin{macro}{\docdate}
%  \begin{macro}{\PPOptArg}
% These definitions must be the first ones in the file.
%    \begin{macrocode}
\def\fileinfo{drama package (Frankenstein's heart)}
\def\DoXPackageS {}
\def\initelyHavECitationS {}
\def\fileversion{v0.2}
\def\filedate{1996/05/05}
\def\docdate{1996/05/05}
\edef\PPOptArg {%
  \filedate\space \fileversion\space \fileinfo
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% If we're loading this file from a \cs\ProcessDTXFile command (see the
% \package{compsci} package), then \cs\JusTLoaDInformatioN will be defined;
% othewise we assume it is not (that's why the FunkY NamE).
% 
% If we're loading from \cs\ProcessDTXFile, we want to load the packages listed
% in \cs\DoXPackageS (needed to typeset the documentation for this file) and
% then bail out.  Otherwise, we're using this file in a normal way as a
% package, so do nothing.  \cs\DoXPackageS, if there are any, are declared in
% the \ext{dtx} file, and, if you're reading the typeset documentation of this
% package, would appear just above.  (It's OK to call \cs\usepackage with an
% empty argument or \cs\relax, by the way.)
%    \begin{macrocode}
\makeatletter% A special comment to help create bst files.  Don't change!
\@ifundefined{JusTLoaDInformatioN} {%
  }{% ELSE (we know the compsci package is already loaded, too)
  \UndefineCS\JusTLoaDInformatioN
  \SaveDoXVarS
  \eExpand\csname DoXPackageS\endcsname\In {%use \csname in case it's undefined
    \usepackage{#1}%
  }%
  \RestoreDoXVarS
  \makeatother
  \endinput
}% A special comment to help create bst files.  Don't change!
%    \end{macrocode}
%
% Now we check for \LaTeX2e and declare the LaTeX package.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{drama}[\PPOptArg]
%    \end{macrocode}^^A special comment to help create bst files.  Don't change!
%
% ^^A NOTE: We have to compensate for the above backslashes, which are not
% ^^A       actually in the .dtx file the author works on, by adding to the
% ^^A       CheckSum.
%%
% \AddToCheckSum{17}^^A `dtx-update-checksum' automatically handles this.
% \AddToCheckSum{7}^^A The half a macrocode env. at the top is missed, however...
% \AddToCheckSum{10}^^A ... and so are the 5 \defs from the .dtx file 
%                   ^^A     that precede it.
% \IfCitations {%
%   \AddToCheckSum{2}^^A When \initelyHavECitationS is defined in
% }                  ^^A the .dtx file, we need 2 more in the CheckSum.
%
%
%    \begin{macrocode}
\RequirePackage{abbrevs,bits,dialogue,moredefs,relsize}
%\RequirePackage{xmark}
\let\sc@mark\Gobble
\VerboseErrors

\DeclareBooleanOptions{oneact}{multiact}
\ProcessOptions
%    \end{macrocode}
%
% \section{characters}
%
% \begin{macro}{\SpeakAppend}
% \begin{macro}{\sc@cast}
% \begin{macro}{\character}
% 
%    \begin{macrocode}
\providecommand\SpeakAppend {says}
\ReserveCS\sc@cast
\NewUserAbbrevDefiner\NewCharacterAbbrev{Character}
\let\TMFontCharacter\scshape
\newcommand*\character [3] {% args: dramper name csname
  \expandafter\NewCharacterAbbrev\csname #3\endcsname{#2}%
  \NewName* {#3\SpeakAppend} {} {%
    \speak{#2}%
  }%
  \addto@macro\sc@cast{,#1}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% The |\@cdr| gets rid of the first silly comma.
%    \begin{macrocode}
\newcommand\DramPer {%
  \ifx\sc@cast\LongEmpty\else
    {\larger\scshape Cast}%
    \relax\begin{verse}
    \edef\sc@t@a{\E@cdr\sc@cast\@nil}%
    \@for\sc@t@b:=\sc@t@a \do {%
      \sc@t@b\\%
    }%
    \relax\end{verse}%
%    \end{macrocode}
% Prepare for another set of characters.
%    \begin{macrocode}
    \InitCS\sc@cast
    \bigbreak
  \fi
}
%    \end{macrocode}
%
%       \subsubsection{sectioning}
%
%  \begin{macro}{\sc@toks@saved@output}
% We pull some fancy stuff with the output routine here.  The algorithm is a
% simpler version of Knuth's \cite[260ff]{knuth:texbook}.
%    \begin{macrocode}
\newtokens\sc@toks@saved@output
\sc@toks@saved@output=\output
%    \end{macrocode}
%  \end{macro}
%
% The |\sc@botmark|, if not empty, will contain text to be inserted at the top
% of the next page. It must contain vertical not horizontal material. 
%
% We actually need to communicate the boolean |sc@directing| via the mark,
% because only the information in the marks is guaranteed to reflect the state
% at the end of the page, and not several lines later.   
%    \begin{macrocode}
\providelength\sc@len

\newcommand\sc@outputwrapper {%
  \setlength{\sc@len}{\dp255}%
  \the\sc@toks@saved@output
  \def\sc@t@b {%
    \sc@botmark
    \addtolength{\sc@len}{-\prevdepth}%
    \kern\sc@len
  }%
  \InitCS\sc@t@a
  \ifx\sc@botmark\ShortEmpty
    \let\sc@t@a\sc@t@b
  \else
    \ifsc@directing
      \let\sc@t@a\sc@t@b
    \fi
  \fi
  \sc@t@a
}
\newcommand\script {%
  \MakeDirectTakeArg
  \relax\begin{Script}%
}
\NewName{endscript} {} {%
  \relax\end{Script}%
}
\NewName{script*} {} {%
  \MakeDirectTakeNoArg
  \relax\begin{Script}%
}
\NewName{endscript*} {} {%
  \relax\end{Script}%
}
\newcommand\sc@make@begin@bit@D [2] {% args: bitstyle copystyle
  \DefName{sc@begin@bit@#1@#2}{##1##2} {%
    \def\BitStyle{#1}%
    \sc@begin@bit@common{##1}{##2}%
    \PreBitAll
%
%    \ClaimXMarkTwo
%    \FrankenInfo{drama}{The script environment is changing \protect\output.}%
%    \output={\sc@outputwrapper}%
%    \let\maxdepth\maxdimen
%    \let\@maxdepth\maxdimen
    \if@oneact@
      \def\thepage {%
        \arabic{bitbitbit}\hspace{\@ne em}\arabic{page}%
      }%
    \else
      \def\thepage {%
        \arabic{bitbit}--\arabic{bitbitbit}\hspace{\@ne em}\arabic{page}%
      }%
    \fi
    \DramPer
%
    \@nameuse{PreBit#1}%
  }%
}
\newcommand\sc@make@end@bit@D [2]  {% args: bitstyle copystyle
  \DefName{sc@end@bit@#1@#2}{##1} {%
    \sc@possiblyfinishdirecting
    \TheEnd
    \FrankenInfo{drama}{\protect\output is back to normal now.}%
  }%
}
\NewBitstyle{Script}
\PromulgateComponentAcrossCopystyles{end@bit}{D}{Script}
\PromulgateComponentAcrossCopystyles{begin@bit}{D}{Script}

\newcommand\act {%
  \sc@possiblyfinishdirecting
  \sc@mark{\ShortEmpty}%
  \stepcounter{bitbit}%
  \pagebreak[3]%
  \bigskip
  \centerline{\relsize{2}Act \thebitbit}%
  \par
  \nobreak
  \smallskip
}
\newcommand\scene {%
  \sc@possiblyfinishdirecting
  \sc@mark{\ShortEmpty}%
  \stepcounter{bitbitbit}%
  \pagebreak[3]%
  \bigskip
  \centerline{\relsize{1}Scene \thebitbitbit}%
  \par
  \nobreak
  \smallskip
}
%    \end{macrocode}
%
%       \subsubsection{speakers and stage directions}
%
%    \begin{macrocode}
\newlength{\halfacross}
  \setlength{\halfacross}{\textwidth}
  \divide\halfacross by 2
\newlength{\quarteracross}
  \setlength{\quarteracross}{\textwidth}
  \divide\quarteracross by 4

\newenvironment{DramaTab} [1] {%
    \relax\begin{list}{} {%
        \setlength{\leftmargin}{#1}%
        \setlength{\listparindent}{\z@}%
        \sloppy
        }%
      \item\relax
  }{%
  \relax\end{list}%
}
\newcommand\setstage [1] {%
  \relax\begin{DramaTab}{\halfacross}%
    \DirectStyle
    \DirectOpen
    \ignorespaces
    #1%
    \unskip
    \DirectClose
  \relax\end{DramaTab}%
}
%    \end{macrocode}
%
% It is a question of style whether to announce the speaker's name a second
% time, if his speech continues after a stage direction in a paragraph by
% itself.  If the page breaks immediately before the stage direction, or
% duringit, no continuation message will be given.  If it breaks after the
% stage direction, and before the next speaker is announced with the |\speak|
% command, a continuation message appropriate to the speaker \emph{before} the
% stage direction is given.  Of course, sectioning commands will cancel any
% continuation messages. 
%
% Communicating via the mark is giving me a problem.  I need to solve this
% problem and replace @sc@bool with mark information.
%
% Also, when using the no-argument form on a source with arguments, you cannot
% swallow the spaces with |\ignorespaces|, because the open brace shields them.
%
% There are problems with certain combinations of taking arguments and
% reannouncing speakers after a stage direction.  I should draw a chart, and
% see how I can handle things.  
%  \begin{macro}{\DirectOpen}
%  \begin{macro}{\DirectClose}
% \mbox{}
%    \begin{macrocode}
\newcommand\DirectOpen {\textrm{(}}
\newcommand\DirectClose {\textrm{)}}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%    \begin{macrocode}
\newboolean{sc@directing}

\newcommand*\DirectNoArg {%
  \sc@noargs@finishdirecting
  \sc@direct
}
\newcommand\DirectWithArg [1] {%
  \sc@args@finishdirecting
  \sc@direct
  #1%
  \sc@really@finishdirecting
}
\newcommand\sc@direct {%
  \global\let\sc@lastmark\sc@themark
  \sc@mark{\ShortEmpty}%
  \sc@directingtrue
  \pagebreak[0]% mild encouragement
  \relax\begin{DramaTab}{\quarteracross}%
    \DirectStyle
    \DirectOpen
    \ignorespaces
}
\newcommand\sc@really@finishdirecting {%
  \unskip
  \DirectClose
  \relax\end{DramaTab}
  \sc@directingfalse
%  \sc@mark\expandafter{\sc@lastmark}% FIXME:
}
%    \end{macrocode}
% Looks like args version is null.
%    \begin{macrocode}
\ReserveCS\sc@args@finishdirecting
\newcommand\sc@noargs@finishdirecting {%
  \ifsc@directing
    \sc@really@finishdirecting
  \fi
}
\ReserveCS\sc@possiblyfinishdirecting
\newcommand\MakeDirectTakeArg {%
  \let\sc@possiblyfinishdirecting\sc@args@finishdirecting
  \let\direct\DirectWithArg
}
\newcommand\MakeDirectTakeNoArg {%
  \let\sc@possiblyfinishdirecting\sc@noargs@finishdirecting
  \let\direct\DirectNoArg
}
%    \end{macrocode}
%
% \todo{Do penalties better?}
%
%  \begin{macro}{\GiveSpeaker}
%    \begin{macrocode}
\newcommand\GiveSpeaker [1] {%
  \par
  \centerline{\textsc{#1}}%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\GiveSpeakerContinued}
% The space is explicit for clarity.
%    \begin{macrocode}
\newcommand\GiveSpeakerContinued [1] {%
  \GiveSpeaker{#1\space\rlap{\textsl{(continued)}}}%
}
\newcommand\speak [1] {%
  \sc@possiblyfinishdirecting
  \sc@mark{\ShortEmpty}%
  \pagebreak[2]%
  \smallskip
  \sc@mark{\GiveSpeakerContinued{#1}}%
  \GiveSpeaker{#1}%
  \par
  \nopagebreak
  \noindent
}
%    \end{macrocode}
%  \end{macro}
%
% \Finale