Xindy 无法正确排序关键词

Xindy 无法正确排序关键词

我正在准备一个索引,其中的条目使用国际音标字母(主要由小写拉丁字母组成,但有一些附加内容。我已在.xdy。当 xindy 准备索引时,分组将按我指定的顺序显示。例如,“ʌ”条目出现在“a”条目之前。但在对键进行排序时,将出现默认排序顺序:出现 aʌaa 而不是。(我复制了下面代码中出现的排序顺序。)我需要指定一些进一步的排序规则吗?

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(基于这个答案):

;; 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

事实证明,更改关键字排序顺序需要定义一种新语言。在文件中定义新的字母组是不够的.xdy。(但是,一旦您定义了新语言,您就可以免费获得字母分组,所以这是一件好事。)

我遵循了这个答案,用于越南语。不过,我将在这里包含我的代码,因为它可能比越南语变音符号更容易理解,并且添加步骤utf8-lang.xdy是新的。从答案中xindy-make-rules-0.2已下载和提取的点开始...

xindy-make-rules-0.2/alphabets目录中,我创建了一个名为 的新文件夹ipa,并创建了utf8.pl.in以下内容:

#!/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';

(这超出了我上面的 MWE 的范围,但我认为是可以理解的。)

我进行了编辑xindy-make-rules-0.2/alphabets/Makefile,以便INSTDIR(第 7 行)反映我的安装位置xindy(就我而言"D:\Program Files (x86)\MiKTeX 2.9\xindy\modules\lang")。

然后在xindy-make-rules-0.2/alphabets目录中执行了以下命令:

make utf8
make install

注意:尽管这在当时有效,但是当我最近尝试相同的命令时,它不会构建我的文件,直到我将其包含在列表下myalphabet/utf8.xdy \(我的副本的第 66 行)。XDYSUTF8xindy-make-rules-0.2/alphabets/Makefile

(由于我是 Windows 用户,因此我使用 执行这些命令msys。使用mingw32-make对我来说不起作用。)

无论出于什么原因,脚本都不会创建我认为至关重要的文件。因此,xindy/modules/lang/ipa我必须在目录中创建文件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"))

请注意,此文件需要ipa.xdy,即上面的问题中提供的文件。

ipa所以总结一下,现在xindy 文件夹中应该有一个名为的子文件夹modules/lang(在我的情况下为"D:\Program Files (x86)\MiKTeX 2.9\xindy\modules\lang"),并且该文件夹应该包含三个文件:utf8.pl.inutf8.xdyutf8-lang.xdy

完成后,我可以进行xindy如下调用:

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

ipa.xdy是我上面的 MWE 的精简版。该文件现在实际上只提供基本选项和标记命令。没有针对 IPA 字母表的任何特定内容。

;; 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 "}")

相关内容