按中间名对索引条目进行排序

按中间名对索引条目进行排序

我有许多罗马名字。我想按中间名对它们进行排序(氏族) 比 first 或 last 更有用。这可能吗?

\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

您可以使用以下方式分离排序键和打印表单@

在此处输入图片描述

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

相关内容