% double-page float package
%
% Copyright University of Washington
%
% Jim Fox
% fox@u.washington.edu
% http://weber.u.washington.edu/~fox/
%

\ProvidesPackage{dpfloat}[1997/09/21]
\NeedsTeXFormat{LaTeX2e}
 
%  This package allows you to format a double-page figure or table
% 
%  It provides two environments:
% 
%    {fullpage}      makes a full page figure or table
%    {leftfullpage}  like fullpage, but guarantees a left side page
%
%  Example use:
%   
% -------------------------------------------------------
%      \begin{figure}[p]% will be the left-side figure
%        \begin{leftfullpage}
%          ...
%        \end{leftfullpage}
%      \end{figure}
%      \begin{figure}[p]% will be the right-side figure
%        \begin{fullpage}
%          ...
%        \end{fullpage}
%      \end{figure}
% -------------------------------------------------------
%
%  
%  LaTeX's output routine is modified to reject left-page floats
%  if they appear on odd pages (right page).  These will then
%  be moved to the next page (a left page).
%
%  This is obviously dependent upon specific details of the
%  output routine which are probably subject to change without notice.
%  

\newif\if@LP \@LPfalse

% For each float we define a macro indicating whether or not
% it is 'left-page' only

\newbox\@@wholepage
\def\fullpage{\setbox\@@wholepage=\vbox\bgroup}
\def\endfullpage{\egroup\dp\@@wholepage\z@
   \vbox to\textheight{\vss\unvbox\@@wholepage\vss}}
\def\leftfullpage{\setbox\@@wholepage=\vbox\bgroup}
\def\endleftfullpage{\egroup\dp\@@wholepage\z@
   \vbox to\textheight{\vss\unvbox\@@wholepage\vss}\global\@LPtrue}

\let\oldend@float\end@float
\def\end@float{%
  \if@LP\global\@namedef{LP:\expandafter\string\@currbox}{L}%
  \else \global\@namedef{LP:\expandafter\string\@currbox}{X}%
  \fi
   \global\@LPfalse
  \oldend@float
}

% Reject a left-page float that appears on an even page

\if@twoside

% reject a left-side float that appears on an odd page
 \let\old@xtryfc\@xtryfc
 \def\@xtryfc #1{%
   \expandafter\if\csname LP:\string#1\endcsname L%
      \ifodd\count0\global\@colht\z@
          \typeout{I moved a leftpage float from page \the\count0.}%
      \fi\fi
    \old@xtryfc #1}

\else

% if you want to do something special for one-sided printing
% do it here

\fi

% end of dpfloat
