我在使用词汇表时遇到了以下问题mhchem
。我希望在开始写句子时不必担心我是否已经使用过首字母缩略词,但我发现这似乎对\Gls
不太适用。我可以通过尝试跟踪我是否已经使用过首字母缩略词来解决这个问题,但我希望能够编辑我的定义以使其正常工作。任何建议都将不胜感激!mhchem
glossaries
\newacronym
\documentclass{article}
\usepackage[acronym]{glossaries} % Load the package
\makeglossaries % Prepare the glossary
\usepackage[version=3]{mhchem}
\newacronym{CO2}{\ce{CO2}}{carbon dioxide}
\newacronym{CH4}{CH$_4$}{methane}
\newacronym{H2SO4}{\NoCaseChange{\ce{H2SO4}}}{sulfuric acid}
\begin{document}
%I'd like the following to work, but it doesn't...
\Gls{CO2} in the environment \ldots
\Gls{CO2} now generates an error
\Gls{CH4} in the environment \ldots
\Gls{CH4} works fine.
%\gls works fine
Calculation of the corresponding \gls{CO2} emissions to cover the surplus in electricity demand.
%I also tried
\Gls{H2SO4} is an acid. We use \gls{H2SO4} everyday.
\Gls{H2SO4} generates an error \ldots
\gls{H2SO4} is okay.
\printglossary[type=acronym,title={List of Abbreviations}]
%\printglossaries
\end{document}
答案1
为底层大写宏 ( \makefirstuc
) 提供一个空组作为其工作的第一个“标记”即可:
\newacronym{CO2}{{}\ce{CO2}}{carbon dioxide}
如果没有它\ce
,\makefirstuc
事情就会出错。