自动在词汇表中自定义条目名称

自动在词汇表中自定义条目名称

我一直在尝试使用词汇表包,但是我遇到了很多问题,因为我可能犯了一些错误,因为我总是手动编辑.gls 文件。

\newglossaryentry{cars}{name=cars, description={Something you can drive}}
\newglossaryentry{apples}{name=apples, description={Something you can eat}}
\makeglossaries

有参考文献

\gls{cars} .... \gls{apples}

这样做会使我的文本保持正确,但会在词汇表中添加单词的复数形式,而尝试在第一个括号或名称值中输入单数版本将解决词汇表中的问题,但在文本中输入单数形式。当然,我已经通过手动编辑 .gls 文件解决了这个问题,但这似乎不是正确的方法,我是否遗漏了什么?(我正在使用 xindy 和 toc,我不知道这算不算)

答案1

您应该将单数词放入词汇表中。如果您需要在文本中使用复数,则使用\glspl而不是\gls

示例输出

\documentclass{article}

\usepackage{glossaries}
\newglossaryentry{car}{name=car, description={Something you can drive}}
\newglossaryentry{apple}{name=apple, description={Something you can eat}}
\makeglossaries

\begin{document}

One \gls{car} and many \glspl{car}.

\printglossaries

\end{document}

相关内容