使用 glsaddall 时出现编译错误

使用 glsaddall 时出现编译错误

当我编译下面的示例时出现错误:

! undefined control sequence
<write> (indexentry :tkey (\glo@computer@index) : locref "{}{\gls@numberpage}"...

平均能量损失

\documentclass[a4paper,12pt,dvipsnames]{report}
\usepackage[style=long,toc,xindy,acronym, sort=use]{glossaries}
\makeglossaries

\newglossaryentry{computer}{
    name=computer,
    description={is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format}}
\begin{document}
 \glsaddall
 \printglossaries
\end{document}

如果我添加gls{computer}示例,编译时不会出现错误。我该如何解决这个问题?

答案1

这有效。您需要使用词汇表中定义的条目。否则无法对它们进行排序!

\documentclass[a4paper,12pt]{report}
\usepackage[style=long,toc,acronym,xindy,sort=use]{glossaries}
\makeglossaries

\newglossaryentry{computer}{
    name=computer,
    description={is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format}}
\newglossaryentry{comp}{
    name=comp,
    description={is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format}}


\begin{document}

\noindent
\gls{computer}\\
\gls{comp}

\printglossaries
\end{document}

如果不想使用\gls{}而使用\glsaddall{},请sort=use从包选项中删除。

相关内容