我们使用latexmk
可以非常方便的实现中文索引排序,只需将引擎更换为zhmakeindex
, 下载zhmakeindex之后将对应系统的zhmakeindex
(例如bin/darwin_x64/zhmakeindex)放在
makeindex同目录下(例如
usr ▸ local ▸ texlive ▸ 2019 ▸ bin ▸ x86_64-darwin)。然后在
tex源文件同目录下建立如下的
.latexmkrc`
$pdf_previewer = 'open -a Skim';
$xelatex = 'xelatex -synctex=1 -interaction=nonstopmode -shell-escape';
@generated_exts = (@generated_exts, 'synctex.gz');
$pdf_mode = 1;
@cus_dep_list=(@cus_dep_list, "glo gls 0 makenomenclature");
sub makenomenclature {
system("zhmakeindex -s zh.ist -t '$_[0]'.glg -o '$_[0]'.gls '$_[0]'.glo");
}
@generated_exts = (@generated_exts, 'glo gls glg acn acr alg');
$makeindex = 'zhmakeindex -z pinyin -s zh.ist';
$clean_ext = "bbl nav out snm idx ind glg glo gls slg slo sls"
则可测试如下:
\documentclass{ctexart}
\usepackage[linkcolor=cyan,colorlinks]{hyperref}
\usepackage[automake, symbols, toc]{glossaries-extra} %, order=letter
\usepackage[noautomatic]{imakeidx}
\makeindex[intoc,columns=3,columnseprule=true,columnsep=5pt]
\newcommand{\iemph}[1]{\uwave{#1}\index{#1|hyperpage}}
\renewcommand*{\glssymbolsgroupname}{符号列表}
\makeglossaries
\glsnoexpandfields
\glsxtrnewsymbol[description={共线三点$A$、$B$、$C$的简比}]{rc}{\ensuremath{(ABC)}}
\glsxtrnewsymbol[description={共线三点$A$、$B$、$D$的简比}]{rb}{\ensuremath{(ABD)}}
\glsxtrnewsymbol[description={三共线点$A$、$B$、$C$的简比}]{rd}{\ensuremath{(ABC)}}
\title{中文索引处理}
\author{}
\date{}
\begin{document}
\printglossaries
\maketitle
测试\iemph{三点形}\\
测试\iemph{二次曲线}\\
\gls{rd}\\
\gls{rb}
\newpage
\iemph{向量}\\
\iemph{共线}\\
\iemph{简比}\gls{rc}\\
\printindex
\end{document}
使用latexmk -pvc -xelatex
效果如图
如果不使用.latexmkrc
, 可以通过重新定义默认imakeidx的程序得到如下解决方案, 该答案参考tex.so
\usepackage{imakeidx}
\makeatletter
\def\imki@progdefault{zhmakeindex}
\makeatother
\makeindex[intoc,columns=2,columnseprule=true,columnsep=5pt,options={-s zh.ist}]
最后,附上zh.ist
preamble "\\begin{theindex}
\\def\\seename{见}
\\def\\alsoname{又见}
\\providecommand*\\indexgroup[1]{%
\\indexspace
\\item \\textbf{#1}\\nopagebreak}\n"
postamble "\n\n\\end{theindex}\n"
group_skip "\n\n \\indexspace\n\n"
headings_flag 1
heading_prefix " %\n \\indexgroup{"
heading_suffix "} \n %\n"
numhead_positive "数字"
numhead_negative "数字"
symhead_positive "符号"
symhead_negative "符号"
delim_0 " \\dotfill\\ "
delim_1 " \\dotfill\\ "
delim_2 " \\dotfill\\ "
网友评论