可以ltxdoc.cls
与makeidx
和 一起使用吗bookmark
?
MNWE:
\documentclass{ltxdoc}
\usepackage{makeidx}
\usepackage{bookmark}
\makeindex
\begin{document}
\DescribeMacro{\mymacro}\marg{argument}\par
\printindex
\end{document}
根据评论中的建议,我尝试了
makeindex -s gind.ist prawf
以下是makeindex
的文字记录:
This is makeindex, version 2.17 [TeX Live 2023] (kpathsea + Thai
support).
Scanning style file /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist.............done (13 attributes redefined, 3 ignored).
Scanning input file prawf.idx...done (0 entries accepted, 1 rejected).
Nothing written in prawf.ind.
Transcript written in prawf.ilg.
日志:
This is makeindex, version 2.17 [TeX Live 2023] (kpathsea + Thai support).
Scanning style file /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist..........
** Input style error (file = /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist, line = 75):
-- Unknown specifier lethead_prefix.
** Input style error (file = /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist, line = 76):
-- Unknown specifier lethead_suffix.
** Input style error (file = /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist, line = 77):
-- Unknown specifier lethead_flag.
...done (13 attributes redefined, 3 ignored).
Scanning input file prawf.idx...
!! Input index error (file = prawf.idx, line = 1):
-- Extra `|' at position 46 of first argument.
done (0 entries accepted, 1 rejected).
Nothing written in prawf.ind.
Transcript written in prawf.ilg.
原始索引文件是
\indexentry{mymacro=\verb!*+\mymacro+|hdclindex{2}{usage}|hyperpage}{1}
答案1
您会在日志中收到一条警告:
Package hypdoc Warning: hyperref has been loaded before. Check the options!
hypdoc
在前导码末尾加载hyperref
,并选择hyperindex=false
避免其干扰,但由于您已经hyperref
通过bookmark
包加载,因此它不再起作用。
遗憾的是,理清 30 年的历史并避免这个加载顺序问题并非易事:目前无法hyperindex
在打包后重置。
目前对您来说最简单的方法是hypdoc
在 hyperref 之前提前加载:
\documentclass{ltxdoc}
\usepackage{makeidx}
\usepackage{hypdoc}
\usepackage{bookmark}
\makeindex
\begin{document}
\DescribeMacro{\mymacro}\marg{argument}\par
\printindex
\end{document}
此外,正如评论中提到的,您必须使用特殊样式调用 makeindex,例如,-s gind
然后您会得到这个