0

I want to set the first occurrance of a glossary entry in italics. From this answer to a related question, I got the following MWE:

\documentclass{article}

\usepackage{glossaries}
\makeglossaries

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

\newglossaryentry{term}{name={technical term}, description=\nopostdesc}

\begin{document}
First occurrance of \gls{term}, second occurrance of \gls{term}.

\end{document}

However, it has two problems. First, \defglsdisplayfirst is apparently deprecated, and second, I get unwanted horizontal space when using it:

enter image description here

I have seen similar questions on how to solve this without using \defglsdisplayfirst, but they all concern acronyms. I use both acronyms and other entries which are not acronyms, and I want this to apply to all kinds of glossary entries.

As part of the deprecation warning, it says that I should use \defglsentryfmt instead, but I can't figure out how to use it.

1

After looking more closely into the manual and how \glsentryfmt is originally defined, I managed to figure it out. =)

This gives me what I want:

\documentclass{article}

\usepackage{glossaries}
\makeglossaries

\defglsentryfmt{%
  \ifglsused{\glslabel}{%
    \glsgenentryfmt%
  }{%
    % Typeset first use
    \textit{\glsgenentryfmt}%
  }%
}

\newglossaryentry{term}{name={technical term}, description=\nopostdesc}

\begin{document}
First occurrance of \gls{term}, second occurrance of \gls{term}.

\end{document}
| improve this answer | |

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.