I'm using the \sindex[]{}
command from the splitxdx
package to create index entries. To control sorting I'm using the @
symbol, for example \sindex[...]{1@One}
.
To make things a bit more configurable, I define a custom command: \newcommand{\sortedOne}{1@One}
.
The problem is when I insert this command into \sindex
's argument, I get the literal text 1@One
showing up. For example, the code \sindex[myindex]{\sortedOne!This fails.}
produces the first of the following entries:
Is there an easy way to avoid this? I would prefer a method where I don't have to manually type out something like \expandafter
each time I use \sindex
.
As an interesting side note, it does work correctly if I wrap the \sindex
command in a \comma@parse
command from the kvsetkeys
package: \comma@parse{\sortedOne!This works with comma parse}{\sindex[myindex]}
.
Here's my MWE that produced the output above:
\documentclass[12pt]{book}
\usepackage[split]{splitidx}\makeindex
\newindex{myindex}
\usepackage{lipsum}
\usepackage{kvsetkeys}
%\usepackage{hyperref}
%\newcommand{\mainindexentry}[1]{\textbf{\hyperpage{#1}}}
\newcommand{\sortedOne}{1@One}
\begin{document}
\lipsum[1]
\sindex[myindex]{1@One!This works fine}
\sindex[myindex]{\sortedOne!This fails.}
\sindex[myindex]{Even subentries fail!\sortedOne}
\makeatletter
\comma@parse{\sortedOne!This works with comma parse}{\sindex[myindex]}
\makeatother
\printindex[myindex]
\end{document}
.idx
file is literal -- nothing is expanded. so\sortedOne
is what goes into the.idx
file for your second and third examples, and of course it doesn't sort with1@One
, since the index sort is basically a dumb ascii sort of whatever is in the.idx
file. unfortunately, i can't suggest how to make that approach work as you want it to. probably someone else can.