1

I have a number of Roman names. I'd like to sort them by middle name (gens) which is much more useful than by first or last. Is this possible?

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

\makeindex[title=Index of Romans]

\begin{document}


Here I reference Marcus Tullius Cicero\index{Marcus Tullius Cicero} and Gaius Julius Caesar.\index{Gaius Julius Caesar} I'd like the index entry to appear sorted by the middle part of the name (Gaius \textit{Pompeius} Magnus); it is not a viable solution to list it as Pompeius, Gaius Magnus\index{Pompeius, Gaius Magnus} as this lists names in the order 2, 1, 3, which is odd. 

That is, it should be sorted as \textit{Pompeius Magnus, Gaius} but appear as \textit{Gaius Pompeius Magnus}. 

%Thus these should sort in order of the middle name:

\index{Derek Al Cicero}
\index{Charlie Ben Cicero}
\index{Ben Charlie Cicero}
\index{Al Derek Cicero}

\printindex

\end{document}

1 Answer 1

2

You can separate a sort key and print form with @

enter image description here

\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}


Here I reference Marcus Tullius Cicero\rindex{Marcus Tullius Cicero}
and Gaius Julius Caesar.\rindex{Gaius Julius Caesar} I'd like the
index entry to appear sorted by the middle part of the name (Gaius
\textit{Pompeius} Magnus); it is not a viable solution to list it as
Pompeius, Gaius Magnus\rindex{Gaius Pompeius Magnus} as this lists
names in the order 2, 1, 3, which is odd.

That is, it should be sorted as \textit{Pompeius Magnus, Gaius} but
appear as \textit{Gaius Pompeius Magnus}.

%Thus these should sort in order of the middle name:

\rindex{Derek Al Cicero}
\rindex{Charlie Ben Cicero}
\rindex{Ben Charlie Cicero}
\rindex{Al Derek Cicero}

\printindex

\end{document}
1
  • Fantastic thank you!
    – alice19
    Commented Jul 11, 2023 at 17:35

You must log in to answer this question.

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