0

Thanks to David Carlisle who assisted me in sorting index entries by middle name. Now I'd like the associated sub-entries not to repeat the text of the entry: thus the entry would read as

Gaius Julius Sneezer
    Hayfever, 1
    March, 1

Rather than repeating the entry each time.

\documentclass[a4paper]{article}
\usepackage{imakeidx}

\makeindex[title=Index of Romans]

\newcommand\rindex[1]{\xrindex#1\relax}
\def\xrindex#1 #2 #3\relax{\index{#2 #1 #3@#1 #2 #3}}

\begin{document}
This is text. 
\rindex{Gaius Julius Sneezer!Hayfever}
\rindex{Gaius Julius Sneezer!March}
\rindex{Marcus Tullius Snifero!Allergies}
\rindex{Marcus Tullius Snifero!Dust}

\printindex

\end{document}

1 Answer 1

1

enter image description here

I introduced a second command for the ! cases, you could of course get more complicated and use a single command with some testing, but I'd keep it simple.

\documentclass[a4paper]{article}
\usepackage{imakeidx}

\makeindex[title=Index of Romans]

\newcommand\rrindex[1]{\xrrindex#1\relax}
\def\xrrindex#1 #2 #3!#4\relax{\index{#2 #1 #3@#1 #2 #3!#4}}

\begin{document}
This is text. 
\rrindex{Gaius Julius Sneezer!Hayfever}
\rrindex{Gaius Julius Sneezer!March}
\rrindex{Marcus Tullius Snifero!Allergies}
\rrindex{Marcus Tullius Snifero!Dust}

\printindex

\end{document}
1
  • Thank you so much (again!)
    – alice19
    Commented Jul 11, 2023 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .