% Some LaTeX macros for handling gnuplot plots
% David Kotz dfk@cs.duke.edu

% Find out whether user wants full plot or skeleton plots
% User types either ``plot'' or ``skel'' (no quotes)
\typein[\plotskel]{Do you wish full plots [plot] or skeleton plots [skel]?}

% Define the current plot directory
\newcommand{\plotdir}{}
% Redefine the current plot directory
\newcommand{\newplotdir}[1]{\renewcommand{\plotdir}{#1/}}

\newlength{\plotwidth}
\setlength{\plotwidth}{\textwidth}
\addtolength{\plotwidth}{-0.1in}

%%%%%%%%%%%% Plots %%%%%%%%%%%%%

% Define \plot
% Include a plot in the standard way
%  Parm 1 is the plot name
%  Parm 2 is the caption for the lof
%  Parm 3 is the real caption
\newcommand{\plot}[3]{
 \begin{figure}[htbp]
  \framebox[\textwidth]{
    \begin{minipage}{\plotwidth}
      \begin{center}
       \input{figs/\plotdir#1/\plotskel.tex}
      \end{center}
      \caption[#2]{#3}
      \label{f:\plotdir#1}
    \end{minipage}
  }
 \end{figure}  
}

% Reference one of the above plots (before or after it is input)
\newcommand{\plotref}[1]{Figure~\ref{f:\plotdir#1}}

% Reference a range of plots
\newcommand{\plotrange}[2]{Figures~\ref{f:\plotdir#1}--\ref{f:\plotdir#2}}

%%%%%%%%%%%% Misc figures %%%%%%%%%%%%%

% Define \fig
% Include a miscellaneous figure in the standard way
%  Parm 1 is the fig name
%  Parm 2 is the caption for the lof
%  Parm 3 is the real caption
\newcommand{\fig}[3]{
 \begin{figure}[htbp]
  \framebox[\textwidth]{
    \begin{minipage}{\plotwidth}
      \begin{center}
       \input{figs/\plotdir misc/#1.tex}
      \end{center}
      \caption[#2]{#3}
      \label{f:\plotdir misc/#1}
    \end{minipage}
  }
 \end{figure}  
}

% Reference one of the above figs (before or after it is input)
\newcommand{\figref}[1]{Figure~\ref{f:\plotdir misc/#1}}

% Reference a range of figs
\newcommand{\figrange}[2]{%
Figures~\ref{f:\plotdir misc/#1}--\ref{f:\plotdir misc/#2}}
