No grouping for one index using \imakeidx

formattingimakeidxindexingmakeindex

I have a large project with multiple indexes in LuaLaTeX. Is there a way to use \imakeidx perhaps with a .ind file to have just one of these indexes 'turn off' grouping so that each level 0 item is spaced from the last item or subitem?

For this index, the specific level 0 items do not have a page number so I'd like it to look like:

Item
   Subitem            page
   Subitem            page
   Subitem            page

Item
   Subitem            page

Item
   Subitem            page
   Subitem            page

etc.

Because everything is already working except this, I'd like to stick with just makeindex/imakeidx and style files, not xindy, texindy or anything else.

Here is an example of what I'd like, but it redefines \item, \subitem etc. in the preamble, so only works if it is applied to all indexes. I need it for just a single index, leaving the others alone:

How to set the space between two index entries with the same character

Here's an example in texindy, but I don't know how to use texindy and I have multiple other indexes I'm not keen on redoing:

texindy style file: adding space between grouped entries

Can this be done in just plain regular \makeindex/\imakeidx with a style file? It seems I need an element like item_10 but this does not appear to exist. Or is there some other simple, direct way?

Best Answer

You can apply the customization only to the thematic index.

\documentclass{article}
\usepackage{imakeidx}

\makeindex
\makeindex[title=Thematic index,name=thematic,columns=1]

% customize the thematic index
\makeatletter
\newcommand{\thematiccustom}{%
  \def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}%
  \def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}%
  \def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}%
  \def\indexspace{}%
}
\makeatother

\begin{document}

Text.

\index{something}
\index{another}

\index[thematic]{Fruit!Apple}
\index[thematic]{Fruit!Banana}
\index[thematic]{Fruit!Cherry}

\index[thematic]{Animal!Whale}
\index[thematic]{Animal!Gnu}

\index[thematic]{Automobile!Chevrolet}
\index[thematic]{Automobile!Jaguar}

\index[thematic]{Miscellaneous!Beauty}
%\index[thematic]{Miscellaneous!Happiness}

\printindex

\begingroup
\thematiccustom
\printindex[thematic]
\endgroup

\end{document}

enter image description here

Note: columns=1 is just to better show the separation between items.

Related Question