5

I am preparing an index with entries that use the International Phonetic Alphabet (which largely consists of lowercase Latin letters, but with additions. I have specified my desired sort order in an .xdy file. When xindy prepares the index, the groupings appear in my specified order. For instance, the 'ʌ' entries appear before the 'a' entries. But when sorting keys, the default sorting order occurs: aʌ appears after aa instead of before. (I've duplicated the sort order that appears in the code below.) Do I need to specify some further sorting rule?

xelatex
xindy -I latex -o xindy-ipa-sorting.ind -M ipa-alphabet xindy-ipa-sorting.idx
xelatex

xindy-ipa-sorting.tex:

\documentclass{book}
\usepackage{polyglossia}
\setmainfont{Times New Roman}
\usepackage{makeidx,lipsum}
\makeindex
\begin{document}
\lipsum[1]

\index{ʌa}
\index{ʌʌ}

\index{aa}
\index{aʌ}

\printindex
\end{document}

ipa.xdy (base on this answer):

;; xindy style file for an index with extended alphabet

(define-attributes (("default" "textbf" "textit" "hyperpage")))

;; "see" and "see also"

(define-crossref-class "see")
(markup-crossref-list :class "see" :open "\see{" :sep "; " :close "}{}")
(define-crossref-class "seealso")
(markup-crossref-list :class "seealso" :open "\seealso{" :sep "; " :close "}{}")

(markup-crossref-layer-list :sep ", ")

(require "base/numeric-sort.xdy")

(define-location-class "arabic-page-numbers" ("arabic-numbers"))
(define-location-class "roman-page-numbers"  ("roman-numbers-lowercase"))
(define-location-class "Roman-page-numbers"  ("roman-numbers-uppercase"))
(define-location-class "alpha-page-numbers"  ("alpha"))
(define-location-class "Alpha-page-numbers"  ("ALPHA"))

(define-location-class-order ("roman-page-numbers"
                  "Roman-page-numbers"
                  "arabic-page-numbers"
                  "alpha-page-numbers"
                  "Alpha-page-numbers"
                  "see"
                  "seealso"))

(require "lang/english/utf8.xdy")

(define-alphabet "latin-ipa"
("ʌ" "a" "b" "d" "dʒ" "e" "ɛ" "f" "ɡ" "ɣ" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "ʃ" "t" "tʃ" "u" "ʊ" "w" "x" "z" "ʒ" "ʔ"))
(define-letter-groups
("ʌ" "a" "b" "d" "dʒ" "e" "ɛ" "f" "ɡ" "ɣ" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "ʃ" "t" "tʃ" "u" "ʊ" "w" "x" "z" "ʒ" "ʔ"))

(define-letter-group "ʌ" :before "a")
(define-letter-group "dʒ" :after "d" :before "e")
(define-letter-group "ɛ" :after "e" :before "f")
(define-letter-group "ɣ" :after "ɡ" :before "h")
(define-letter-group "ʃ" :after "s" :before "t")
(define-letter-group "tʃ" :after "t" :before "u")
(define-letter-group "ʊ" :after "u" :before "w")
(define-letter-group "ʒ" :after "z" :before "ʔ")
(define-letter-group "ʔ" :after "ʒ" )

;; =======================
;; merge rules
;; =======================

;; LaTeX and TeX conventions

(merge-rule "\\LaTeXe *" "LaTeX2e" :eregexp :again)
(merge-rule "\\BibTeX *" "BibTeX" :eregexp :again)
(merge-rule "\\AmSTeX *" "AmSTeX" :eregexp :again)
(merge-rule "\\AmSLaTeX *" "AmSLaTeX" :eregexp :again)
(merge-rule "\\XeT *" "XeT" :eregexp :again)

(require "base/tex.xdy")

(markup-locref :open "\textbf{" :close "}" :attr "textbf")
(markup-locref :open "\textit{" :close "}" :attr "textit")
(markup-locref :open "\hyperpage{" :close "}" :attr "hyperpage")

;; =======================
;; sort rules
;; =======================

;; list pali capitals under pali lowercase

(sort-rule "g" "ɡ")

;;(sort-rule "Ā" "ā")
;;(sort-rule "Ṃ" "ṃ")
;;(sort-rule "Ī" "ī")
;;(sort-rule "Ñ" "ñ")

;; list latin capitals under latin lowercase

;;(sort-rule "A" "a")
;;(sort-rule "B" "b")
;;(sort-rule "C" "c")
;;(sort-rule "D" "d")
;;(sort-rule "E" "e")
;;(sort-rule "F" "f")
;;(sort-rule "G" "g")
;;(sort-rule "H" "h")
;;(sort-rule "I" "i")
;;(sort-rule "J" "j")
;;(sort-rule "K" "k")
;;(sort-rule "L" "l")
;;(sort-rule "M" "m")
;;(sort-rule "N" "n")
;;(sort-rule "O" "o")
;;(sort-rule "P" "p")
;;(sort-rule "Q" "q")
;;(sort-rule "R" "r")
;;(sort-rule "S" "s")
;;(sort-rule "T" "t")
;;(sort-rule "U" "u")
;;(sort-rule "V" "v")
;;(sort-rule "W" "w")
;;(sort-rule "X" "x")
;;(sort-rule "Y" "y")
;;(sort-rule "Z" "z")

;; ======================
;; markup rules
;; ======================

(require "base/page-ranges.xdy")

(markup-index :open
"\begin{theindex}
  \providecommand*\lettergroupDefault[1]{}
  \providecommand*\lettergroup[1]{%
      \par\textbf{#1}\par
      \nopagebreak
  }
"
          :close "~n~n\end{theindex}~n"
          :tree)

(markup-indexentry :open "~n  \item "           :depth 0)
(markup-indexentry :open "~n    \subitem "      :depth 1)
(markup-indexentry :open "~n      \subsubitem " :depth 2)

(markup-locclass-list :open ", " :sep ", ")
(markup-locref-list   :sep ", ")

;; letter group markup

(markup-letter-group-list :sep "~n~n  \indexspace~n")

(markup-letter-group :open-head "~n  \lettergroupDefault{" :close-head "}" :group "default")
(markup-letter-group :open-head "~n  \lettergroup{" :close-head "}")

1 Answer 1

6

It turns out that changing the keyword sorting order involves defining a new language. It's not sufficient to define new letter groups in a .xdy file. (Once you define the new language, however, you get the letter groupings for free, so that's something.)

I followed the procedure outlined in this answer, for Vietnamese. I'm going to include my code here, however, since it might be a little easier to follow than the Vietnamese diacritics, and the step of adding utf8-lang.xdy was new. Starting from the point in the answer where xindy-make-rules-0.2 has been downloaded and extracted...

In the xindy-make-rules-0.2/alphabets directory I created a new folder called ipa and then created utf8.pl.in with this content:

#!/usr/bin/perl

$language = "IPA";
$prefix = "ipa";
$script = "latin";

$alphabet = [
['ʌ',  ['ʌ']],
['a',  ['a']],
['b',  ['b']],
['d',  ['d']],
['dʒ',  ['dʒ']],
['e',  ['e']],
['ɛ',  ['ɛ']],
['f',  ['f']],
['ɡ',  ['ɡ', 'g']],
['ɣ',  ['ɣ']],
['h',  ['h']],
['i',  ['i']],
['j',  ['j']],
['k',  ['k']],
['l',  ['l']],
['m',  ['m']],
['n',  ['n']],
['o',  ['o']],
['p',  ['p']],
['q',  ['q']],
['r',  ['r']],
['s',  ['s']],
['ʃ',  ['ʃ']],
['t',  ['t']],
['tʃ',  ['tʃ']],
['u',  ['u']],
['ʊ',  ['ʊ']],
['w',  ['w']],
['x',  ['x']],
['z',  ['z']],
['ʒ',  ['ʒ']],
['ʔ',  ['ʔ']],
];

$sortcase = 'Aa';
#$sortcase = 'aA';

@special = ('?', '!', '.', 'letters', '-', '\'', '{', '}');

do 'make-rules.pl';

(This goes beyond the scope of my MWE above, but I think in a comprehensible way.)

I edited xindy-make-rules-0.2/alphabets/Makefile so that INSTDIR (line 7) reflected the location of my xindy installation (in my case "D:\Program Files (x86)\MiKTeX 2.9\xindy\modules\lang").

Then in the xindy-make-rules-0.2/alphabets directory I executed these commands:

make utf8
make install

Note: Although this worked at the time, when I tried the same commands recently, it would not build my file until I included myalphabet/utf8.xdy \ under the XDYSUTF8 list in xindy-make-rules-0.2/alphabets/Makefile (line 66 of my copy).

(Since I am a Windows user, I executed these commands using msys. Using mingw32-make did not work for me.)

For whatever reason, the script does not create a file that I found to be crucial. So, in the xindy/modules/lang/ipa directory, I had to create the file utf8-lang.xdy:

(require "lang/ipa/utf8.xdy")
(define-sort-rule-orientations (forward backward forward forward))
(use-rule-set :run 0
          :rule-set ("ipa-alphabetize" "ipa-ignore-special"))
(use-rule-set :run 1
          :rule-set ("ipa-resolve-diacritics" "ipa-ignore-special"))
(use-rule-set :run 2
          :rule-set ("ipa-resolve-case" "ipa-ignore-special"))
(use-rule-set :run 3
          :rule-set ("ipa-resolve-special"))

Note that this file requires ipa.xdy, which is the file provided in the question above.

So to recap, there should now be a subfolder called ipa in the xindy modules/lang folder (in my case "D:\Program Files (x86)\MiKTeX 2.9\xindy\modules\lang"), and that folder should contain three files: utf8.pl.in, utf8.xdy, and utf8-lang.xdy.

With that done, I am able to invoke xindy as follows:

xindy -L IPA -I latex -o example.ind -M ipa example.idx

ipa.xdy is a stripped-down version from my MWE above. The file now really just provides the basic options and the markup commands. There's nothing specific to the IPA alphabet.

;; xindy style file for an index with extended alphabet

(define-attributes (("default" "textbf" "textit" "hyperpage")))

;; "see" and "see also"

(define-crossref-class "see")
(markup-crossref-list :class "see" :open "\see{" :sep "; " :close "}{}")
(define-crossref-class "seealso")
(markup-crossref-list :class "seealso" :open "\seealso{" :sep "; " :close "}{}")

(markup-crossref-layer-list :sep ", ")

(require "base/numeric-sort.xdy")

(define-location-class "arabic-page-numbers" ("arabic-numbers"))
(define-location-class "roman-page-numbers"  ("roman-numbers-lowercase"))
(define-location-class "Roman-page-numbers"  ("roman-numbers-uppercase"))
(define-location-class "alpha-page-numbers"  ("alpha"))
(define-location-class "Alpha-page-numbers"  ("ALPHA"))

(define-location-class-order ("roman-page-numbers"
                  "Roman-page-numbers"
                  "arabic-page-numbers"
                  "alpha-page-numbers"
                  "Alpha-page-numbers"
                  "see"
                  "seealso"))

;; =======================
;; merge rules
;; =======================

;; LaTeX and TeX conventions

(merge-rule "\\LaTeXe *" "LaTeX2e" :eregexp :again)
(merge-rule "\\BibTeX *" "BibTeX" :eregexp :again)
(merge-rule "\\AmSTeX *" "AmSTeX" :eregexp :again)
(merge-rule "\\AmSLaTeX *" "AmSLaTeX" :eregexp :again)
(merge-rule "\\XeT *" "XeT" :eregexp :again)

(require "base/tex.xdy")

(markup-locref :open "\textbf{" :close "}" :attr "textbf")
(markup-locref :open "\textit{" :close "}" :attr "textit")
(markup-locref :open "\hyperpage{" :close "}" :attr "hyperpage")

;; ======================
;; markup rules
;; ======================

(require "base/page-ranges.xdy")

(markup-index :open
"\begin{theindex}
  \providecommand*\lettergroupDefault[1]{}
  \providecommand*\lettergroup[1]{%
      \par\textbf{#1}\par
      \nopagebreak
  }
"
          :close "~n~n\end{theindex}~n"
          :tree)

(markup-indexentry :open "~n  \item "           :depth 0)
(markup-indexentry :open "~n    \subitem "      :depth 1)
(markup-indexentry :open "~n      \subsubitem " :depth 2)

(markup-locclass-list :open ", " :sep ", ")
(markup-locref-list   :sep ", ")

;; letter group markup

(markup-letter-group-list :sep "~n~n  \indexspace~n")

(markup-letter-group :open-head "~n  \lettergroupDefault{" :close-head "}" :group "default")
(markup-letter-group :open-head "~n  \lettergroup{" :close-head "}")

You must log in to answer this question.

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