\ProvidesPackage{windex}[1998/07/04 v1.1
  LaTeX support for `windex' (R L Rivest)]

% Adapted from windex.tex (Ronald L. Rivest, 11/20/89) for LaTeX
% [mjd,1998/07/02]

% To separate letter sections in the index, use statements of the form
%
%   \index{a{\indexspace}[]}
%
% for each letter section that is actually present in the index.
% These statements should go after \begin{document}.

\let\indexmargin\@gobble

%    The "final" and "draft" options are global options normally
%    inherited from the documentclass.

\DeclareOption{draft}{% show indexed terms in marginal notes
  \renewcommand{\indexmargin}[1]{\marginpar{\tiny#1}}%
  \@mparswitchfalse % Cause all marginal pars to go on right side 
}

\DeclareOption{final}{\let\indexmargin\@gobble}

\ExecuteOptions{final}
\ProcessOptions\relax

\makeindex

\newcommand{\printindex}{\InputIfFileExists{\jobname.index}{}{}}

\def\@wrindex#1{%
 \indexmargin{\fbox{\parbox[t]{1in}{#1}}}%
 \protected@write\@indexfile{}{%
   #1%
   \ifindexasis
   \else
     \ifinproblem[0\string\indextagspace{}pr.]%
     \else
       \ifinexercise[0\string\indextagspace{}ex.]\fi
     \fi
   \fi
   :\thepage
 }%
 \endgroup % close group started by \index
 \@esphack
}

\endinput %
