% Rotated float support requires rotbox.sty
% w/0 the LABEL arguement, they are assumed to be continued figure,
% and use the capcont command.

% \tagrdiagram*[FLOAT]{FILE}{CAPTION}{LABEL}
%    *		optional
%    FLOAT	float options
%    FILE	reads LaTeX input in file Dfile
%    CAPTION	for list of figures
%    LABEL	for \ref and \pageref
\def\tagrdiagram{\@ifstar{\@stagrdiagram}{\@tagrdiagram}}
\def\@tagrdiagram{\@ifnextchar[{\@@tagrdiagram}{\@@tagrdiagram[t]}}
\def\@stagrdiagram{\@ifnextchar[{\@@stagrdiagram}{\@@stagrdiagram[t]}}

\def\@@tagrdiagram[#1]#2{\@@@tagrfigure[#1]{\input{D#2}\relax}}
\def\@@stagrdiagram[#1]#2{\@@@stagrfigure[#1]{\input{D#2}\relax}}


\def\@@@tagrfigure[#1]#2#3#4{%
    \begin{figure}[#1]
      \begin{minipage}\textheight\begin{rotbox}\hbox to \textheight%
      {\hss\noindent\begin{minipage}\textheight\hrule
	\vskip .5\baselineskip
	\begin{minipage}\columnwidth
	    \small#2%
	\end{minipage}
	\vskip .5\baselineskip plus .5\baselineskip
	\begingroup
	    \setbox\z@=\hbox{#4}%
	    \ifdim\wd\z@>\z@
		\caption{#3}%
		\label{#4}%
	    \else
		\captcont{#3}%
	    \fi
	\endgroup
	\vskip 2pt
	\hrule\end{minipage}}\end{rotbox}\end{minipage}
    \end{figure}
}

\def\@@@stagrfigure[#1]#2#3#4{%
    \begin{figure*}[#1]
      \begin{minipage}\textheight\begin{rotbox}\hbox to \textheight%
      {\hss\noindent\begin{minipage}\textheight\hrule
	\vskip .5\baselineskip
	\begin{minipage}\textwidth
	    \small#2%
	\end{minipage}
	\vskip .5\baselineskip plus .5\baselineskip
	\begingroup
	    \setbox\z@=\hbox{#4}%
	    \ifdim\wd\z@>\z@
		\caption{#3}%
		\label{#4}%
	    \else
		\captcont{#3}%
	    \fi
	\endgroup
	\vskip 2pt
	\hrule\end{minipage}}\end{rotbox}\end{minipage}
    \end{figure*}
}


% \tagrtable*[FLOAT]{FILE}{CAPTION}{LABEL}
%    *		optional
%    FILE	read LaTeX input in file Tfile
%    FLOAT	float options
%    CAPTION	for list of tables
%    LABEL	for \ref and \pageref
\def\tagrtable{\@ifstar{\@stagrtable}{\@tagrtable}}
\def\@tagrtable{\@ifnextchar[{\@@tagrtable}{\@@tagrtable[t]}}
\def\@stagrtable{\@ifnextchar[{\@@stagrtable}{\@@stagrtable[t]}}

\def\@@tagrtable[#1]#2#3#4{%
    \begin{table}[#1]
      \begin{minipage}\textwidth\hspace*{\fill}\begin{rotbox}\hbox to
      \textheight% 
      {\hss\noindent\begin{minipage}\textheight\hrule
	\vskip .5\baselineskip
	\begin{minipage}\columnwidth
	    \small\input{T#2}\relax
	\end{minipage}
	\vskip .5\baselineskip plus .5\baselineskip
	\begingroup
	    \setbox\z@=\hbox{#4}%
	    \ifdim\wd\z@>\z@
		\caption{#3}%
		\label{#4}%
	    \else
		\captcont{#3}%
	    \fi
	\endgroup
	\vskip 2pt
	\hrule\end{minipage}}\end{rotbox}\hspace*{\fill}\end{minipage}
    \end{table}
}

\def\@@stagrtable[#1]#2#3#4{%
    \begin{table*}[#1]
      \begin{minipage}\textheight\begin{rotbox}\hbox to \textheight%
      {\hss\noindent\begin{minipage}\textheight\hrule
	\vskip .5\baselineskip
	\begin{minipage}\textwidth
	    \small\input{T#2}\relax
	\end{minipage}
	\vskip .5\baselineskip plus .5\baselineskip
	\begingroup
	    \setbox\z@=\hbox{#4}%
	    \ifdim\wd\z@>\z@
		\caption{#3}%
		\label{#4}%
	    \else
		\captcont{#3}%
	    \fi
	\endgroup
	\vskip 2pt
	\hrule\end{minipage}}\end{rotbox}\end{minipage}
    \end{table*}
}

