0

I'd like to be able to control which \gls-entries shows up with pagenumbers in the glossary. I've read the manual and found that the glsignore format does this partially, but only seem to make the number illegible rather than removing it fully. I.e. note the 1, , for the pizza entry, I would only like the 1 there (since that is the only reference from the text body).

Is there any way to fix this without resorting to bib2gls? Converting my very large and crossreferenced and full of macro to bib-format is a significant venture, which I'd like to avoid.

I'm quite handy with awk / sed / grep etc, so having to reformat all calls to \gls{*entry*} in the main body would not be an issue (I guess I could convert my glossary to .bib as well, but I really don't want to).

Here in the example I'm using a \mygls-macro to apply glsignore on entries within the glossary itself. I would like to use it on some entries outside the glossary as well, but inside the glossary is the most important.

example_image

I am fully aware that I need to run makeglossaries at least twice since not all standards are directly referenced in the text body.

MWE:

\documentclass{article}

\usepackage[xindy,acronym]{glossaries-extra}
\makeglossaries

\newcommand{\mygls}[1]{\gls[format=glsignore]{#1}}

\newglossaryentry{tech}
{%
  name={technology},
  description={Not to be confused with \mygls{pizza}.}
}

\newglossaryentry{pizza}
{%
  name={pizza},
  description={Food usually consumed with \mygls{beer}.}
}

\newglossaryentry{beer}
{%
  name={beer},
    description={Drink normally consumed with \mygls{pizza}.}
}


\newglossaryentry{sim}
{%
  name={simulated},
    description={A simulated newpage \newpage which also references \mygls{pizza}.}
}

\begin{document}

A glossary example. International \gls{tech} and \gls{pizza} use has
reached peak oil levels. As has \gls{sim} shenanigans.

\newpage

\printglossaries

\end{document}

As a further description of my case, one of my glossaries (in my very-large-thesis*tm) contains a hundred or so standards with many cross-references, and I'd like to get rid of those cross-references pagenumbering because they completely garble the glossary (i.e. the pagenumbers take up more space than the descriptions of the entries themselves) but still keep the pagenumbers for when the standards are referenced in the text, and keep the links for readers reading the pdf rather than printed version.

Got any ideas?

2 Answers 2

1

The "easiest"/"cleanest" solution that comes to mind would be to introduce a conditional and redefine \delimN, \glsXpageXglsignore, and \glsXpageXglsnumberformat using \let, \renewcommand so that the first one's redefinition only calls \toggletrue, the last two always call \togglefalse after executing their original definition, and the last one additionally calls the original definition of \delimN first using \iftoggle.

EDIT: AFAIR, you'll only find the definitions of the three commands to be redefined by looking at the glossaries[-extra] source(s). Since we only slightly modify the original behaviour – and luckily there are no side effects from "freely modifying" them in this case –, it's sufficient to simply "wrap" or "extend" the original definitions without even taking a peek. (The only trick is to place the redefinitions where they belong, that is, at the end of the glossary preamble. Note that we're able to use the starred version of \renewcommand here, but this detail can be safely ignored.)

If you add the following lines right below the inclusion of the glossaries-extra package, no unneeded delimiters should be visible (tested with TeXlive 2019):

\usepackage{etoolbox}
\apptoglossarypreamble{%
  \newtoggle{PrintDelimiter}
  \let\OLDdelimN\delimN \renewcommand*{\delimN}{\toggletrue{PrintDelimiter}}
  \let\OLDglsXpageXglsignore\glsXpageXglsignore \renewcommand*{\glsXpageXglsignore}[2]{\OLDglsXpageXglsignore{#1}{#2}\togglefalse{PrintDelimiter}}
  \let\OLDglsXpageXglsnumberformat\glsXpageXglsnumberformat \renewcommand*{\glsXpageXglsnumberformat}[2]{\iftoggle{PrintDelimiter}{\OLDdelimN}{}\OLDglsXpageXglsnumberformat{#1}{#2}\togglefalse{PrintDelimiter}}
}

The result should look like this:

enter image description here

2
  • Can you elaborate? I could not find much of a manual on \delimN, \glsXpageXglsignore and \glsXpageXglsnumberformat.
    – flindeberg
    Commented Sep 13, 2019 at 16:36
  • Superb, thanks a lot.
    – flindeberg
    Commented Sep 23, 2019 at 14:40
0

Another way of solving the issue. See the definition of \mygls. \glshyperlink does not create the glossary->position in text pagenumber-thingy :-)

\documentclass{article}

\usepackage[xindy,acronym]{glossaries-extra}
\makeglossaries

\newcommand{\mygls}[1]{\glshyperlink[\glsentrytext{#1}]{#1}}

\newglossaryentry{tech}
{%
  name={technology},
  description={Not to be confused with \mygls{pizza}.}
}

\newglossaryentry{pizza}
{%
  name={pizza},
  description={Food usually consumed with \mygls{beer}.}
}

\newglossaryentry{beer}
{%
  name={beer},
    description={Drink normally consumed with \mygls{pizza}.}
}


\newglossaryentry{sim}
{%
  name={simulated},
    description={A simulated newpage \newpage which also references \mygls{pizza}.}
}

\begin{document}

A glossary example. International \gls{tech} and \gls{pizza} use has
reached peak oil levels. As has \gls{sim} shenanigans.

\newpage

\printglossaries

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .