5 为什么索引排版时候,分类字母不显示? 6天11时10分18秒

发布于 2026-07-18 16:19:12

排版索引的时候,索引项能够正常显示,但是分类字母不显示,什么原因?
以下是源代码

\documentclass[a4paper,twoside,titlepage]{ctexbook}  %文档类

% ==================== 索引排版 ====================
\usepackage[xindy]{imakeidx}

%--------------------名称汉化--------------------
\renewcommand*{\see}[2]{{\kaishu 参见}#1}
\renewcommand*{\seealso}[2]{{\kaishu 又见}#1}
%--------------------制作名称索引--------------------
\makeindex[%
name=nouns, % 索引文件名(默认为 \jobname,即主文件名)
title={名词索引}, % 索引表标题(默认为 \indexname)
intoc=true, % 加入目录(默认为 false,不加入目录)
columns=2, % 分栏(默认为 1)
columnsep=1cm, % 栏间距(默认为 35pt)
columnseprule=true, % 分栏线(默认为 false)
program=makeindex, % 调用的索引程序(或用 xindy、texindy)
options={-s mkind.ist}, % 索引程序的选项(默认为空)
noautomatic=false % 不自动调用索引程序(默认为 false)
]
%--------------------制作人名索引--------------------
\makeindex[%
name=persons, % 索引文件名(默认为 \jobname,即主文件名)
title={人名索引}, % 索引表标题(默认为 \indexname)
intoc=true, % 加入目录(默认为 false,不加入目录)
columns=2, % 分栏(默认为 1)
columnsep=1cm, % 栏间距(默认为 35pt)
columnseprule=true, % 分栏线(默认为 false)
program=makeindex, % 调用的索引程序(或用 xindy、texindy)
options={-s mkind.ist}, % 索引程序的选项(默认为空)
noautomatic=false % 不自动调用索引程序(默认为 false)
]

\begin{document}
    
    \tableofcontents
    \index[nouns]{自然}
    
    \index[persons]{赵一鸣}
    
    \index[nouns]{天空}
    
    \index[persons]{钱文博}
    
    \index[nouns]{海洋}
    
    \index[persons]{孙志远}
    
    \index[nouns]{大地}
    
    \index[persons]{李明轩}
    
    \index[nouns]{风霜}
    
    \index[persons]{周子涵}
    
    \index[nouns]{雨雪}
    
    \index[persons]{吴俊杰}
    
    \index[nouns]{雷电}
    
    \index[persons]{郑凯瑞}
    
    \index[nouns]{云雾}
    
    
    
    \printindex[nouns] % 输出名词索引
    \printindex[persons] % 输出人名索引
    
\end{document}

以下是索引格式文件mkind.ist的代码

headings_flag     1
heading_prefix    "  \n  \\centerline{\\large\\bfseries "
heading_suffix    "}\n  \\indexspace\n"
preamble          "\\begin{theindex}\n  \\parindent=0pt\n  \\def\\seename{参见}\n  \\def\\seealsoname{又见}"
numhead_positive  "数字"
numhead_negative  "数字"
symhead_positive  "符号"
symhead_negative  "符号"

跑出来的效果

1.png

查看更多

关注者
0
被浏览
36
1 个回答
雾月
雾月 8小时前
这家伙很懒,什么也没写!

实际上并不是不显示字母,而是 makeindex 程序并不能(正确)识别中文字符所属的类别。如果索引前面是英文或者设置了用于排序的文字

    \index[persons]{zym@赵一鸣}
    
    \index[persons]{qwb@钱文博}

就能观察到正确的分组。
lshort-zh-cn 就是这么做的。

makeindex 不能识别中文,但刘海洋编写的 zhmakeindex 可以!它支持按汉字拼音、笔画等分组,它几乎完全兼容 makeindex。TeXLive 不自带,但可以在 CTAN 上下载 https://mirrors.ctan.org/indexing/zhmakeindex.zip 。解压后将它 bin 下的可执行文件(Windows 平台就是 bin\windows_x64\zhmakeindex.exe)复制到 TeXLive 安装路径里(例如 D:\texlive\2026\bin\windows\,保证 zhmakeindex.exemakeindex.exe 在同一个文件夹就行。

然后再 patch 一下 imakeidx 就行(需要使用 --shell-escape 编译,或者修改 texmf.cnf 文件)

\documentclass[a4paper,twoside,titlepage]{ctexbook}  %文档类

% ==================== 索引排版 ====================
\usepackage[xindy]{imakeidx}
\makeatletter
% 直接改 imakeidx.sty 原文件也行
\define@choicekey{imki}{program}[\imki@val\imki@nr]
  {makeindex,xindy,texindy,truexindy,zhmakeindex}{%
    \ifcase\imki@nr\relax
      \def\imki@program{makeindex}%
    \or
      \def\imki@program{texindy}%
    \or
      \def\imki@program{texindy}%
    \or
      \def\imki@program{xindy}%
    \or
      \def\imki@program{zhmakeindex}%
    \fi}
\makeatother

%--------------------名称汉化--------------------
\renewcommand*{\see}[2]{{\kaishu 参见}#1}
\renewcommand*{\seealso}[2]{{\kaishu 又见}#1}
%--------------------制作名称索引--------------------
\makeindex[%
name=nouns, % 索引文件名(默认为 \jobname,即主文件名)
title={名词索引}, % 索引表标题(默认为 \indexname)
intoc=true, % 加入目录(默认为 false,不加入目录)
columns=2, % 分栏(默认为 1)
columnsep=1cm, % 栏间距(默认为 35pt)
columnseprule=true, % 分栏线(默认为 false)
program=zhmakeindex, % 调用的索引程序(或用 xindy、texindy)
options={-s mkind.ist}, % 索引程序的选项(默认为空)
noautomatic=false % 不自动调用索引程序(默认为 false)
]
%--------------------制作人名索引--------------------
\makeindex[%
name=persons, % 索引文件名(默认为 \jobname,即主文件名)
title={人名索引}, % 索引表标题(默认为 \indexname)
intoc=true, % 加入目录(默认为 false,不加入目录)
columns=2, % 分栏(默认为 1)
columnsep=1cm, % 栏间距(默认为 35pt)
columnseprule=true, % 分栏线(默认为 false)
program=zhmakeindex, % 调用的索引程序(或用 xindy、texindy)
options={-s mkind.ist}, % 索引程序的选项(默认为空)
noautomatic=false % 不自动调用索引程序(默认为 false)
]

\begin{document}
    
    \tableofcontents
    \index[nouns]{自然}
    
    \index[persons]{赵一鸣}
    
    \index[nouns]{天空}
    
    \index[persons]{钱文博}
    
    \index[nouns]{海洋}
    
    \index[persons]{孙志远}
    
    \index[nouns]{大地}
    
    \index[persons]{李明轩}
    
    \index[nouns]{风霜}
    
    \index[persons]{周子涵}
    
    \index[nouns]{雨雪}
    
    \index[persons]{吴俊杰}
    
    \index[nouns]{雷电}
    
    \index[persons]{郑凯瑞}
    
    \index[nouns]{云雾}
    
    
    
    \printindex[nouns] % 输出名词索引
    \printindex[persons] % 输出人名索引
    
\end{document}

image.png

撰写答案 当前问题悬赏金额为¥5 元,被提问者采纳后将获得赏金

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览