![词汇表-额外丢弃期限和缩写长格式](https://linux22.com/image/451106/%E8%AF%8D%E6%B1%87%E8%A1%A8-%E9%A2%9D%E5%A4%96%E4%B8%A2%E5%BC%83%E6%9C%9F%E9%99%90%E5%92%8C%E7%BC%A9%E5%86%99%E9%95%BF%E6%A0%BC%E5%BC%8F.png)
当使用以下期限discardperiod
的功能时glossaries-extra
,如果使用明确的长格式,则会被不适当地丢弃:
\documentclass{article}
\usepackage[
abbreviations,
shortcuts=abbr,
]{glossaries-extra}
\glssetcategoryattribute{abbreviation}{discardperiod}{true}
\glssetcategoryattribute{abbreviation}{retainfirstuseperiod}{true}
\newabbreviation{dr}{Dr.}{Doctor}
\begin{document}
% This is OK.
\ab{dr}. \ab{dr}.
% This is still OK.
\as{dr}.
% This period gets unduly discarded.
\al{dr}.
\end{document}
有人碰巧知道正确处理此案的方法吗?
答案1
我想我可以想出一些合理的办法,即使这个办法比我希望的要棘手。
\documentclass{article}
\usepackage[
abbreviations,
shortcuts=abbr,
]{glossaries-extra}
\glssetcategoryattribute{abbreviation}{discardperiod}{true}
\glssetcategoryattribute{abbreviation}{retainfirstuseperiod}{true}
\newtoggle{glsenddot}
\NewDocumentCommand{\glsdot}{}{\global\toggletrue{glsenddot}.\@}
\makeatletter
\renewcommand*{\glsxtrifperiod}[1]{%
\iftoggle{glsenddot}
{%
\global\togglefalse{glsenddot}%
\new@ifnextchar.{\@firstoftwo{#1}}%
}
{\@secondoftwo{#1}}%
}
\makeatother
\preto\glsxtrpostlink{\global\togglefalse{glsenddot}}
\newabbreviation{dr}{Dr\glsdot}{Doctor}
\newabbreviation{abc}{ABC}{Aaaa Bbbb Cccc}
\begin{document}
% This is OK.
\ab{dr}. \ab{abc}. \ab{abc}. \ab{dr}.
% This is still OK.
\as{dr}.
% This period is now in place.
\al{dr}.
\ab{abc}.
\end{document}