1

I use the package glossaries-extra and address the same terms multiple times in my writing. I needed to have control over what page numbers appear in my glossaries and found this thread.

The solution linked above excludes the terms not marked with > from the glossary altogether. Is there a way to include all the terms mentioned in a document but provide page numbers only for the marked instances?

Thank you in advance for any help!

\documentclass[10pt]{article}

\usepackage[colorlinks=true]{hyperref}
\usepackage[acronyms]{glossaries-extra}

\setabbreviationstyle[acronym]{nolong-short}
\makeglossaries

\GlsXtrSetDefaultGlsOpts{noindex}
\GlsXtrSetAltModifier{>}{noindex=false}

% Used in text, not marked as `>` -- add to glossary without page number
\newglossaryentry{charger}{
    name={charger},
    description={A device for charging mobile phones}}

% Used in text, marked as `>` -- add to glossary with page number
\newacronym{usb}{USB}{Universal Serial Bus}

% Not used in text -- do not add to glossary
\newacronym{api}{API}{Application Programming Interface}


\begin{document}


\section*{In English}

The \gls{charger} has three \glsxtrfull>{usb} ports.


\printglossaries


\end{document}

Desired result:

enter image description here

Edit

Updated my MWE and included the picture of a glossary that I would like to have.

Background: I have a long list of term definitions. Collaborators write different chapters and use different terms, marking some term occurrences with > to add page numbers to glossaries.

I compile the final document and need to make sure that all used terms are included in the glossary, even those that are not originally marked with >.

As a result, I either need to have a mechanism to include all used terms (and only those marked with > will have page numbers).

If it is not possible, I need to somehow automatically identify which used terms have no single occurrence marked with > and mark them so that they appear in the glossary. Of course, I can find unmarked terms manually, but it will take hours.

2
  • Could you update your MWE with the output you don't want to have? Three or more chapters by different authors with different definitions, etc., some items are missing or have multiple pages in the glossary, or is there the same with different definitions, etc.? All the real life situations you come across and want to avoid. – Simon Dispa Apr 13 at 18:49
  • I think my current MWE and the explanation under it reflects all real-life situations, at least known to me at this point. – f-hollow Apr 15 at 2:55
1

From https://tex.stackexchange.com/a/346462/161015

Use a dummy counter (that produces no text) for the entries where you don't want the page numbers.

The document has two pages. You can choose which page is added to the glossary or acronyms lists.

p

g

a

\documentclass[10pt]{report}

%% From https//tex.stackexchange.com/a/346462/161015
\newcounter{empty}
\renewcommand{\theempty}{}

\usepackage[colorlinks=true]{hyperref}

\usepackage[acronyms]{glossaries-extra}
\setabbreviationstyle[acronym]{nolong-short}
\makeglossaries

\newglossaryentry{charger}{
    name={charger},
    description={A device for charging mobile phones}}

\newacronym{usb}{USB}{Universal Serial Bus} 

\newglossaryentry{Inventio}
{name={Inventio},
    description={The method used for the discovery of arguments}
}

\newacronym{inv}{Inventio}{one of the five canons of rhetoric}  

\newglossaryentry{Dispositio}
{name={Dispositio}, description={Is the system used for the organization of arguments }
}

\newglossaryentry{Elocutio}
{name={Elocutio},   description={Is the term for the mastery of stylistic elements in Western classical rhetoric}
}

\newglossaryentry{Narratio}
{name={Narratio}, description={Part of an argument in which a speaker or writer provides a narrative account}
}

\newglossaryentry{Memoria}
{name={Memoria},    description={The term for aspects involving memory}
}

\newglossaryentry{Pronuntiatio}
{name={Propositio}, description={The discipline of delivering speeches}
}

\begin{document}

\chapter{List of entries I}

\begin{enumerate}
    \item The \gls[counter=empty]{Inventio} is \glsxtrfull{inv}.    
    \item The \gls{Dispositio}.     
    \item The \gls{Elocutio}.
    \item The \gls{Narratio}.
    \item The \gls{Memoria}.
    \item The \gls{Pronuntiatio}.   
\end{enumerate}

\section*{In English I}

The \gls{charger} has three \glsxtrfull{usb} ports.

\chapter{List of entries II}

\begin{enumerate}
    \item The \gls{Inventio} is \glsxtrfull[counter=empty]{inv}.
    \item The \gls[counter=empty]{Dispositio}.      
    \item The \gls[counter=empty]{Elocutio}.
    \item The \gls[counter=empty]{Narratio}.
    \item The \gls[counter=empty]{Memoria}.
    \item The \gls[counter=empty]{Pronuntiatio}.
\end{enumerate}

\section*{In English II}

The \gls{charger} has three \glsxtrfull[counter=empty]{usb} ports.

\printglossaries

\end{document}

This is nice but perhaps inconvenient. From the same link:

The other way around is make the counter=empty the default and add the counter=page option for those entries (the first time only) that must have the page number registered.

1
  • Thank you for your answer! Unfortunately, it does not solve my issue. Sorry, looks like my question was not clear. I refined it and added some extra details. – f-hollow Apr 12 at 9:58

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.