使用词汇表包,我想用小写字母定义文本中的首字母缩略词,如下所示:
示例首字母缩略词 (SA)
自由度 (DOF)
而重复将显示为:
SA
DOF
但是,在首字母缩略词列表中,我希望它以大写字母显示,例如:
SA - 样本首字母缩略词
DOF - 自由度
使用以下代码,我无法得到正确的结果:
\documentclass{article}
\usepackage[acronym]{glossaries}
\makeglossaries
\newglossaryentry{sample}{name=sample,description=a sample entry}
\newacronym{sa}{SA}{Sample Acronym}
\newacronym{dof}{DOF}{Degrees of Freedom}
\begin{document}
This is a \gls{sample}. And this is a \gls{sa}, while another one will be \gls{dof}.
Recurrences are \gls{sa} and \gls{dof}.
\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
\printglossary
\printglossary[type=acronym,style = super]
\end{document}
答案1
使用glossaries-extra
,您只需设置glossdesc
属性即可。
\documentclass{article}
\usepackage[abbreviations]{glossaries-extra}
\glssetcategoryattribute{general}{glossdesc}{firstuc}
\glssetcategoryattribute{abbreviation}{glossdesc}{title}
\makeglossaries
\newglossaryentry{sample}{name=sample,description=a sample entry}
\newabbreviation{sa}{SA}{sample acronym}
\newabbreviation{dof}{DOF}{degrees {}of freedom}
\begin{document}
This is a \gls{sample}. And this is a \gls{sa}, while another one will be \gls{dof}.
Recurrences are \gls{sa} and \gls{dof}.
\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
\printglossary
\printglossary[type=abbreviations, style=super]
\end{document}