%^^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
