summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/frankenstein/unsupported/bits.sty
blob: 630fa00409c31d1dedb84e410a5f5fa19ab23bd9 (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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
%^^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
%   bits LaTeX package.  It will work ONLY if it is placed in a
%   proper directory.  Files called README, INSTALL, bits.tex
%   and bits.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{602} 
%
% \newcommand\scheme [2] {\ensuremath{\frac{#1}{#2}}}
%
%^^A** abstract
% \begin{abstract}
%   Bits provides a programmer's interface for a new idea called a
%   \term{bit}, which is like an environment but has a title, author, and
%   other attributes usually only associated with the \env{document}
%   environment.  
%
%   This package is useful but may have problems and is unsupported.
% \end{abstract}
% \tableofcontents
%
% \part{Discussion}
%
% This documentation is spotty, but should be accurate.  Please feel free to
% write me if you can't figure something out.
%
% \section{Basic concepts and terminology}
%   \subsection{Users' interface}
%
% A \term{bit} is the smallest part of a document treated as an independent
% unit.  Each \term{bit} has an explicit type called a \term{bitstyle}.
% (Examples: generic, story, poem, recipe, letter.)  A bit's bitstyle
% determines the markup that is legal within the bit.  (Additional declarations
% can be made on a per-bit basis, also; see below.)  A bit's formatting is
% determined by both its bitstyle and the copystyle (see below) of the
% document.  New bitstyles can be added.
%
% A \term{copystyle} is one of an explicit list of ways to present a collection
% of bits together in a single document.  It might well be called a
% ``documentstyle'' and be implemented as a \LaTeX{} documentclass, but if they
% are kept separate, copystyles and documentclasses can coexist with each
% other, and this leads to a greater flexibility when dealing with existing
% documents.  The relationship between copystyles and documentclasses is
% discussed further below. New copystyles can be added.
%
% \subsection{Programmers' interface}
%
% The formatting of a bit is considered to involve a fixed number of
% \term{tasks}.  Examples of tasks performed near the beginning of formatting a
% bit are inserting some space after the preceding bit, and formatting the
% title of the current bit.  Each task must be assigned a \term{procedure} that
% accomplishes that task.  (Notice that the null procedure might be a suitable
% procedure for some tasks in some situations.)  We call a mapping of some
% tasks to suitable procedures a \term{profile}.  We call a profile that maps
% the \emph{complete} set of tasks a \term{scheme}.  You need a scheme to
% format a bit, and the scheme to use for a given bit is determined by its
% bitstyle and copystyle.
%
% Now we are in a position to try to visualize the variable space established
% by the \term{bits} package.  It's not simple, and if you think of a better
% way, please let me know.
%
% As just explained, to format a bit, you need a scheme, which is a series of
% procedures suitable for a series of certain tasks.  To be concrete, let's
% assume there are 4 tasks.  Identify each task with a general color.  In our
% example, let's use red, blue, green, and yellow.  Think of a scheme as a
% stack of colored blocks, each representing a procedure.  The top block,
% corresponding to the first task, is red, the second block is blue, the third
% green, and the bottom block, corresponding to the final task, is yellow.
%
% Suppose I create a new scheme, the same as the original except for a slight
% change in the first task.  This would be represented by changing the color of
% the red, or top, block to a different shade of red.  The precise color of a
% block represents the specific procedure.  A general color is associated with
% a task because it is expected that no procedure suitable for one task is
% going to be suitable for another task.  The redness of a block represents its
% suitability for the the first task.
%
% (If we wanted to be exact, we would observe that some procedures, such as the
% null procedure, might be suitable for more than one task.  OK, let such
% procedures be a shade of grey, with the null task, let us say, being white.
% Then the colored block at each task's position will have either the
% associated color of the task or a shade of grey.)
%
% I have drawn in your mind the picture of two stacks of 4 colored blocks,
% differing only in the shade of the top (red) block.  Let's give them the
% names Jack and Jill.  Let Jack and Jill represent two bitstyles.  You can
% imagine as many bitstyles as you like---Jack, Jill, Hank, Wendy, and
% Beauregard; all are stacks of four colored blocks arranged next to each other
% in a line, a red block on top, a blue block, a green block, and a yellow
% block.  Some of the stacks might even have identical blocks.  This would mean
% that two bitstyles have the same scheme.  You refer to bitstyles by their
% name, so in the future, you could change one bitstyle and make it different
% from the other.  In fact, when you create a new bitstyle, it is initially
% simply a copy of an existing bitstyle.  Then you can modify the new one if
% you want to.
%
% bitclass? bittype?  bitstyle best describes a scheme.  bitscheme?
%
% You've almost got the whole picture now.  We need to consider copystyles.
% Suppose Jack, Jill, Hank, Wendy, and little Beauregard are all siblings.
% They have the same last name, Grimm.  Grimm is the name of a copystyle.
% Across town, or in a parallel universe, there is another set of siblings
% Jack, Jill, etc.\ with a different last name, Beedle.  They, too, are
% represented by a line of stacks of colored blocks.  Line up the Beedle
% siblings behind the Grimm siblings, and you now have a pile of colored blocks
% 4 high (4 tasks), 5 wide (the 5 bitstyles Jack, Jill, etc.), and 2 deep (the
% 2 copystyles Grimm and Beedle).
%
% That's it.  Given a bitstyle (e.g., Hank) and a copystyle (e.g., Beedle), you
% have a particular scheme for formatting a bit.
%
% As you may notice, there is so far no justification for the metaphor of
% family.  Nothing I've said yet about tasks and procedures corresponds to the
% metaphor's suggestion that Hank Beedle is probably more similar to Wendy
% Beedle than he is to Hank Grimm; or that when putting together the Beedles in
% a family photograph, there is a certain pleasing aesthetic unity that would
% be lacking if any of those odd-looking Grimms were to stray into the picture.
% In fact, technically, each scheme can be completely different from every
% other scheme, Hank Beedle being as different from Wendy Beedle as he is from
% Hank Grimm.
%
% These metaphors are justified when you consider the way in which new
% copystyles and bistyles are added, and the expected purposes for bitstyles
% and copystyles.
%
% OR: family of Poems, family of recipes.  First name is the copystyle.  Then a
% document would consist of Hank Poem, Hank Recipe, etc. = Standard Poem,
% Standard Recipe; Fancy Poem, Fancy Recipe.
%
% Or, each family has one Poem, one Recipe, etc. So a document puts together
% members of a family, Poem, Recipe, etc.
%
% \section{Usage}
%
% Bits look like \LaTeX{} environments that take two arguments.  (Surprise
% surprise that's exactly what they are.)  Here's an example of a bit with
% hypothetical bitstyle ``poem'': 
%
% \begin{codeexample}
% \begin{poem}{Butterflies}{\subtitle{An Address to My Stomach}}
%   O jittery one, quavering tub, \\
%   Rumble not your complaints so violently! \\
%   Remember your jollitude just last Sunday, \\
%   The pound of bovine ambrosia \\
%   I filled you to the gills with \\
%   To silence you, on this, my wedding day.
% \end{poem}
% \end{codeexample}
%
% \section{Extension and customization}
%   \subsection{Customizing an instance of a bit}
%
% Fat little Hank Beedle might come with a note tied around his neck on a piece
% of yarn, with special instructions on his care and feeding from his mother.
% ``Peanuts will give him hives,'' it might say.  And ``A quart of sour cream
% is always welcome.''
%
%   \subsection{Adding bitstyles, copystyles, and tasks}
%
% When you add a new bitstyle $B'$, you create a new scheme for each of the
% existing copystyles.  You name an existing bitstyle $B$ and zero or more
% profiles.  For each existing copystyle $C$, the profiles will be composed
% with the \scheme{B}{C} scheme to obtain the new scheme \scheme{B'}{C}.
% (Notice that if any of the profiles you name are schemes, the choice of $B$
% is irrelevant, and that if you name no profiles, $B' = B$.)
%
% The procedure is identical when you add a new copystyle.  Just swap
% references to copystyles and bibstyles in the last paragraph.
%
% You can add to list of tasks.  When you do this, you must assign a default
% procedure for it (part of the \cat{Z} scheme, the universal default).  All
% existing bitstyles and copystyles will inherit the same procedure for this
% task.  This makes sense because they've presumably all done the task the same
% way before, if they've done it at all.  You can promulgate changes with
% \cs\Promulgate etc.
%
% \section{Notes}
%
% FIX; bit type determines its markup; bitstyle is a mapping of tasks to
% procedures.
%
% \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{basic bits (Frankenstein's guts)}
\def\DoXPackageS {}
\def\fileversion{v1.2}
\def\filedate{2001/08/31}
\def\docdate{2001/08/31}
\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{bits}[\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.
%
%
% \section{Preliminaries}
%
%   \subsection{Requirements}
%
%    \begin{macrocode}
\RequirePackage{blkcntrl,letterhead,moredefs,relsize}
%    \end{macrocode}
%
%   \subsection{Option processing}
%
%    \begin{macrocode}
\DeclareOption{poetica} {%
  \RequirePackage{poetica}
  \newcommand\FullTitlePoetica {%
    \begin{Poetica}
      \fontshape{t}\selectfont
      \BitTitle\\%
      \ifx\BitSubtitle\ShortEmpty \else
        \BitSubtitle\\%
      \fi
    \end{Poetica}
  }
  \AtBeginDocument {%
    \let\FullTitle\FullTitlePoetica
  }
}
%    \end{macrocode}
% FIX: hmm, I think I always want user options so that I can have two different
% packages require a package, and they don't have to match up on their options.
% What about options that can only be used in preamble, that would be the right
% thing for many cases I think.  Aak, \cname{ends} can't be defined without
% special handling?  Hmm, seems like it can.
%    \begin{macrocode}
\DeclareBooleanUserOptions{ends}{noends}
\DeclareBooleanUserOptions{signed}{anonymous}

\DeclareBooleanOptions{titlepage}{notitlepage}

\ExecuteOptions{ends,notitlepage,signed}
\ProcessOptions
%    \end{macrocode}
%
% \section{Making new copy and bit styles}
%
%   \subsection{General stuff}
%
% \begin{macro}{\bt@a}
% \begin{macro}{\bt@b}
% \begin{macro}{\bt@c}
% \begin{macro}{\bt@d}
% \begin{macro}{\bt@e}
%   \mbox{}
%    \begin{macrocode}
\ReserveCS\bt@a
\ReserveCS\bt@b
\ReserveCS\bt@c
\ReserveCS\bt@d
\ReserveCS\bt@e
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\bt@tasks}
% \begin{macro}{\bt@bitstyle@list}
% \begin{macro}{\bt@copystyle@list}
%   Comma-separated lists of valid bitstyles, copystyles, and tasks.  We start
%   them off non-null to bootstrap the system of adding new ones, which adds
%   them preceded by a comma.
%    \begin{macrocode}
\newcommand\bt@tasks {%
  environment,end@bit,begin@bit,interbits,firstbit%
  ,settitle,setfirsttitle%
}
\newcommand\bt@bitstyle@list {%
  generic%
}
\newcommand\bt@copystyle@list {%
  standard%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@bt@trymoreschemes@}
% \begin{macro}{\@bt@trymoreschemes@true}
% \begin{macro}{\@bt@trymoreschemes@false}
% \begin{macro}{\bt@list@car}
% \begin{macro}{\bt@list@cdr}
%   \cname{bt@list@car} and \cname{bt@list@cdr} expand to the car and cdr of a
%   comma-separated list, respectively.
%    \begin{macrocode}
\provideboolean{@bt@trymoreschemes@}

\NewName{bt@list@car}{#1,#2\@nil} {%
  #1%
}
\NewName{bt@list@cdr}{#1,#2\@nil} {%
  #2%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\NewCopystyle}
% \begin{macro}{\NewBitstyle}
% \begin{macro}{\bt@assign@task}
%   To define a new style, you specify a base style and a list of profiles.
%   Each of these can be empty.  If no base style is specified, the root style
%   is used (i.e., standard copystyle or generic bitstyle).  See discussion
%   above.
%    \begin{macrocode}
\newcommand\NewCopystyle [2][Z] {% args: [profile-list] new-copystyle
  \addto@macro\bt@copystyle@list{,#2}%
  \@for\bt@a:=\bt@bitstyle@list \do {%
    \@for\bt@b:=\bt@tasks \do {%
      \eExpand\bt@b\In {%
          \expandafter\bt@assign@task
            \expandafter{\bt@a}{#2}{##1}{#1}%
      }%
    }%
  }%
}
\newcommand\NewBitstyle [2][Z] {% args: [scheme-list] new-bitstyle
  \addto@macro\bt@bitstyle@list{,#2}%
  \@for\bt@a:=\bt@copystyle@list \do {%
    \@for\bt@b:=\bt@tasks \do {%
      \eExpand\bt@a\In {%
        \eExpand\bt@b\In {%
%        \eExpandNest\bt@b\In {%  FIX?
          \bt@assign@task{#2}{##1}{####1}{#1}%
        }%
      }%
    }%
  }%
}
\newcommand\bt@assign@task [4] {% args: bitstyle copystyle 
                                %       task scheme-list
  \@bt@trymoreschemes@true
  \edef\bt@d{#4}% scheme-list that diminishes; edef not necessary
  \@whilesw\if@bt@trymoreschemes@\fi {%
%    \end{macrocode}
% There's at least one element to start; and the last scheme (\cat{Z}) is always
% defined.
%    \begin{macrocode}
    \edef\bt@c{%
      \bt@list@car\bt@d,\@nil
    }
    \@ifundefined{bt@make@#3@\bt@c} {%
        \edef\bt@d{\bt@list@cdr\bt@d,\@nil}%
        }{% ELSE
      \@nameuse{bt@make@#3@\bt@c}{#1}{#2}%
      \@bt@trymoreschemes@false
      }%
  }%
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\PromulgateTaskAcrossCopystyles}
% \begin{macro}{\PromulgateTaskAcrossBitstyles}
%   \mbox{}
%    \begin{macrocode}
\newcommand\PromulgateTaskAcrossCopystyles [3] {% args: task scheme bitstyle
  \@for\bt@a:=\bt@copystyle@list \do {%
    \@nameuse{bt@make@#1@#2}{#3}{\bt@a}%
  }%
}
\newcommand\PromulgateTaskAcrossBitstyles [3] {% args: task scheme copystyle
  \@for\bt@a:=\bt@bitstyle@list \do {%
    \@nameuse{bt@make@#1@#2}{\bt@a}{#3}%
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bt@begin@bit@common}
% \begin{macro}{\BitStyle}
% \begin{macro}{\PreBitAll}
%   \cname{bt@begin@bit@common} should be called early in the sequence of
%   beginning a bit.
%    \begin{macrocode}
\providesavebox\sc@box@a
\newcommand\bt@begin@bit@common [2] {%
  \title{#1}%
%    \end{macrocode}
% We want to clear all optional attributes here, such as subtitle. FIX: should
% be a list of attributes and perhaps even abstract clearing functions on them, etc.
%    \begin{macrocode}
  \subtitle{}%
%    \end{macrocode}
% Execute stuff: FIXME: nice hooks can be set here to execute things later
% We introduce the \par so that extra spaces in the argument are not going to
% mean anything.  It would be complicated but possible by means perhaps of
% \cs\nullfont to avoid starting a paragraph here.  Arg, the kernel is so
% opaque on how it handles ignoring spaces and what it's doing with everypar.
%    \begin{macrocode}
  \par #2%
  \refstepcounter{bit}%
  \ifnum\value{bit} = \@ne
    \@nameuse{bt@firstbit@\CopyStyle}%
  \else
    \@nameuse{bt@interbits@\CopyStyle}%
  \fi
}
\ReserveCS\BitStyle
\ReserveCS\PreBitAll
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%   \subsection{Schemes}
%
%     \subsubsection{The \cat{Z} scheme}
%
% \begin{macro}{\FullTitle}
%   The \cat{Z} scheme is always the last resort deafult, and it corresponds to
%   the standard copystyle and the generic bitstyle.
%
% FIXME: whenever we have a dummy we have to use DefName or else we error
% FIXME: Aak, when Promulgating we need defnames for everyting!
%    \begin{macrocode}
\newcommand\bt@make@environment@Z [2] {% args: bitstyle dummy
  \DefName{end#1}{}{}%
  \DefName{#1}{##1##2} {%
    \DefName{end#1}{} {%
      \@nameuse{bt@end@bit@#1@\CopyStyle}{##1}%
    }%
    \@nameuse{bt@begin@bit@#1@\CopyStyle}{##1}{##2}%
  }%
}
\newcommand\bt@make@interbits@Z [2] {% args: dummy copystyle
  \DefName{bt@interbits@#2}{} {%
    \relax
    \par\pagebreak[2]\bigskip\bigskip
    \@nameuse{bt@settitle@\BitStyle @#2}%
  }%
}
\newcommand\bt@make@firstbit@Z [2] {% args: dummy copystyle
  \DefName{bt@firstbit@#2}{} {%
    \relax
    \par\pagebreak[2]%
    \thispagestyle{empty}%
    \@nameuse{bt@setfirsttitle@\BitStyle @#2}%
  }%
}
\newcommand\bt@make@begin@bit@Z [2] {% args: bitstyle copystyle
  \DefName{PreBit#1}{}{}%
  \DefName{bt@begin@bit@#1@#2}{##1##2} {%
    \def\BitStyle{#1}%
    \bt@begin@bit@common{##1}{##2}%
    \PreBitAll
    \@nameuse{PreBit#1}%
  }%
}
\newcommand\bt@make@end@bit@Z [2] {% args: bitstyle copystyle
  \DefName{bt@end@bit@#1@#2}{##1} {%
    \TheEnd
  }%
}
\newcommand\bt@make@settitle@Z [2] {% args: bitstyle copystyle
  \DefName{bt@settitle@#1@#2}{} {%
    \relax
    \begin{center}\FullTitle\end{center}
  }%
}
\newcommand\bt@make@setfirsttitle@Z [2] {% args: bitstyle copystyle
  \DefName{bt@setfirsttitle@#1@#2}{} {%
    \relax
    \begin{center}\FullTitle\end{center}
    \DTypeout{FIXME setfirsttitle in Z scheme}%
  }%
}
%    \end{macrocode}
% When there is no subtitle, it sometimes seems better for the title to be set
% one size larger than the copy; but when you have a subtitle, you need the
% title two sizes larger so that the subtitle can be an intermediate size.
% With CM fonts, because their boldface is extended, a bold subtitle at the
% same size as the copy looks good, and larger is too larger.  So this is a
% tricky issue.  A basic kludge that would work for me, given the font families
% I have an use, would be to check for CM fonts here, or on the other hand
% specifically for an extended boldface, or for Dante/Bulmer, or set a flag in
% my dante.sty or bulmer.sty.
%    \begin{macrocode}
\newcommand\FullTitle {%
  \relsize{2}\bfseries
%  \relsize{1}\bfseries
  \BitTitle\\%
  \ifx\BitSubtitle\ShortEmpty
  \else
    \csname sbseries\endcsname  % this way it's harmless if undefined
    \relsize{-1}\BitSubtitle\\%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
%     \subsubsection{The \cat{P} scheme}
%
% \begin{macro}{\bt@make@setfirsttitle@P}
% \begin{macro}{\bt@make@settitle@P}
% \begin{macro}{\bt@make@end@bit@P}
% \begin{macro}{\bt@make@begin@bit@P}
% The \cat{P} scheme was created for the poem bitstyle.
%    \begin{macrocode}
\newcommand\bt@make@begin@bit@P [2] {% args: bitstyle copystyle
  \DefName{bt@begin@bit@#1@#2}{##1##2} {%
    \def\BitStyle{#1}%
    \bt@begin@bit@common{##1}{##2}%
    \PreBitAll
    \verse        % FIX: why does the PreBitAll hook come before \verse and the
		  % BitHook come after?  Why doesn't the PreBitAll come in
		  % @common@ -- well, so that a bit can put stuff before the hooks.
    \@nameuse{PreBit#1}%
  }%
}
\newcommand\bt@make@end@bit@P [2]  {% args: bitstyle copystyle
  \DefName{bt@end@bit@#1@#2}{##1} {%
    \relax
    \endverse
    \TheEnd
  }%
}
\newcommand\bt@make@settitle@P [2]  {% args: bitstyle copystyle
  \DefName{bt@settitle@#1@#2}{} {%
    \relax
    \begin{verse}\FullTitle\end{verse}
  }%
}
\newcommand\bt@make@setfirsttitle@P [2]  {% args: bitstyle copystyle
  \DefName{bt@setfirsttitle@#1@#2}{} {%
    \relax
    \begin{verse}\FullTitle\end{verse}
    \DTypeout{this is setfirsttitle in P scheme}%
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%     \subsubsection{The \cat{R} scheme}
%  For the prose bitstyle.
%    \begin{macrocode}
\newcommand\bt@make@settitle@R [2] {%
  \DefName{bt@settitle@#1@#2}{} {%
    \relax
    \ifx\BitTitle\ShortEmpty\else
      \noindent
      \begingroup
        \relsize{1}%
        \bfseries
        \BitTitle
      \endgroup
      \par\smallskip
    \fi
  }%
}
%    \end{macrocode}
%
%     \subsubsection{The \cat{T} scheme} FIX: for what?
%
% \section{The standard copystyle and generic bitstyle}
%
%    \begin{macrocode}
\@for\bt@e:=\bt@tasks \do {%
  \PromulgateTaskAcrossBitstyles{\bt@e}{Z}{standard}
}
%    \end{macrocode}
%
% \section{Bit Styles}
%
%   \subsection{Story}
% This is the same as generic.
%    \begin{macrocode}
\NewBitstyle{generic}
\NewBitstyle{story}
%    \end{macrocode}
%
%   \subsection{Poem}
%
%    \begin{macrocode}
\NewBitstyle{poem}
\PromulgateTaskAcrossCopystyles{begin@bit}{P}{poem}
\PromulgateTaskAcrossCopystyles{end@bit}{P}{poem}
\PromulgateTaskAcrossCopystyles{settitle}{P}{poem}
\PromulgateTaskAcrossCopystyles{setfirsttitle}{P}{poem}
%    \end{macrocode}
%
%   \subsection{Prose}
%
%    \begin{macrocode}
\NewBitstyle{prose}
\PromulgateTaskAcrossCopystyles{settitle}{R}{prose}
%    \end{macrocode}
%
% \section{Copy Styles}
%
%    \begin{macrocode}
\NewCopystyle{titlepage}

\newcommand\bt@make@setfirsttitle@T [2] {% args: bitstyle copystyle
  \DefName{bt@setfirsttitle@#1@#2}{} {%
    \thispagestyle{empty}%
    \vspace*{\fill}%
    \begin{center}
      {\relsize{5}\BitTitle \\}%
      \ifx\BitSubtitle\ShortEmpty\else
        {\relsize{3}\BitSubtitle \\}%
      \fi
    \end{center}
    \vfill
%      \CoverNotes
%      \vfill
    \par
    \begingroup
      \sffamily
      \hfill
      \begin{tabular}{r@{\hspace{\@ne em}}r}
        Copy of:&\todayabbrev   \\%
        Version of:&\Lastchange \\%
        Date:&\Date             \\%     
      \end{tabular}
      \par\bigskip\bigskip
      \begin{raggedleft}
        \def\and{\\}%
        \larger\scshape\Author
%    \end{macrocode}
% A final |\par| is needed to close the paragraph in raggedleft mode.
%    \begin{macrocode}
        \par
      \end{raggedleft}
    \endgroup
    \newpage
    \setcounter{page}{\@ne}%
  }%
}
\PromulgateTaskAcrossBitstyles{setfirsttitle}{T}{titlepage}
%    \end{macrocode}
%
% \section{Bit counters and interbit skips}
%
% \begin{macro}{\c@bit}
% \begin{macro}{\c@bitbit}
% \begin{macro}{\c@bitbitbit}
%   \mbox{}
%    \begin{macrocode}
\providecounter{bit}
\providecounter{bitbit}[bit]
\providecounter{bitbitbit}[bitbit]
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\bt@bitskip}
%  \begin{macro}{\InterBitBreak}
%  \begin{macro}{\InterBitBitBreak}
%  \begin{macro}{\InterBitBitBitBreak}
% \cs\medbreak is penalty -100; \cs\smallbreak is 50.  FIXME: what's going on
% here?
%    \begin{macrocode}
\newcommand\bt@bitskip[1] {%
  \par
  \ifdim \lastskip < \bigskipamount
    \removelastskip
    \penalty -500%
    #1%
  \fi
}  
\newcommand\InterBitBreak {%
  \bt@bitskip
  \bigskip
}
\newcommand\InterBitBitBreak {%
  \bt@bitskip
  \medskip
}
\newcommand\InterBitBitBitBreak {%
  \bt@bitskip
  \smallskip
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\bitbit}
% \begin{macro}{\bitbitbit}
% \begin{macro}{\bt@bitbit}
% \begin{macro}{\bt@bitbitbit}
%   FIXME: These should be made attributes of the Generic Bit Style.
%    \begin{macrocode}
\newcommand\bitbit {%
  \@ifstar {%
      \bt@bitbit{}%
    }{% ELSE
    \refstepcounter{bitbit}%
    \bt@bitbit{\thebitbit\ }%
  }%
}
\newcommand{\bt@bitbit} [2] {%
  \ifnum\value{bitbit}=\@ne \else
     \InterBitBitBreak
  \fi
  \noindent #1{\relsize{-1}\bfseries #2}%
  \par\nobreak
  \smallskip
}
\newcommand\bitbitbit {%
  \@ifstar {%
      \bt@bitbitbit{}%
    }{% ELSE
    \refstepcounter{bitbitbit}%
    \bt@bitbitbit{\thebitbitbit\ }%
  }%
}
\newcommand\bt@bitbitbit [2] {%
  \ifnum\value{bitbitbit}=\@ne \else
    \InterBitBitBitBreak
  \fi
  \noindent #1{\relsize{-1}\bfseries #2}%
  \par\nobreak
  \smallskip
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% \section{Userinfos}
%
% \begin{macro}{\Author}
% \begin{macro}{\author}
% \begin{macro}{\Lastchange}
% \begin{macro}{\lastchange}
% \begin{macro}{\Date}
% \begin{macro}{\date}
% \begin{macro}{\title}
% \begin{macro}{\BitTitle}
% \begin{macro}{\BitSubtitle}
% \begin{macro}{\Subtitle}
% \begin{macro}{\subtitle}
% When we redefine \cs\author, \cs\date, and \cs\title, we add a new action to
% the original meaning.  This means that standard commands like \cs\maketitle
% will still perform as expected, if someone prefers to use that instead of the
% \Frankenstein commands.
%    \begin{macrocode}
\SaveCS\date

\newcommand*\Date {%
  \todayabbrev
}
\defcommand\date [1] {%
  \MDSaveddate{#1}%
  \def\Date{#1}%
}
\SaveCS\title
\ReserveCS\BitTitle

\defcommand\title [1] {%
  \MDSavedtitle{#1}%
  \def\BitTitle{#1}%
}
%    \end{macrocode}
% Why did I originally want \cs\Subtitle to be a user command instead of \cs\subtitle?
%    \begin{macrocode}
\NewUserInfo*[\subtitle]\BitSubtitle
%\NewUserInfo*[\Subtitle]\BitSubtitle
%\newlet\subtitle\Subtitle
\NewUserInfo*\Lastchange
\lastchange{\todayabbrev}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Copystyle}
% \begin{macro}{\copystyle}
%   \mbox{}
%    \begin{macrocode}
\NewUserInfo*\CopyStyle
\copystyle{standard}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
% \section{Dates}
%
% \begin{macro}{\today}
% \begin{macro}{\todayabbrev}
%   \mbox{}
%    \begin{macrocode}
\def\today {%
  \number\day\space\ifcase\month\or 
        January\or February\or
        March\or April\or May\or June\or July\or August\or September\or
        October\or November\or December\fi\space\number\year
}
\newcommand\todayabbrev {%
  \number\day\space\ifcase\month\or 
        Jan\or Feb\or
        Mar\or Apr\or May\or Jun\or Jul\or Aug\or Sep\or
        Oct\or Nov\or Dec\fi\space\number\year
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\copywrite}
%   This adds a copyright message to the beginning of \cs\Notes.  Its single
%   argument should be a year.
%    \begin{macrocode}
\newcommand\copywrite [1] {%
  \edef\Notes {%
    \copyright#1 All rights reserved. \Notes
  }%
}
%    \end{macrocode}
%  \end{macro}
%
% \section{Ends}
%
% \begin{macro}{\EndSign}
%   It's very hard to attach this thing without allowing a page break before it. FIX.
%    \begin{macrocode}
\newcommand\EndSign {%
  \par\nobreak
  \vspace{2\bigskipamount}%  multiplication turns glue into dimen.
  \hfill
%    \end{macrocode}
% We do this so that |\Author| can have |\\|s in it.
%    \begin{macrocode}
  \begingroup
    \scshape
    \let\and\@tabularcr
    \begin{tabular}{c}
      \Author \\% 
      \relsize{-1}\itshape\Date
    \end{tabular}%
  \endgroup
}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\theend}
%   User command which (almost) always makes an \cs\EndSign:
%    \begin{macrocode}
\newcommand\theend {%
  \if@signed@
    \EndSign
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TheEnd}
%   The end of a bit calls \cs\TheEnd.  The default definition is either
%   nothing or \cs\EndSign, depending on some condition.
%    \begin{macrocode}
\newcommand\TheEnd {%
  \def\sc@t@c {%
    prizes%
  }%
  \let\sc@t@a\EndSign
  \ifx\CopyStyle\sc@t@c
    \InitCS*\sc@t@a
  \else
    \if@signed@
      \if@ends@
% FIX: when you get the footer going...
%        \ifnum\value{page} < 2%
%          \InitCS*\sc@t@a
%        \fi
      \else
        \InitCS*\sc@t@a
      \fi
    \else
      \InitCS*\sc@t@a
    \fi
  \fi
  \sc@t@a
}
%    \end{macrocode}
% \end{macro}
%
% \section{Version control}
%
% We use macros instead of boxes, because at this point some of the macros in
% the boxes may change their meaning.  
%
% Algorithm: We will maintain two \cs\hbox es |to \textwidth| each time
% \cs\MakeCover is called.  Set the footboxes to |\v@idbox| here.  Whenever
% |\MakeCover| is called, it should stack another |\vbox| with the right
% information in it into both boxes.  The information is expanded, and thus the
% macro contents can change between calls to |\MakeCover|, but the box being
% built inserts two different |\vboxes| with their value at the moment.
%
% \begin{macro}{\bt@vcbox}
% \begin{macro}{\VersionControlString}
% \begin{macro}{\VersionControlAuthorString}
%   \mbox{}
%    \begin{macrocode}
\newcommand\BTVersionWord {Version}
\newcommand\BTCopyWord {Copy}
\newcommand\bt@vcbox {%
  \footnotesize
  \ifx\Lastchange\ShortEmpty\else
    {\bfseries \BTVersionWord:} {\slshape \Lastchange}%
  \fi
  \hspace{\@ne em}%
  {\bfseries \BTCopyWord:} {\slshape \todayabbrev}%
}
\newcommand\VersionControlString {%
  \hfill \bt@vcbox \hfill
}
%    \end{macrocode}
% I should assign some names to the various meanings of and, like protect.
%    \begin{macrocode}
\newcommand\VersionControlAuthorString {%
  \bt@vcbox \hfill {\scshape\def\and{\unskip, \ignorespaces}\Author}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%     
% \begin{macro}{\whitespace}
%   \mbox{}
%    \begin{macrocode}
\requirecommand\whitespace {%
  \bigbreak
}
%    \end{macrocode}
%  \end{macro}
%
% \part{Configuration}
%
% We leave the rest to a configuration file.
%    \begin{macrocode}
\InputIfFileExists{bits.cfg}{}{}
%    \end{macrocode}
%
%  The contents of the distributed configuration file are below.
%
% \InputIfFileExists{bits.cfg}{}{}
%
% \Finale