2

Thanks to a number of great texindy questions here on stackexchange, I have imakeidx working nicely within xelatex using splitindex and custom xindy style files. However, I've run across one formatting issue that I haven't found asked or described anywhere.

I have one index where all the terms are grouped under a small number (~7) of headings. When these headings begin with a different letter, they have some extra space between the groups. However, if the headings begin with the same letter, there is no extra space (see the example image and code below).

My question is, how to I modify my generalstyle.xdy file to get extra space between the main entries?

I don't want extra space between the sub-entires, I just want a consistent format and the lack of space between some groups looks awkward. I realize I could use the un-elegant approach of something like

\index{B@\textbf{\large Danish Tales}|nopage}
\index{C@\textbf{\large Danish Titles}|nopage}

instead of

\index{danish@\textbf{\large Danish Tales}|nopage}
\index{danish titles@\textbf{\large Danish Titles}|nopage}

to force xindy to consider these as being listed under different letters. Or, I could even define "danish" and "danish titles" as separate letters with special sorting rules in an xdy file (far more painful than I want to deal with), but all of this feels so hacked and ugly. Surely there's a simple way to simply define that main group entries, even under the same letter, should get an extra space? (Keep in mind that I'm very new to xindy/texindy/imakeidx - I've only been using them for 1 week at this point...)

Anyhow, here's my working example. It's carved out of a much large document, so apologies if it's not as minimal as it could be.

First, the .tex file:

% !TEX TS-program = xelatex 
% !TEX encoding = UTF-8
% this allows us to use real characters like æ instead of macros like \ae

%% PREAMBLE

%Set the document type
\documentclass[letterpaper,titlepage,twoside,openany,12pt]{book}

%Provide standard TeX shortcuts in xelatex
\usepackage{xunicode}
%Extra customizations for XeLateX
\usepackage{xltxtra}

%XeLateX can't use babel, so use polyglossia instead
%(primarily to get proper hyphenation in the other languages)
\usepackage{polyglossia}
\setdefaultlanguage[variant=american]{english}
\setotherlanguages{icelandic,danish,norsk,swedish}

%Setup the indexing
\usepackage[xindy,splitindex]{imakeidx}
%default index 
\makeindex[title=Index of Tale Information,program=texindy,intoc,columns=2,options=-L icelandic -C utf8 -M lang/icelandic/utf8 -M generalstyle]
%I want to suppress page number on group headings, define \noidxpage so it eats the argument
%the idstyle.xdy defines the formatting option nopage = \noidxpage
\newcommand{\noidxpage}[1]{}

\begin{document}

    \mainmatter

    Dummy text here (really several chapters with lots of stuff indexed\ldots)

    %setup the category headers
    \index{danish@\textbf{\large Danish Tales}|nopage}
    \index{icelandic@\textbf{\large Icelandic Tales}|nopage}
    \index{danish titles@\textbf{\large Danish Titles}|nopage}
    \index{icelandic titles@\textbf{\large Icelandic Titles}|nopage}
    \index{collectors@\textbf{\large Collector}|nopage}
    \index{storytellers@\textbf{\large Storyteller}|nopage}
    \index{location@\textbf{\large Location Collected}|nopage}

    %dummy index info to show what I see
    \index{danish!Jesper the Rabbit Herder}
    \index{danish titles!Jesper Harehyrde}
    \index{collectors!Kristensen, Evald Tang}
    \index{storytellers!Futtrup, Rasmus}
    \index{location!DK, Lemvig}
    \index{danish!The Little Horse}
    \index{danish titles!Det Lille Øg}
    \index{collectors!Grundtvig, Svend}
    \index{storytellers!Krag-Juel-Vind, Elisa}
    \index{location!DK, Horsens}
    \index{icelandic!Mori, the Hound}
    \index{icelandic titles!Hundurinn Móri}
    \index{collectors!Árnason, Jón}
    \index{icelandic!Bukolla}
    \index{icelandic titles!Búkolla}
    \index{collectors!Einarsson, Magnús}
    \index{storytellers!Renessee, Ingibjörg}
    \index{storytellers!Skúlason, Hrund}
    \index{storytellers!Þorgrímsson, Sigrún}


    %Create the index
    \printindex

\end{document}

Here's the xindy style file:

