原问题的解决方案在这里得到解决:索引中的缩略词按字母顺序排列
,每次我尝试在索引中包含首字母缩略词时执行命令\gls{acronym}
。提供的代码运行良好,但是,我注意到首字母缩略词仅显示在索引中使用两次时或更多(MWE 和下面的输出)。我有一长串的首字母缩略词,在整个文本中只提到过一次,我需要将它们全部显示在索引中。有什么想法吗?
\documentclass[11pt]{article}
\usepackage{makeidx}
\makeindex
\usepackage[acronym,toc,shortcuts]{glossaries}
\makeglossaries
\renewcommand*{\CustomAcronymFields}{%
name={\the\glsshorttok},%
symbol={\the\glsshorttok},%
text={\the\glsshorttok\protect\index{\the\glslongtok\space(\the\glsshorttok)}},%
plural={\the\glsshorttok\noexpand\acrpluralsuffix\protect\index{\the\glslongtok\space(\the\glsshorttok)}},%
first={\the\glslongtok\space(\the\glsshorttok)},%
firstplural={\the\glslongtok\noexpand\acrpluralsuffix\space(\the\glsshorttok)},%
description={\the\glslongtok}%
}
\SetCustomStyle
\newacronym{cd}{CD}{compact disk}
\newacronym{cho}{CHO}{chinese hamster ovary}
\newacronym{bhk}{BHK}{baby hamster kidney}
\newacronym{hek}{HEK}{human embryonic kidney}
\newacronym{hgh}{HGH}{human growth hormone}
\newacronym{scfv}{scFv}{small chain variable fragment}
\newacronym{pi}{pI}{isoelectric point}
\begin{document}
\noindent
First\index{first} use of \gls{cd}\\
subsequent\index{subsequent} use of \gls{cd}
, and
\gls{cho} and
\gls{bhk} and
\gls{hek} and
\gls{hgh} and again \gls{hgh} %used twice and displayed, likewise \gls{cd}
\gls{scfv} and
\gls{pi}.
\printglossaries
\printindex
\end{document}
答案1
抱歉,我忘了添加\index
和first
键firstplural
,这就是为什么第一次使用的术语没有被索引。以下是更正后的 MWE:
\documentclass[11pt]{article}
\usepackage{makeidx}
\makeindex
\usepackage[acronym,toc,shortcuts]{glossaries}
\makeglossaries
\renewcommand*{\CustomAcronymFields}{%
name={\the\glsshorttok},%
symbol={\the\glsshorttok},%
text={\the\glsshorttok\protect\index{\the\glslongtok\space(\the\glsshorttok)}},%
plural={\the\glsshorttok\noexpand\acrpluralsuffix\protect\index{\the\glslongtok\space(\the\glsshorttok)}},%
first={\the\glslongtok\space(\the\glsshorttok)\protect\index{\the\glslongtok\space(\the\glsshorttok)}},%
firstplural={\the\glslongtok\noexpand\acrpluralsuffix\space(\the\glsshorttok)\protect\index{\the\glslongtok\space(\the\glsshorttok)}},%
description={\the\glslongtok}%
}
\SetCustomStyle
\newacronym{cd}{CD}{compact disk}
\newacronym{cho}{CHO}{chinese hamster ovary}
\newacronym{bhk}{BHK}{baby hamster kidney}
\newacronym{hek}{HEK}{human embryonic kidney}
\newacronym{hgh}{HGH}{human growth hormone}
\newacronym{scfv}{scFv}{small chain variable fragment}
\newacronym{pi}{pI}{isoelectric point}
\begin{document}
\noindent
First\index{first} use of \gls{cd}\\
subsequent\index{subsequent} use of \gls{cd}
, and
\gls{cho} and
\gls{bhk} and
\gls{hek} and
\gls{hgh} and again \gls{hgh}
\gls{scfv} and
\gls{pi}.
\printglossaries
\printindex
\end{document}
该索引现在是: