summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/frankenstein/blkcntrl.sty
blob: b313925e20e51e013e4161edf30f15862543c316 (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
%^^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
%   blkcntrl LaTeX package.  It will work ONLY if it is placed in a
%   proper directory.  Files called README, INSTALL, blkcntrl.tex
%   and blkcntrl.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{97}
%
%^^A** abstract
% \begin{abstract}
%   Inserts hooks into certain block elements and footnotes.  Also provides a
%   command to set block quotations one size smaller than the main text.
% \end{abstract}
% \tableofcontents
%
% \part{Discussion}
%
% \section{General}
%
% This package has two purposes.  First, it inserts several hooks into
% constructs in the standard document classes so that other packages can use
% the hooks.  The \package{achicago}, \package{attrib}, \package{dialogue}, and
% \package{bits} packages in the \Frankenstein bundle require
% \package{blkcntrl}.  Second, \package{blkcntrl} offers one option itself that
% uses the hooks.  The \option{smallblocks} option has the same effect as using
% \cs\smallblocks in the preamble, for which see below.  The
% \option{normalblocks} option means no \cs\smallblocks, and is there simply
% for completeness.
%
%% FIX; using smallblocks option gives option clash when other packages require
%  blkcntrl.  Do thorough review of option passing.
%
% \DescribeMacro\smallblocks
%     When \cs\smallblocks is declared in the preamble, footnotes and the block
%     elements \env{quote}, \env{quotation}, and \env{verse} are set one size
%     smaller (i.e., \code{\relsize{-1}}).
%
% \DescribeMacro\normalblocks
%
% \section{Programmers' interface}
%
% \DescribeMacro\PreChunk
%
% \DescribeMacro\PreQuote
%
% \DescribeMacro\PreQuotation
%
% \DescribeMacro\PreVerse
%
% \DescribeMacro\PreFootnote
%
% \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{block control}
\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{blkcntrl}[\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{Requirements}
%
%    \begin{macrocode}
\RequirePackage{moredefs,relsize}
%    \end{macrocode}
%
% \section{Options}
%
% \begin{macro}{\normalblocks}
% \begin{macro}{\smallblocks}
% \begin{macro}{\if@smallblocks@}
% \begin{macro}{\@smallblocks@true}
% \begin{macro}{\@smallblocks@false}
%  \mbox{}
%    \begin{macrocode}
\DeclareBooleanUserOptions{smallblocks}{normalblocks}
\@onlypreamble\smallblocks
\@onlypreamble\normalblocks
\ExecuteOptions{normalblocks}
\ProcessOptions
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \section{General get-control hook hacks}
%
% \begin{macro}{\if@in@footnote@}
% \begin{macro}{\@in@footnote@true}
% \begin{macro}{\@in@footnote@false}
% \begin{macro}{\PreFootnote}
% \begin{macro}{\PreChunk}
% \begin{macro}{\PreQuote}
% \begin{macro}{\PreQuotation}
% \begin{macro}{\PreVerse}
%   Additions to these hooks should be made with \cname{\addto@macro}.
%   Deletions should be accomplished by scoping.
%
%   I think macros are much more convenient as hooks than tokens.  I use the
%   prefixes |Pre| or |Post|.  We want to add a hook to the usual definition
%   here, to gain some control over relative sizing in footnotes.
%    \begin{macrocode}
\newboolean{@in@footnote@}
\newcommand\PreFootnote {%
  \@in@footnote@true
}
\ReserveCS\PreChunk
\newcommand\PreQuote {%
  \PreChunk
}
\newcommand\PreQuotation {%
  \PreChunk
}
\newcommand\PreVerse {%
  \PreChunk
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@makefntext}
%   All we're doing is adding the \cs\PreFootnote hook.
%    \begin{macrocode}
\defcommand\@makefntext [1] {%
  \setlength\parindent{\@ne em}%
  \noindent
  \hb@xt@ 1.8em{\hss\@makefnmark}%
  {\PreFootnote #1}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{verse}
% \begin{environment}{quotation}
% \begin{environment}{quote}
%   Again all we're doing to these environments is adding the hooks.
%
%   The hook cannot be put into the second argument, which is called before the
%   paragraph preceding the environment has been ended (unless the environment
%   started a new one).  
%    \begin{macrocode}
\renewenvironment{verse}
               {\let\\\@centercr
               \relax\list{}{\setlength{\itemsep}{\z@}%
                        \setlength{\itemindent}{-1.5em}%
                        \setlength{\listparindent}{\itemindent}%
                        \setlength{\rightmargin}{\leftmargin}%
                        \addtolength{\leftmargin}{1.5em}}%
                \item\relax\PreVerse\relax}
               {\endlist}
\renewenvironment{quotation}
               {\list{}{\setlength{\listparindent}{1.5em}%
                        \setlength{\itemindent}{\listparindent}%
                        \setlength{\rightmargin}{\leftmargin}%
                        \setlength{\parsep}{\z@ \@plus\p@}}%
                \item\relax\PreQuotation\relax}
               {\endlist}
\renewenvironment{quote}
               {\list{}{\setlength{\rightmargin}{\leftmargin}}%
                \item\relax\PreQuote\relax}
               {\endlist}
%    \end{macrocode}
% \end{environment}
% \end{environment}
% \end{environment}
%
%    \begin{macrocode}
\AtBeginDocument {%
  \if@smallblocks@
    \addto@macro\PreChunk {%
      \if@in@footnote@
      \else
        \relsize{-1}%
      \fi
    }%
  \fi
}
%    \end{macrocode}
%
% \Finale