;Allow removing page numbers (e.g. for group headings)
;   this requires putting the comma in the default formatting
;   of the page number so that the default seperator is blank
(define-attributes (("nopage")) )
(markup-locref :attr "nopage" :open "\noidxpage{" :close "}")
(markup-locref :attr "default" :open ", \textbf{" :close "}")
;
;(markup-locclass-list :open "\dotfill " :sep ", ")
(markup-locclass-list :open "" :sep "")
;
;(markup-locref-list   :sep ", ")
(markup-locref-list   :sep "")
;
(markup-range :sep "--")


(markup-index :open  "\begin{theindex}~n
 \providecommand*\lettergroupDefault[1]{}
 \providecommand*\lettergroup[1]{%
   \nopagebreak
  }"
          :close "~n~n\end{theindex}~n"
          :tree)


;; The indexentries (item_<..> specifiers)

(markup-indexentry :open "~n  \item "           :depth 0)
(markup-indexentry :open "~n    \subitem "     :depth 1)
(markup-indexentry :open "~n      \subsubitem " :depth 2)

And this is an image of the resulting index:

Index with several main groupings

4

First solution: You see that the .ind file generated with your code is something like that:

\begin{theindex}

 \providecommand*\lettergroupDefault[1]{}
 \providecommand*\lettergroup[1]{%
   \nopagebreak
  }
  \lettergroup{C}
  \item \textbf{\large Collector}\noidxpage{1}
    \subitem Árnason, Jón, \textbf{1}
    \subitem Einarsson, Magnús, \textbf{1}
    \subitem Grundtvig, Svend, \textbf{1}
    \subitem Kristensen, Evald Tang, \textbf{1}

  \indexspace

  \lettergroup{D}
  \item \textbf{\large Danish Tales}\noidxpage{1}
    \subitem Jesper the Rabbit Herder, \textbf{1}
    \subitem The Little Horse, \textbf{1}
  \item \textbf{\large Danish Titles}\noidxpage{1}
    \subitem Det Lille Øg, \textbf{1}
    \subitem Jesper Harehyrde, \textbf{1}

You have a \indexspace command (defined in book.cls) between lettergroups. What you want is to have a vertical space between every item, because you don't print anything for lettergroups. So a solution can be adding a vertical space after every item, modifying your style file:

...
;; The indexentries (item_<..> specifiers)

(markup-indexentry  :open "~n  \item "           
                    :close "\bigskip"
                    :depth 0)
(markup-indexentry :open "~n    \subitem "     :depth 1)
(markup-indexentry :open "~n      \subsubitem " :depth 2)

I added a :close argument for the \item markup-indexentry. What you get is:

\begin{theindex}

 \providecommand*\lettergroupDefault[1]{}
 \providecommand*\lettergroup[1]{%
   \nopagebreak
  }
  \lettergroup{C}
  \item \textbf{\large Collector}\noidxpage{1}
    \subitem Árnason, Jón, \textbf{1}
    \subitem Einarsson, Magnús, \textbf{1}
    \subitem Grundtvig, Svend, \textbf{1}
    \subitem Kristensen, Evald Tang, \textbf{1}\bigskip

  \indexspace

  \lettergroup{D}
  \item \textbf{\large Danish Tales}\noidxpage{1}
    \subitem Jesper the Rabbit Herder, \textbf{1}
    \subitem The Little Horse, \textbf{1}\bigskip
  \item \textbf{\large Danish Titles}\noidxpage{1}
    \subitem Det Lille Øg, \textbf{1}
    \subitem Jesper Harehyrde, \textbf{1}\bigskip

  \indexspace

But you see that after a lettergroup you add your \bigskip to \indexspace. So you have to remove the effect of \indexspace after a lettergroup. You can modify your style file:

;Allow removing page numbers (e.g. for group headings)
;   this requires putting the comma in the default formatting
;   of the page number so that the default seperator is blank
(define-attributes (("nopage")) )
(markup-locref :attr "nopage" :open "\noidxpage{" :close "}")
(markup-locref :attr "default" :open ", \textbf{" :close "}")
;
;(markup-locclass-list :open "\dotfill " :sep ", ")
(markup-locclass-list :open "" :sep "")
;
;(markup-locref-list   :sep ", ")
(markup-locref-list   :sep "")
;
(markup-range :sep "--")


(markup-index :open  "\begin{theindex}~n
 \providecommand*\lettergroupDefault[1]{}
 \providecommand*\lettergroup[1]{%
   \nopagebreak}
   \let\oldindexspace\indexspace
   \def\indexspace{}
  "
          :close "~n~n\end{theindex}~n"
          :tree)


;; The indexentries (item_<..> specifiers)

(markup-indexentry  :open "~n  \item "           
                    :close "\oldindexspace"
                    :depth 0)
(markup-indexentry :open "~n    \subitem "     :depth 1)
(markup-indexentry :open "~n      \subsubitem " :depth 2)

You save the definition of \indexspace in \oldindexspace and then you "clear" it. Now you have a vertical space after every item and no space after lettergroups.

enter image description here

Second solution: If you have a lot of entries you could consider to create a separate index for every "family"using imakeidx features:

% !TEX TS-program = xelatex 
% !TEX encoding = UTF-8
% this allows us to use real characters like � instead of macros like \ae

%% PREAMBLE

%Set the document type
\documentclass[letterpaper,titlepage,twoside,openany,12pt]{book}

%Provide standard TeX shortcuts in xelatex
\usepackage{xunicode}
%Extra customizations for XeLateX
\usepackage{xltxtra}

%XeLateX can't use babel, so use polyglossia instead
%(primarily to get proper hyphenation in the other languages)
\usepackage{polyglossia}
\setdefaultlanguage[variant=american]{english}
\setotherlanguages{icelandic,danish,norsk,swedish}

%Setup the indexing
\usepackage[xindy,splitindex]{imakeidx}


\newcommand{\noidxpage}[1]{}

\makeindex[name=collector,title=Collector, program=texindy,intoc,columns=2,options=-L icelandic -C utf8 -M lang/icelandic/utf8 -M generalstyle]
\makeindex[name=danishta, title=Danish Tales ,program=texindy,intoc,columns=2,options=-L icelandic -C utf8 -M lang/icelandic/utf8 -M generalstyle]
\makeindex[name=danishtit, title=Danish Titles, program=texindy,intoc,columns=2,options=-L icelandic -C utf8 -M lang/icelandic/utf8 -M generalstyle]
\makeindex[name=icelandicta, title= Icelandic Tales, program=texindy,intoc,columns=2,options=-L icelandic -C utf8 -M lang/icelandic/utf8 -M generalstyle]
\makeindex[name=icelandictit, title= Icelandic Titles, program=texindy,intoc,columns=2,options=-L icelandic -C utf8 -M lang/icelandic/utf8 -M generalstyle]
\makeindex[name=location, title=Location Collected, program=texindy,intoc,columns=2,options=-L icelandic -C utf8 -M lang/icelandic/utf8 -M generalstyle]
\makeindex[name=storyteller, title=Storyteller, program=texindy,intoc,columns=2,options=-L icelandic -C utf8 -M lang/icelandic/utf8 -M generalstyle]

\begin{document}
\mainmatter
Dummy text here (really several chapters with lots of stuff indexed\ldots)

 %dummy index info to show what I see
\index[danishta]{Jesper the Rabbit Herder}
\index[danishtit]{Jesper Harehyrde}
\index[collector]{Kristensen, Evald Tang}
\index[storyteller]{Futtrup, Rasmus}
\index[location]{DK, Lemvig}
\index[danishta]{The Little Horse}
\index[danishtit]{Det Lille Øg}
\index[collector]{Grundtvig, Svend}
\index[storyteller]{Krag-Juel-Vind, Elisa}
\index[location]{DK, Horsens}
\index[icelandicta]{Mori, the Hound}
\index[icelandictit]{Hundurinn Móri}
\index[collector]{Árnason, Jón}
\index[icelandicta]{Bukolla}
\index[icelandictit]{Búkolla}
\index[collector]{Einarsson, Magnús}
\index[storyteller]{Renessee, Ingibjörg}
\index[storyteller]{Skúlason, Hrund}
\index[storyteller]{Þorgrímsson, Sigrún}

%Create the index
\printindex[collector]
\printindex[danishta]
\printindex[danishtit]
\printindex[icelandicta]
\printindex[icelandictit]
\printindex[location]
\printindex[storyteller]

\end{document}

The result is several indexes like this:enter image description here

  • The \oldindexspace and redefinition of \indexspace worked great - thank you! I am familiar with splitindex (I currently have an index of characters and an index of tale motifs in adition to this general index) - depending on the final length of the book, it might make sense to further split my general index, but for now your solution is exactly what I was looking for. – S. Burt Oct 20 '15 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.