我正在使用词汇表包,我想以如下方式打印首字母缩略词:
- 首字母缩略词列表:首字母缩略词的每个单词的首字母均大写
- 连续文本:首字母缩略词的每个单词的首字母均应小写
提出的解决方案这里效果很好,但我有一个带连字符的首字母缩略词,它被识别为一个单词(“Air-conditioning”)。我该如何修改代码,使首字母缩略词列表中的输出为“Air-Conditioning”而不是“Air-conditioning”?
我目前的代码是:
\documentclass[a4paper,oneside,11pt]{report}
\usepackage[nopostdot,nogroupskip,nonumberlist,acronym]{glossaries}
\newacronym{hvac}{HVAC}{heating, ventilation and air-conditioning}
\makeatletter
\newglossarystyle{long-initcapsdesc}{%
\setglossarystyle{long}%
\renewcommand{\glsnamefont}[1]{\MakeUppercase{##1}}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\protected@edef\thisdesc{\glsentrydesc{##1}}%
\xcapitalisewords{\thisdesc}\glspostdescription\space ##2\tabularnewline
}%
}
\makeatother
\makeglossaries
\begin{document}
\printglossary[type=acronym,style=long-initcapsdesc,title={List Of Acronyms}]
\vspace{100pt}
\noindent
text text text \gls{hvac} text text text
\end{document}
答案1
如果你有至少 2.03 版本的mfirstuc
您可以使用 启用连字符拆分\MFUhyphentrue
。
\documentclass[a4paper,oneside,11pt]{report}
\usepackage[nopostdot,nogroupskip,nonumberlist,acronym]{glossaries}
\MFUhyphentrue
\newacronym{hvac}{HVAC}{heating, ventilation and air-conditioning}
\makeatletter
\newglossarystyle{long-initcapsdesc}{%
\setglossarystyle{long}%
\renewcommand{\glsnamefont}[1]{\MakeUppercase{##1}}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\protected@edef\thisdesc{\glsentrydesc{##1}}%
\xcapitalisewords{\thisdesc}\glspostdescription\space ##2\tabularnewline
}%
}
\makeatother
\makeglossaries
\begin{document}
\printglossary[type=acronym,style=long-initcapsdesc,title={List Of Acronyms}]
\vspace{100pt}
\noindent
text text text \gls{hvac} text text text
\end{document}
现在有一种更简单的方法可以应用于\capitalisewords
字段:
\newglossarystyle{long-initcapsdesc}{%
\setglossarystyle{long}%
\renewcommand{\glsnamefont}[1]{\MakeUppercase{##1}}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glsentrytitlecase{##1}{desc}\glspostdescription\space ##2\tabularnewline
}%
}