1

I would like to change the format used to print the number list in a glossary created with the glossaries package to match the style that I am using in my bibliography. However, I cannot find any information how to achieve this.

Starting from the MWE

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[nopostdot,style=indexgroup,nolist]{glossaries}

\makenoidxglossaries
\newglossaryentry{target}
{
    name={target},
    description={Foo foo bar}
}
\newglossaryentry{link}
{
    name={link},
    description={Another example \gls{target}}
}

\begin{document}

\Gls{target} and \gls{link}.

\newpage

\printnoidxglossary

\end{document}

I would like to achieve a style that resembles my bibliography which looks like:

enter image description here

That means I want to have "used on: p. 42" or "used on: pp. 3, 10, 17-30" in italics.

languitar
  • 808

1 Answers1

1

This can be done with a couple of minor modifications to the example from this answer. Just replace

 \GlsXtrEnablePreLocationTag{Page: }{Pages: }

with

\GlsXtrEnablePreLocationTag{\textit{used on p.~}}{\textit{used on pp.~}}

for the number list prefix, and for the italic number list use

\renewcommand{\GlsXtrFormatLocationList}{\textit}

Complete example:

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}

\makeglossaries

\GlsXtrEnablePreLocationTag{\textit{used on p.~}}{\textit{used on pp.~}}
\renewcommand{\GlsXtrFormatLocationList}{\textit}

\newglossaryentry{sample1}{name={sample1},description={first
example}}
\newglossaryentry{sample2}{name={sample2},description={second
example}}

\begin{document}
\gls{sample1}, \gls{sample2}.

\newpage

\gls{sample2}.

\newpage

\printglossaries

\end{document}

image of glossary

Nicola Talbot
  • 41,153
  • Thank you! Would have been easy if I found the other answer while searching. – languitar Aug 18 '17 at 10:16
  • For acronyms, is it possible to add a dot after long version automatically? For normal glossaries entries I always use a complete sentence, but for acronyms a dot would be needed before the "used on". – languitar Aug 18 '17 at 10:20
  • 1
    @languitar The postdot package option will automatically add a dot after all the descriptions. If you only want it done after certain entries you can use the post-description hook. For example, if you define acronyms using \newacronym, this automatically sets category=acronym, so you could do \renewcommand{\glsxtrpostdescacronym}{.} but if you use \newabbreviation instead (which does category=abbreviation) you'd need to do \renewcommand{\glsxtrpostdescabbreviation}{.}. – Nicola Talbot Aug 18 '17 at 12:31