%
% docparts allows you to directly typeset a part of a document
% and have the main document typeset with the proper \includeonly
% statement automagicaly inserted.
% 
% checksum = "58789 79 366 2353"
% 
% docparts is really useful if your editor can invoke latex on the 
% document you are editing: this will compile only the part of the 
% document you are working on instead of triggering a LaTeX 
% "missing \begin{document}" error.
% 
% docparts is not really a package since it cannot be used
% with \usepackage. It must be \input at the beginning of each
% part of a document.
%
% Fr\'{e}d\'{e}ric Boulanger <Frederic.Boulanger@supelec.fr>
% Sup\'{e}lec - Service Informatique
% Plateau de Moulon
% 3 rue Joliot-Curie
% 91192 Gif-sur-Yvette cedex
% France
%
\expandafter\ifx\csname docpart\endcsname\relax
\else
\endinput\fi % protect against multiple inclusion

\NeedsTeXFormat{LaTeX2e}
% \ProvidesPackage{docparts}
%   [1998/11/12 v1.0 Document part management]

\AtBeginDocument{ % change \docpart once we know what to typeset
  \def\docpart#1#2{
	  \typeout{^^J
		  \space\space docparts: processing part "#2" of "#1"
		^^J}
	}
}

\def\docpart#1#2{ % initial docpart selects part to typeset
	\typeout{^^J
	  \space\space docparts: processing only part "#2" of "#1"
	^^J}
	\includeonly{#2}  % process only this part
  \xdef\jobname{#1} % change jobname to avoid .aux issues
  \input{#1.tex}    % go to main document
}
\endinput
%
% 
% Each part should be put into the main document using LaTeX \include 
% commands. For instance, main.tex should look like:
%   \documentclass[...]{...}
%   ...
%   \usepackage{docparts}
%   ...
%   \begin{document}
%   ...
%   \include{part1}
%   \include{part2}
%   ...
%   \end{document}
%   
% Each partx.tex file should start with:
%   \input{docparts.sty}
%   \docpart{main}{partx}
% where <partx> is the name of the part.
% 
% "latex main" will typeset the full document, but "latex part2" will 
% typeset only part2 by issuing an \includeonly{part2} command and 
% inputing main.tex.
% 
% When you are working on <partx> of a document, just typeset <partx>. 
% You do not need to edit the main document to add an \includeonly 
% statement.
% If your text editor is able to send the current document to LaTeX, 
% you do not need to switch to the main document window to typeset 
% the current part.
% 
