% SHOWIDX DOCUMENT-STYLE OPTION - released 16 June 1991
%    for LaTeX version 2.09
% Copyright (C) 1985, 1988, 1989, 1991 by Leslie Lamport
%
% Prints \index entries in outer margin. For use with book or report
% style.  Note: makes \flushbottom the default.
 
\typeout{Document style option `showidx' - released 16 June 1991}
 
\newinsert\@margin
 
\newinsert\indexbox
\dimen\indexbox=\maxdimen
\def\@showidx#1{\insert\indexbox{\small
                \hsize\marginparwidth
                \hangindent\marginparsep \parindent\z@
                \everypar{}\let\par\@@par \parfillskip\@flushglue
                \lineskip\normallineskip
                \baselineskip .8\normalbaselineskip\sloppy
                \raggedright \leavevmode
                \vrule \@height .7\normalbaselineskip \@width \z@\relax
                    #1\relax\vrule
                 \@height \z@ \@depth .3\normalbaselineskip \@width \z@}}
 
\def\@leftidx{\hskip-\marginparsep \hskip-\marginparwidth}
\def\@rightidx{\hskip\columnwidth \hskip\marginparsep}
 
\def\@mkidx{\vbox to \z@{\hbox{\if@twocolumn
    \if@firstcolumn \@leftidx \else \@rightidx \fi
  \else \if@twoside \ifodd\c@page \@rightidx
                    \else \@leftidx \fi
        \else \@rightidx \fi
  \fi
  \box\indexbox}\vss}}
 
\def\raggedbottom{\def\@textbottom{\vskip
      \z@ plus.0001fil}\let\@texttop\@mkidx}
\def\flushbottom{\let\@textbottom\relax \let\@texttop\@mkidx}
 
\def\@wrindex#1#2{\let\thepage\relax
   \xdef\@gtempa{\write#1{\string
      \indexentry{#2}{\thepage}}}\endgroup\@gtempa
   \@showidx{#2}\if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
 
\def\@index#1{\@showidx{#1}\endgroup\@esphack}
 
\def\index{\@bsphack\begingroup\@sanitize\catcode32=10\relax\@index}
 
\def\makeindex{\if@filesw \newwrite\@indexfile
  \immediate\openout\@indexfile=\jobname.idx
  \def\index{\@bsphack\begingroup
    \def\protect####1{\string####1\space}\@sanitize
    \catcode32=10 \@wrindex\@indexfile}\typeout
   {Writing index file \jobname.idx }\fi}
 
\flushbottom
 
\endinput
