6

I have a problem with using the glossary package. I use sharelatex.

When I use a glossary term (first and others), there appears an unwanted space in the output document.

This is the code I use:

Main

\usepackage[acronym, translate=babel, nopostdot]{glossaries}
\makeglossaries

% External files
\loadglsentries{Z_glossary}
\loadglsentries{Z_afkortingen}

% Not in table of contents
\glstocfalse

% First appearance in italic
\defglsdisplayfirst[\glsdefaulttype]{\textit{#1}}

The Glossary

\newglossaryentry{workflowpattern}%
{%
    name={Workflowpattern}, 
    description={Blablabla}, 
    text={workflowpattern}, 
    plural={workflowpatterns}, 
    first={workflowpattern},            
    firstplural={workflowpatterns},
}

The text

zijn de \glspl{workflowpattern} en beschrijven

And the result:

The output

  • 1
    On behalf of @Gary Wang, "The bug mentioned by **Heiko Oberdiek** has been fixed in the newest version of glossaries (4.42) where the needless space has been removed. So there should be no extra space." – Raaja Mar 13 at 11:07
3

The unwanted space comes from \defglsdisplayfirst of glossaries.sty 2014/01/20 v4.03, see the line marked with % <==:

\newcommand*{\defglsdisplayfirst}[2][\glsdefaulttype]{%
  \GlossariesWarning{\string\defglsdisplayfirst\space is now obsolete.^^J
  Use \string\defglsentryfmt\space instead}%
  \expandafter\def\csname gls@#1@displayfirst\endcsname##1##2##3##4{#2}%
  \edef\@gls@doentrydef{%
    \noexpand\defglsentryfmt[#1]{%
      \noexpand\ifcsdef{gls@#1@display}%
      {%
        \noexpand\@@gls@default@entryfmt
          {\noexpand\csuse{gls@#1@displayfirst}}
          {\noexpand\csuse{gls@#1@display}}%
      }%
      {%
        \noexpand\@@gls@default@entryfmt
          {\noexpand\csuse{gls@#1@displayfirst}}%
          {\noexpand\glsdisplay} % <==
      }%
    }%  
  }%
  \@gls@doentrydef
}

As workaround, the definition without the unwanted space:

\usepackage[...]{glossaries}
\makeatletter
\renewcommand*{\defglsdisplayfirst}[2][\glsdefaulttype]{%
  \GlossariesWarning{\string\defglsdisplayfirst\space is now obsolete.^^J
  Use \string\defglsentryfmt\space instead}%
  \expandafter\def\csname gls@#1@displayfirst\endcsname##1##2##3##4{#2}%
  \edef\@gls@doentrydef{%
    \noexpand\defglsentryfmt[#1]{%
      \noexpand\ifcsdef{gls@#1@display}%
      {%
        \noexpand\@@gls@default@entryfmt
          {\noexpand\csuse{gls@#1@displayfirst}}
          {\noexpand\csuse{gls@#1@display}}%
      }%
      {%
        \noexpand\@@gls@default@entryfmt
          {\noexpand\csuse{gls@#1@displayfirst}}%
          {\noexpand\glsdisplay}% without unwanted space
      }%
    }%  
  }%
  \@gls@doentrydef
}
\makeatother
  • Thank you. I had to place it before \defglsdisplayfirst[\glsdefaulttype]{\textit{#1}} – TomH Mar 3 '14 at 9:34
1

use

\defglsdisplayfirst[\glsdefaulttype]{\textit{#1}\ignorespaces}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.