% Document sub-style threecolumn.sty   May 23, 1989
%
% Author: George D. Greenwade, Director, Center for Business and Economic
%  Research, Sam Houston State University, Huntsville, TX 77341-2056
%  Voice: (409) 294-1518    Bitnet: BED_GDG@SHSU.BITNET
%
% Date of Release:  May 23, 1989  (original version)
% Revision History:
%
% Purpose: To create LaTeX output in three columns without corrupting the
%  general uses of LaTeX.  This version is not suggested for use unless the
%  ENTIRE DOCUMENT is to be in a three column output with no multiple column
%  floats.
%
% Usage:  Preamble: \documentstyle[...,threecolumn]{...}
%         In text:  \threecolumn
%
% Features: Addition of \photo{height}{caption} to create an empty box of the
%  dimension \columnwidth wide and specified height (#1), with a caption below
%  set in the \sl font.  Height MUST be specified, caption may be blank, but
%  must be left as a null entry (i.e., \photo{2in}{} for a 2-inch blank space).
%  \photo is placed on a minipage within a table[ht].  The caption is photo-
%  specific and does not step the table counter (as best as I can tell).
%
% Known Limitations (which would be nice ot fix):  May 23, 1989
%  (1) \threecolumn does NOT presently handle MULTIPLE COLUMN table and figure
%      floats properly, but does properly handle footnotes; however, there are
%      no apparent float handling problem in \twocolumn or \onecolumn.
%  (2) Switching from \onecolumn to \twocolumn and \onecolumn to \threecolumn
%      behave properly.  Switching from \threecolumn to \twocolumn,
%      \threecolumn to \onecolumn, \twocolumn to \theeecolumn, and \twocolumn
%      to \onecolumn generates a blank (but numbered) page.  As a rule,
%      \twocolumn presents strange output results in this sub-style.
%  (3) \maketitle is inoperable in \threecolumn.
%
% Copyright (c) 1989 by George D. Greenwade
% Permission to copy all or part of this work is granted, provided that the
% copies are not made or distributed for resale, and that the copyright notice
% and this notice are retained.
%
% THIS WORK IS PROVIDED ON AN "AS IS" BASIS.  THE AUTHOR PROVIDES NO WARRANTY
% WHATSOEVER, EITHER EXPRESS OR IMPLIED, REGARDING THE WORK, INCLUDING
% WARRANTIES WITH RESPECT TO ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
% PURPOSE.
%
% Please forward all fixes and improvements which do not otherwise corrupt the
% operation of the LaTeX document processing program to the author.
\typeout{Document Style Option 'threecolumn'.  Released 23 May 1989}

\hoffset -.4in                  % Generalized page layout for three column
\voffset -.3in                  %  output.  Certainly, these are subject to
\columnsep 15pt                 %  customization, but these definitions seem to
\textwidth 7.2in                %  provide efficient default margins.
\textheight 9.5in               %
\topmargin 0pt                  %
\headsep 0pt                    %
\headheight 0pt                 %
\oddsidemargin 0pt              %
\pretolerance=500               % Needed pretolerance and tolerance to assure
\tolerance=10000                %  text generally fits the columns
\doublehyphendemerits=100000    % Inhibit consecutive line hyphens
\brokenpenalty=10000            % Inhibit broken words across columns/pages
\widowpenalty=10000             % Inhibit widows at bottom of page
\clubpenalty=10000              % Inhibit orphans at top of page

\newif\if@threecolumn   \@threecolumnfalse   % New ifs used in routine
\newif\if@secondcolumn  \@secondcolumnfalse  %
\newif\if@thirdcolumn   \@thirdcolumnfalse   %
\newbox\@centercolumn                        % New box to place center column
\newdimen\photoblock \photoblock=0pt         % New dimension used in \photo

\def\onecolumn{\clearpage             % Redefine \onecolumn without corruption
     \global\columnwidth\textwidth
     \global\hsize\columnwidth \global\linewidth\columnwidth
     \global\@twocolumnfalse \global\@threecolumnfalse
     \global\@secondcolumnfalse \global\@thirdcolumnfalse
     \@floatplacement}

\def\twocolumn{\clearpage             % Redefine \twocolumn without corruption
     \global\columnwidth\textwidth
     \global\advance\columnwidth -\columnsep \global\divide\columnwidth\tw@
     \global\hsize\columnwidth \global\linewidth\columnwidth
     \global\@twocolumntrue \global\@threecolumnfalse
     \global\@firstcolumntrue \global\@secondcolumnfalse
     \global\@thirdcolumnfalse
     \@dblfloatplacement\@ifnextchar[{\@topnewpage}{}}

\def\threecolumn{\clearpage             % Define \threeecolumn (very rough;
     \global\columnwidth\textwidth      %   handles floats poorly, if at all)
     \global\advance\columnwidth -\columnsep
     \global\advance\columnwidth -\columnsep \global\divide\columnwidth\thr@@
     \global\hsize\columnwidth \global\linewidth\columnwidth
     \global\@twocolumnfalse \global\@threecolumntrue \global\@firstcolumntrue
     \global\@secondcolumnfalse \global\@thirdcolumnfalse
     \@dblfloatplacement\@ifnextchar[{\@topnewpage}{}}

\def\@doclearpagethree{\ifvoid\footins  % Define variation of \@doclearpage
        \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
%WAS        \setbox\@tempboxa\box\@ccl
        \setbox\@tempboxa\box\@cclv
        \xdef\@deferlist{\@toplist\@botlist
            \@deferlist}\gdef\@toplist{}\gdef\@botlist{}\global\@colroom\@colht
             \ifx\@currlist
              \@empty\else\@latexerr{Float(s)
                 lost}\@ehb\gdef\@currlist{}\fi
       \@makefcolumn\@deferlist
        \@whilesw\if@fcolmade \fi{\@opcol
                                  \@makefcolumn\@deferlist}\if@threecolumn
           \if@firstcolumn
             \xdef\@dbldeferlist{\@dbltoplist
                 \@dbldeferlist}\gdef\@dbltoplist{}\global\@colht\textheight
              \begingroup \@dblfloatplacement \@makefcolumn\@dbldeferlist
               \@whilesw\if@fcolmade \fi \endgroup
           \if@secondcolumn
             {\@outputpage\@makefcolumn\@dbldeferlist} \fi \endgroup
           \else \vbox{}\clearpage
        \fi\fi
     \else\setbox\@cclv\vbox{\box\@cclv\vfil}\@makecol\@opcol
      \clearpage
     \fi}

\def\@specialoutput{\ifnum\outputpenalty > -\@Mii  % Redefine \@specialoutput
    \if@threecolumn \@doclearpagethree             %  to handle \threecolumn
    \else \@doclearpage \fi                        %  environment.
  \else
    \ifnum \outputpenalty <-\@Miii
       \ifnum\outputpenalty<-\@MM \deadcycles\z@\fi
       \global\setbox\@holdpg\vbox{\unvbox\@cclv}
%WAS:    \else \setbox\@tempboxa\box\@ccl
    \else \setbox\@tempboxa\box\@cclv
        \@pagedp\dp\@holdpg \@pageht\ht\@holdpg
        \unvbox\@holdpg
        \ifvoid\footins\else\advance\@pageht\ht\footins
          \advance\@pageht\skip\footins \advance\@pagedp\dp\footins
          \insert\footins{\unvbox\footins}\fi
        \@next\@currbox\@currlist{\ifnum\count\@currbox >\z@
            \@addtocurcol\else\@addmarginpar\fi}\@latexbug
    \ifnum \outputpenalty <\z@ \penalty \z@ \fi
  \fi\fi}

\def\@opcol{\global\@mparbottom\z@   % Redefine \@opcol to handle \threecolumn
    \if@twocolumn\@outputdblcol \fi  %   environment without corruption
    \if@threecolumn\@outputtplcol\else
    \@outputpage \global\@colht\textheight \fi}

\def\@skipcolumn{\if@firstcolumn  % Tentatively define \@skipcolumn (for future
  \global\@firstcolumnfalse       %  use in two-column-wide material in the
  \global\@secondcolumnfalse      %  \threecolumn environment)  NOT EMPLOYED!
  \global\@thirdcolumntrue \fi
  \if@secondcolumn \global\@firstcolumntrue \global\@secondcolumnfalse
  \global\@thirdcolumnfalse \fi}

\def\@outputtplcol{\if@firstcolumn     % Define \@outputtplcol (analogous to
    \global\@firstcolumnfalse          %  \@outputdblcol, but for \threecolumn)
    \global\@secondcolumntrue \global\@thirdcolumnfalse
    \global\setbox\@leftcolumn\box\@outputbox
\else
  \if@secondcolumn \global\@secondcolumnfalse \global\@thirdcolumntrue
   \global\setbox\@centercolumn\box\@outputbox
\else
\global\@thirdcolumnfalse \global\@firstcolumntrue
    \setbox\@outputbox\vbox{\hbox to\textwidth{\hbox to\columnwidth
      {\box\@leftcolumn \hss}\hfil \vrule width\columnseprule\hfil
\hbox to\columnwidth
      {\hss \box\@centercolumn \hss}\hfil \vrule width\columnseprule\hfil
       \hbox to\columnwidth{\box\@outputbox \hss}}}\@combinedblfloats
       \@outputpage \begingroup \@dblfloatplacement \@startdblcolumn
       \@whilesw\if@fcolmade \fi{\@outputpage\@startdblcolumn}\endgroup
    \fi \fi}

\def\photoblocksize{\global\photoblock=\columnwidth   % Define width of the
   \advance \photoblock -\columnsep                   %  photo block
   \if@threecolumn \advance \photoblock -\columnsep \fi}

\def\photo#1#2{\photoblocksize   % Define \photo{height}{caption} as floating
 \begin{table}[ht]               %  blank space for photo insertions to be used
\begin{minipage}{\photoblock}    %  in final paste-up.
\rule{0pt}{#1}   \\              % #1 is height
\end{minipage}                   % width defaults to column width
\begin{center} {\sl \ #2}        % #2 is caption set in the \sl font face
\end{center}
\end{table}}