4

I want something similar to this question, but the answer lacks a few things that I need:

  • redefinitions of the plural variants of the \gls macros (\glspl, \Glspl, \GLSpl)
  • every time a new chapter is started, I want the hyperrefs to be turned on again (automatically)
  • in the \printglossaries-produced section, all glossary references should be hyperrefs (for when I'm using \gls in an entry's description)

Regarding the first bullet point, it would be nice if \gls{x} is the singular form of \glspl{x} would produce just one hyperref to the corresponding glossary entry.

An acceptable alternative to not having hyperrefs in subsequent glossary entry usages would be to just disable the colored boxes on the hyperrefs (but keeping the hyperrefs)

3

If your first and text values are the same, you can achieve this using:

\documentclass{report}

\usepackage{etoolbox}
\usepackage[colorlinks]{hyperref}
\usepackage
 [
    nohypertypes={main}% suppress automatic links for main glossary
 ]
 {glossaries}

% reset entries at the start of each chapter
\preto\chapter{\glsresetall}

\makeglossaries

% Modify the way `\gls`, `\glspl` (and their case-changing versions)
% and `\glsdisp` appear:

\renewcommand{\glsentryfmt}{%
  \ifglsused{\glslabel}
    {\glsgenentryfmt}% entry has been used.
    {\glshyperlink[\glsgenentryfmt]{\glslabel}}% entry hasn't been used
}

\newglossaryentry{apple}{
  name={apple},
  description={small round fruit}
}

\newglossaryentry{pear}{
  name={pear},
  description={small non-round fruit}
}

\begin{document}

\chapter{Sample}

\section{No Case Change}

Singular: \gls{apple}. Plural: \glspl{apple}.

Singular: \gls{pear}. Plural: \glspl{pear}.

\section{First Letter Uppercase}

Singular: \Gls{apple}. Plural: \Glspl{apple}.

Singular: \Gls{pear}. Plural: \Glspl{pear}.

\section{All Uppercase}

Singular: \GLS{apple}. Plural: \GLSpl{apple}.

Singular: \GLS{pear}. Plural: \GLSpl{pear}.

\chapter{Another Sample}

\section{No Case Change}

Singular: \gls{apple}. Plural: \glspl{apple}.

Singular: \gls{pear}. Plural: \glspl{pear}.

\section{First Letter Uppercase}

Singular: \Gls{apple}. Plural: \Glspl{apple}.

Singular: \Gls{pear}. Plural: \Glspl{pear}.

\section{All Uppercase}

Singular: \GLS{apple}. Plural: \GLSpl{apple}.

Singular: \GLS{pear}. Plural: \GLSpl{pear}.

\printglossaries

\end{document}

First page:

Image of first page

Second page:

Image of second page

Glossary:

Image of glossary

If you have any acronyms then this method will reset them at the start of every chapter. If you don't want this to happen, then the code will require some modification.

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.