6

I'm searching a way to emphasize the first occurrence of a glossary term in every section

\usepackage{glossaries}
\makeglossaries
\newglossaryentry{webapp}{
    name=webapp,
    first={\underline{webapp}},
    description={description of the webapp}
}

If i use this in this way

\section{first}
\gls{webapp} \gls{webapp} \gls{webapp} \gls{webapp}

\section{second}
\gls{webapp} \gls{webapp} \gls{webapp} \gls{webapp}

Only the fist occurrence on the first section will be underlined, the other occurrence will not.

Is there a solution to make also the first occurrence of "webapp" on the second section be underlined?

1
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Jan 11, 2014 at 10:19

1 Answer 1

7

Yes, it is possible, you can just issue the command \glsreset{webapp} to reset the behavior when needed. If you want to reset the behavior for all glossary entries use \glsresetall.

MWE

\documentclass{article}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{webapp}{
    name=webapp,
    first={\underline{webapp}},
    description={description of the webapp}
}

\begin{document}

\section{frist}
\gls{webapp} \gls{webapp} \gls{webapp} \gls{webapp}

\section{second}
\glsreset{webapp}
\gls{webapp} \gls{webapp} \gls{webapp} \gls{webapp}

\printglossaries

\end{document} 

Output:

enter image description here

If you don't want to insert that line manually each time you issue a \section, you can insert the following line in the preamble

\pretocmd{\section}{\glsresetall}{}{}

It requires etoolbox which is automatically loaded by glossaries.

For example, the following MWE produces the same result as the above one:

\documentclass{article}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{webapp}{
    name=webapp,
    first={\underline{webapp}},
    description={description of the webapp}
}

\pretocmd{\section}{\glsresetall}{}{}

\begin{document}

\section{first}
\gls{webapp} \gls{webapp} \gls{webapp} \gls{webapp}

\section{second}
\gls{webapp} \gls{webapp} \gls{webapp} \gls{webapp}

\printglossaries

\end{document} 
2
  • 1
    @RikyTres Remember that you can accept the answer, if it solves your problem. See How do you accept an answer? Jan 11, 2014 at 10:40
  • Yep man! I've done it ;) I was just try it before accept it...
    – RikyTres
    Jan 11, 2014 at 10:44

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.