TransWikia.com

Index with dashes to show levels

TeX - LaTeX Asked by ol so-n-so on June 19, 2021

A LaTeX makeindex style with dashes to indicate subitems and subsubitems is desired. The posting Makeidx, Subentries and dashes here looked like the ticket. With the suggested additions, and a couple from elsewhere, here is the modified .ist

preamble "begin{theindex}thispagestyle{empty}n"
quote '+'
headings_flag 1
heading_suffix ""
item_1  "n subitem --- "
item_x1 "n subitem --- "
item_2  "n subsubitem --- --- "
item_x2 "n subsubitem --- --- "
delim_0 ": "
delim_1 ": "
delim_2 ": "
delim_r "-"
suffix_2p ",f."
suffix_3p ",ff."

The following LaTeX MWE was tested with the style file above (the idxlayout package is used to kill the indents and get a multicolumn index)

documentclass{article}
usepackage{makeidx}
usepackage[subindent=0pt,subsubindent=0pt, totoc=true]{idxlayout}
makeindex
begin{document}

ParentAindex{ParentA}, SubAAindex{ParentA!SubAA}, SubABindex{ParentA!SubAB}, SubACindex{ParentA!SubAC}

ParentBindex{ParentB}, SubBAindex{ParentB!SubBA}, SubsubBAAindex{ParentB!SubBA!SubsubBAA}, SubsubBABindex{ParentB!SubBA!SubsubBAB}, SubBBindex{ParentB!SubBB}

printindex
end{document}    

The problem is that, in the output, the first subitem in a list of subitems does not get the preceding dash(es)

undesired index format

even though the second, third, etc. do. The desired index output is

desired index format

The undesired output only seems to happen when the parent item is itself indexed in the document (and so gets a page number in the index). How may I achieve the desired index format?

One Answer

I did a bit more research, and I found the answer. Two more lines need to be added to the .ist file, namely

item_01 "n subitem --- "
item_12 "n subsubitem --- --- "

where, for example item_01 is the

Command to be inserted between a level 0 item and a level 1 item.

The command item_x1 is the

Command to be inserted between a level 0 item and a level 1 item, where the level 0 item does not have associated page numbers.

There is a similar distinction between item_12 and item_x2. Adding the two commands to the .ist file gives the desired effect, whether the parent index item has a page number or not.

The quoted descriptions come from the Overleaf web site, at https://www.overleaf.com/learn/latex/Indices.

Correct answer by ol so-n-so on June 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP