我正在準備一個索引,其中包含使用國際音標的條目(主要由小寫拉丁字母組成,但有附加內容).xdy
。指定的順序顯示例如,「ʌ」條目出現在「a」條目之前,但是在對鍵進行排序時,會出現預設排序順序:aʌ 出現。後代替前。 (我複製了下面程式碼中出現的排序順序。)我需要指定一些進一步的排序規則嗎?
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
注意:雖然這在當時有效,但當我最近嘗試相同的命令時,它不會建立我的文件,直到我將其包含在(副本的第 66 行)列表中myalphabet/utf8.xdy \
。XDYSUTF8
xindy-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
xindymodules/lang
資料夾中應該有一個名為 的子資料夾(在我的例子中"D:\Program Files (x86)\MiKTeX 2.9\xindy\modules\lang"
),而該資料夾應包含三個資料:utf8.pl.in
、utf8.xdy
和utf8-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 "}")