%%
%% LaTeX style to for manual index.
%%
\NeedsTeXFormat{LaTeX2e}

\ProvidesPackage{myindex}

% \reallyindex{SORTKEY}{HEADCS}{TYPE}
% writes (index-entry "SORTKEY" "HEADCS" TYPE PAGENUMBER)
% which becomes  \item \HEADCS{SORTKEY} mainpagenumber ; auxpagenumber ...

\newcommand{\mainschindex}[1]{\index{#1!tt!main}}
\newcommand{\mainindex}[1]{\index{#1!rm!main}}
\newcommand{\schindex}[1]{\index{#1!tt!aux}}
\newcommand{\sharpindex}[1]{\index{#1!sharp!aux}}

\newcommand{\codemainindex}[1]{{\mainschindex{{#1}}\code{#1}}}
\newcommand{\codeindex}[1]{{\schindex{#1}\code{#1}}}

\newenvironment{myindex}
               {\if@twocolumn
                  \@restonecolfalse
                \else
                  \@restonecoltrue
                \fi
                \columnseprule \z@
                %!! \columnsep 35\p@
                \twocolumn[\@makeschapterhead{\indexname}]%
                \@mkboth{\MakeUppercase\indexname}%
                        {\MakeUppercase\indexname}%
                \thispagestyle{plain}\parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem}
               {\if@restonecol\onecolumn\else\clearpage\fi}
\renewcommand\@idxitem{\par\hangindent 40\p@}
\renewcommand\subitem{\@idxitem \hspace*{20\p@}}
\renewcommand\subsubitem{\@idxitem \hspace*{30\p@}}
\renewcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}
