# No grouping for one index using \imakeidx

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?

• That style is what you get out of the box with \index{Item!Subitem} Aug 13 at 10:57
• Actually, neither Cicada's reply nor egreg's reply do what I want. I had already had \index{Item!Subitem}. The problem I was having with that structure was that there were two Items that begin with the same letter, and I want a blank line between those major categories - no grouping. Going to a splitindex did not solve this issue either. In the example code in Canids's solution, there is no space between the block for Canids and the box for Cats. I'd like spacing between every Item as is seen between Cats and Miscellaneous regardless of the initial letter of the Items. Aug 31 at 14:30
• Edit your question with the details. Aug 31 at 14:32
• Well, I'm not sure what you are missing. I gave an example of the sample output I wanted to get. You'll notice that each Item in my desired output list is separated by a blank line from the last entry of the item before. The sample MWE in Cicada's example shows the problem, which occurs whether I use the standard \index{Item!Subitem} or their splitindex solution: two major Item blocks that begin with the same first letter are not separated from one another. I want them separated. Aug 31 at 15:23

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}


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

• Thank you. This is perfect, and by avoiding splitindex allows one fewer compile. Sep 2 at 0:56

For each thematic "category", manually add (and keep track of) a separate sorting character (s@t, where s = sorting string, t = index entry text, with "a@" for "cats", "b@" and "c@" for canids and carrypacks respectively, and "z@" for misc, so the index entry would look like, for example, \index[theme]{a@Cats!leopard}). "Miscellaneous" would logically be at the end in a theme list.

An .ist file with a dotfill command would give you right justification: if it is called plain.ist, invoking it would be by: \makeindex[name=theme,title=Thematic Index,options=-s plain].

One-column (columns=1 option in the \makeindex command):

Default two-columns:

MWE

\documentclass{article}
\usepackage[splitindex]{imakeidx}
\makeindex[name=fel,title=Cats]%a
\makeindex[name=can,title=Canids]%b
\makeindex[name=equ,title=Carrypacks]%c
\makeindex[name=msc,title=Misc]%z
\makeindex[name=theme,title=Thematic Index,options=-s plain]
\begin{document}
lion\index[fel]{lion}\index[theme]{a@Cats!lion}
coyote\index[can]{coyote}\index[theme]{b@Canids!coyote}
zebra\index[equ]{zebra}\index[theme]{c@Carrypacks!zebra}
moose\index[msc]{moose}\index[theme]{z@Miscellaneous!moose}
\newpage
wolf\index[can]{wolf}\index[theme]{b@Canids!wolf}
gazelle\index[equ]{gazelle}\index[theme]{c@Carrypacks!gazelle}
tiger\index[fel]{tiger}\index[theme]{a@Cats!tiger}
mouse\index[msc]{mouse}\index[theme]{z@Miscellaneous!mouse}
\newpage
guinea pig\index[msc]{guinea pig}\index[theme]{z@Miscellaneous!guinea pig}
leopard\index[fel]{leopard}\index[theme]{a@Cats!leopard}
dingo\index[can]{dingo}\index[theme]{b@Canids!dingo}
horse\index[equ]{horse}\index[theme]{c@Carrypacks!horse}
\newpage
\printindex[can]
\printindex[equ]
\printindex[fel]
\printindex[msc]
\printindex[theme]

\end{document}


The plain.ist file:

delim_0 "\\space\\dotfill\\space "
delim_1 "\\space\\dotfill\\space "
delim_2 "\\space\\dotfill\\space "
delim_n ", "
delim_r "--"
delim_t ""
encap_prefix "\\"
encap_infix "{"
encap_suffix "}"
line_max 1000


If I have understood correctly, do you mean adding something like a summary or thematic index, using level 0 as grouping?

It's a separate index and has its own \index[...]{...} entries.

A script could go through the .idx files and derive a theme .idx file, getting, say, \indexentry{lion}{1} (from the -fel.idx) and outputting \indexentry{Cats!lion}{1} into the -theme.idx but this would be partway through the automatic toolchain, and in any case, a mapping to match the sub-entry (lion) to the grouping (Cats) would still need to be done/defined somewhere beforehand. Perhaps a regex could work, after the mapping is established.

MWE

\documentclass{article}
\usepackage[splitindex]{imakeidx}
\makeindex[name=fel,title=Cats]
\makeindex[name=can,title=Canids]
\makeindex[name=msc,title=Misc]
\makeindex[name=theme,title=Thematic Index]
\begin{document}
lion\index[fel]{lion}\index[theme]{Cats!lion}
coyote\index[can]{coyote}\index[theme]{Canids!coyote}
moose\index[msc]{moose}\index[theme]{Miscellaneous!moose}
\newpage
wolf\index[can]{wolf}\index[theme]{Canids!wolf}
tiger\index[fel]{tiger}\index[theme]{Cats!tiger}
mouse\index[msc]{mouse}\index[theme]{Miscellaneous!mouse}
\newpage
guinea pig\index[msc]{guinea pig}\index[theme]{Miscellaneous!guinea pig}
leopard\index[fel]{leopard}\index[theme]{Cats!leopard}
dingo\index[can]{dingo}\index[theme]{Canids!dingo}
\newpage
\printindex[can]
\printindex[fel]
\printindex[msc]
\printindex[theme]

\end{document}

• I think this is what I want; regrettably I'm leaving town for a time and won't be able to implement it yet to try it out soon. As a follow on question, would a style file to right justify the page numbers be creates for the index "theme" or for each of the sub-indices "fel" " can" and "msc"? And can this work in a document with other separate indices that are not involved with a splitindex? Thanks! Aug 13 at 10:38
• As it turns out, this is almost what I want, except that I want a blank line between the Canids block, ending in wolf, and the line for Cats. That is, I don't care that Canids and Cats start with the same letter - I want the same space between the block for Canids (ending in wolf) and the block for Cats as there is between the block for Cats (ending in tiger) and the block for Miscellaneous. Aug 31 at 17:46
• Ask all these new questions in separate posts, with one question per post. That way, more eyes are on them, with a greater chance of response. No one will be trawling through comments to identify if there are additional questions. Link back to this question, for context. I don't know the answers. There's an experiment I want to try with sorting (labelling the categories with different ascii sort chars, to get the blank line). Plus: by "right justified", do you mean (like) a 1-column index, not a 2-column index?? Sep 1 at 11:38
• See amended answer. Sep 1 at 12:35
• The amended answer works, thank you very much. It's amazing how complicated things have to get to add one blank line. Sep 1 at 14:49