LaTeX forum ⇒ MakeIndex, Nomenclature, Glossaries and AcronymsChange index "see also" and "see" format

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
murraye
Posts: 34
Joined: Sat Aug 15, 2009 6:25 pm

Change index "see also" and "see" format

Postby murraye » Fri Jul 08, 2016 5:00 pm

Desired index result

I want an index using makeindex to have entries like the following (where I've used ~~~ and ~~~~~~ to indicate indenting for subentries and sub subentries):

nothing, 1
~~~ nil, 1
~~~~~~ and zero, 1
~~~~~~ (see also null elements}
~~~ null, 1
~~~ See also zero elements
null elements, 1

zero (see zero elements)
zero elements, 1

Note the following formatting requirements shown:

  • A "See also ..." for a main entry begins with an upper-case "S".
  • A "(see also ...)" for a subentry is indented below the subentry and enclosed in parens.
  • A "(see ...)" cross-reference is enclosed in parens.
  • A "(see ...)" cross-reference does not include a comma after the (sub)entry on its line.
  • A "see" or "see also"/"See also" entry does not end with a page number.
Here's a screen shot of the printed index:
Image

A working source file that produces the result

The following source file will accomplish that:
  1. \documentclass{book}
  2. \usepackage{makeidx}
  3.  
  4. \newcommand\gobbleone[1]{}
  5. \newcommand*{\seeonly}[2]{\ (\emph{\seename} #1)}
  6. \newcommand*{\also}[2]{(\emph{\alsoname} #1)}
  7. \newcommand{\Also}[2]{\emph{See also} #1}
  8.  
  9. \makeindex
  10.  
  11. \begin{document}
  12.  
  13. This is a short book about zero. Therefore, it's also about nothing.
  14. Which means null (or nil).
  15.  
  16. \index{nothing}
  17. \index{nothing!nil}
  18. \index{nothing!nil!and zero} % added for clarity
  19. \index{nothing!nil!zzzzz@\also{null elements}|gobbleone}
  20. \index{nothing!null}
  21. \index{nothing!zzzzz@\Also{zero elements}|gobbleone}
  22. \index{null elements}
  23.  
  24. \index{zero \seeonly{zero elements}|gobbleone}
  25. \index{zero elements}
  26.  
  27. \printindex
  28.  
  29. \end{document}


Simplification & improvement sought

Can this be simplified by suitable definitions that would avoid having to explicitly include the `|gobbleone` in each "see only" and "see" entry? And it would even be better if I did not have to explicitly include the `zzzzz@` sort key that puts the "see also" subentries after all others.

I would strongly prefer definitions written in LaTeX (using `newcommand`) rather than at lower-level TeX (using `\def`).

These related postings unfortunately do not seem to accomplish what I need:


Tags:

Return to “MakeIndex, Nomenclature, Glossaries and Acronyms”

Who is online

Users browsing this forum: No registered users and 1 guest