I use texindy to generate an index.
There are several indexed terms with a leading number. I want these terms to be sorted as if the leading numbers weren't there. This I attempted to achieve with the following merge-rule in my xindy stylesheet:
(merge-rule "^[0-9]+ (.*)" "\1" :eregexp)
Texindy is invoked like this:
texindy --debug level=2 -L czech -M lang/czech/utf8 -M stylesheet.xdy indexfile.idx
However, the result suggests the rule doesn't get applied: terms with a leading number are sorted according to the number, which results in them being at the very beginning of the index. It seems there might be an issue with rule precedence, as xindy applies some rules to normalize numbers included in terms by zero-padding them. The log sample below documents complete processing of one term with leading number.
apply rules once: '1 Kron 29, 10- 13' => '0000001' ' Kron 29, 10- 13'
apply rules once: ' Kron 29, 10- 13' => 'NIL' 'NIL'
apply rules once: 'Kron 29, 10- 13' => 'NIL' 'NIL'
apply rules once: 'ron 29, 10- 13' => 'NIL' 'NIL'
apply rules once: 'on 29, 10- 13' => 'NIL' 'NIL'
apply rules once: 'n 29, 10- 13' => 'NIL' 'NIL'
apply rules once: ' 29, 10- 13' => 'NIL' 'NIL'
apply rules once: '29, 10- 13' => '0000029' ', 10- 13'
apply rules once: ', 10- 13' => 'NIL' 'NIL'
apply rules once: ' 10- 13' => 'NIL' 'NIL'
apply rules once: '10- 13' => '0000010' '- 13'
apply rules once: '- 13' => 'NIL' 'NIL'
apply rules once: ' 13' => 'NIL' 'NIL'
apply rules once: '13' => '0000013' ''
Final merge-rule result: '1 Kron 29, 10- 13' -> '0000001 Kron 0000029, 0000010- 0000013'
How to solve this?
EDIT: minimal example:
document (document.tex):
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{multind}
\makeindex{index}
\begin{document}
This paragraph contains term without a number:
Term\index{index}{Term}
This paragraph contains term beginning with a number:
1st Term\index{index}{1 Term}
Let's add a random\index{index}{random} word to the index.
\printindex{index}{The Testing Index}
\end{document}
xindy stylesheet (stylesheet.xdy):
;; ignore leading numbers when sorting and grouping
(merge-rule "^[0-9]+ (.*)" "\1" :eregexp)
commands to compile:
pdflatex document
texindy -M stylesheet.xdy index.idx
pdflatex document
expected result: index with two letter groups, R and T, with "Term" and "1 Term" under T
actual result: index with three letter groups: R, T and default (no letter). "1 Term" falls into default.
