Book logo xindy

A Flexible Indexing System


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New Version of xindy.sty



Hi,

 I've fixed some minor bugs in xindy.sty:
   
   - indexstyles chapter and section are only defined, if
     the corresponding \chapter / \section is defined
   - \ wasn't doubled in all cases when german.sty wasn't loaded.
   - \newindexstyle, \indexstyle now check if the indexstyle is
     existing
   - \renewindexstyle can be used to redefine a indexstyle.
   
 All other mentioned problems aren't solved yet.
 
CU, Andi
   
-----xindy.sty-----
\RequirePackage{keyval}
%
%%
%% various Indexstyles
%%
%
\def\newindexstyle#1#2{%
    \@ifundefined{xindy@style@#1}%
    {\expandafter\gdef\csname xindy@style@#1\endcsname{#2}}
    {\typeout{xindy: indexstyle #1 already defined}}}
\def\renewindexstyle#1#2{%
    \expandafter\let\csname xindy@style@#1\endcsname=\undefined%
    \newindexstyle{#1}{#2}}
\newindexstyle{page}{\thepage}
\ifx\@undefined\chapter\else
    \newindexstyle{chapter}{\thechapter-\thepage}
\fi
\ifx\@undefined\section\else
    \newindexstyle{section}{\thesection-\thepage}
\fi
%
%%
%% select style
%%
%
\def\indexstyle#1{%
    \@ifundefined{xindy@style@#1}
       {\typeout{xindy: indexstyle #1 not defined}}
       {\def\xindy@style{\csname xindy@style@#1\endcsname}}}
\indexstyle{page}
%
%%
%% The keys for the index
%%
%
\define@key{xindy}{attr}{%
   \def\xindy@attr{#1}%
   \ifx\@empty\xindy@attr%
   \else%
      \def\xindy@attr{:attr "#1"}%
   \fi}
\def\xindy@attr{}
\define@key{xindy}{open-range}[:open-range]{\def\xindy@range{:open-range}}
\define@key{xindy}{close-range}[:close-range]{\def\xindy@range{:close-range}}
\def\xindy@range{}
\define@key{xindy}{xref}{\def\xindy@xref{#1}}
\def\xindy@xref{}
%
%%
%% The Backslash should be doubled
%%
%
\begingroup
 \catcode`\|=0
 \catcode`|\=12
 |gdef|xindy@bsps{\\}
 |catcode`|\=|active
 |global|let\|xindy@bsps
|endgroup
%
%%
%% The indexing command
%%
%
\def\indexindy{%
    \begingroup
    \toks@{}
    \ifx\@undefined\germanTeX%
        \catcode`\\=\active
        \expandafter\indexindy@%
    \else%
        \mdqoff\catcode`\\=\active
        \expandafter\indexindy@%
    \fi}
\newcommand{\indexindy@}[2][]{%
 \xindy@checksyntax{#2}%
 \expandafter\def\expandafter\xindy@tmp\expandafter{\the\toks@}%
 \setkeys{xindy}{#1}%
  \index{(indexentry :tkey (\xindy@tmp)%
   \space\xindy@attr\space\xindy@range\space%
   \ifx\@empty\xindy@xref%
       :locref "\xindy@style"%
   \else%
       :xref (\xindy@xref)%
   \fi%
   )}
 \endgroup
}
\def\xindy@checksyntax#1{%
    \def\xindy@tmp{#1}%
    \xindy@for\xindy@@tmp:=\xindy@tmp\do{\xindy@@checksyntax}}
\def\xindy@@checksyntax{%
    \addto@hook\toks@{ ( }%
    \@for\xindy@@@tmp:=\xindy@@tmp\do{%
         \expandafter\addto@hook\expandafter\toks@\expandafter{\expandafter"\xindy@@@tmp" }}%
    \addto@hook\toks@{) }}
%
%%
%% We need a special for-command
%%
%
\def\xindy@fornoop#1\@@#2#3{}
\long\def\xindy@for#1:=#2\do#3{%
  \expandafter\def\expandafter\xindy@fortmp\expandafter{#2}%
  \ifx\xindy@fortmp\@empty \else
    \expandafter\xindy@forloop#2;\@nil;\@nil\@@#1{#3}\fi}
\long\def\xindy@forloop#1;#2;#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
       #5\def#4{#2}\ifx #4\@nnil \else#5\xindy@iforloop #3\@@#4{#5}\fi\fi}
\long\def\xindy@iforloop#1;#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
       \expandafter\xindy@fornoop \else
      #4\relax\expandafter\xindy@iforloop\fi#2\@@#3{#4}}
\def\xindy@tfor#1:={\xindy@tf@r#1 }
\long\def\xindy@tf@r#1#2\do#3{\def\xindy@fortmp{#2}\ifx\xindy@fortmp\space\else
    \xindy@tforloop#2\@nil\@nil\@@#1{#3}\fi}
\long\def\xindy@tforloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
       \expandafter\xindy@fornoop \else
      #4\relax\expandafter\xindy@tforloop\fi#2\@@#3{#4}}
\long\def\@breakxindy@tfor#1\@@#2#3{\fi\fi}

\def\@wrindex#1{%
   \protected@write\@indexfile{}%
      {#1}%
 \endgroup
 \@esphack}
-----------------------------