0

When using the discardperiod functionality from glossaries-extra the following period gets unduly discarded when an explicitly long form is used:

\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}

enter image description here

Anyone happens to know a way to get this case correctly?

1 Answer 1

0

I think I could come up with something reasonable, even if this one was trickier than I hoped for.

\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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .