% File windex.tex
% Macro for writing out index files (.idx files) for use with windex
% Author: Ronald L. Rivest
% Date: 11/20/89
% Note: If you are using windex, then this file should be input into
% your source file before and \index commands are given.
% (It need not precede the \makeindex command.)
% At the end of your file foo, you can place the commands
% \makeatletter
% \@input{foo.index}
% \makeatother
% just before the \end{document} command.
% (These command are equivalent to
% \input{foo.index}
% unless foo.index doesn't yet exist, in which case \@input
% merely prints a warning message and procedes, whereas \input
% asks you for another file name.)
\makeatletter
%% The following causes all indexed terms to be printed in the right-hand
%% margin of the page.
%% To kill this effect, redefine \indexmargin to be a null macro
%% The following is for debugging (produces marginal index terms)
%% Comment this out for production; leave in for debugging.
%\newcommand{\indexmargin}[1]{{\tiny\marginpar{#1}}}
%% The following is for production (no marginal index terms)
%% Comment this out for debugging; leave in for production.
\newcommand{\indexmargin}[1]{}
\@mparswitchfalse % Cause all marginal pars to go on right side
%% In the following #1 is the file,#2 is the string being indexed
\def\@wrindex#1#2{\let\thepage\relax
\indexmargin{\fbox{\parbox[t]{1in}{#2}}}%
\xdef\@gtempa{\write#1{#2:\thepage}}\endgroup\@gtempa
\if@nobreak \ifvmode\nobreak\fi\fi\@esphack}