mhchem
我在詞彙表中使用時遇到以下問題。我不想在開始一個句子時擔心我是否已經使用了首字母縮略詞,但我發現這\Gls
似乎不適用於mhchem
in 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
事情就會出錯。