I have a number of acronyms in my document, some of which have a more complex meaning than others, and I would like to have an accompanying linked entry for them in the glossary.
I found that in order to define these cross-referenced acronyms, I was unable use the normal \newacronym
command and had to use newglossaryentry
instead with the type=\acronymtype
key-value pair defined.
Things seemed fine until I noticed that some of my acronyms were showing up in my document even though I had not referenced them. So, after some tweaking/testing I've worked out that the see
key is the source of the problem. I do like the functionality of the see
key-value, so I'm looking for a solution to the problem I'm reporting rather than abandoning the idea.
Where an acronym references the glossary, I use the see
key-value pair to tell it which glossary entry to point to. It appears that a side-effect of this key-value is that it forces the acronym to be displayed in the Acronyms
list in the document even though it wasn't reference in the document body. In my case, something I do not want.
Below is a sample document that demonstrates how I've approached my cross-referencing need and also demonstrates the problem.
Simply (un)comment the lines see=[Glossary:]{apig},
and \gls{api}
then rebuild.
With see
commented out, the behaviour is correct. Acronym and Glossary both have an API entry when \gls{api}
is active, and neither do when not.
Uncomment see
, and you will now have the Acronym entry regardless of the state of \gls{api}
(including a Glossary: API link that points to nothing), and when \gls{api}
is active there will be a Glossary entry as expected and the link is correct. The TCP and IP acronyms work fine.
Is there a way of fixing this behaviour?
Updates
Seems this may require bib2gls
, which needs to be installed and it appears I don't have it because I'm unable to run the example in the glossaries-user.pdf
(p25). As a result, I cannot see what the outcome would be.
At this point I don't know how to install bib2gls though it's available from CTAN and I have the necessary Java (v8+) installed.
I'm using MacOS Catalina 10.15.6 with Homebrew. I have mactex-20170524.pkg
installed and use TexStudio 3.0.1.
\documentclass{article}
\usepackage{hyperref}
\usepackage[acronym]{glossaries}
%\usepackage[nonumberlist,acronym]{glossaries} %% nonumberlist also turns off 'see' .
%\usepackage{glossaries-extra}
%\usepackage{glossaries-prefix}
\makeglossaries
%% Set flag to include Glossary in the ToC
%\glstoctrue
% Set acronyms such that on first use, the whole phrase is shown along with the acronym.
\setacronymstyle{long-short}
%
\newglossaryentry{api}{
type=\acronymtype,
name={API},
description={Application Programming Interface},
first={Application Programming Interface (API)\glsadd{apig}},
see=[Glossary:]{apig},
%% 'see' adds a note at the end of the acronym description
%% 'see' is turned off by global or local 'nonumberlist'
%% Using the example above it writes 'Glossary: API' with Glossary: in italics.
}
\newglossaryentry{apig}{
name={API},
description={An Application Programming Interface (API) is a particular set of rules and specifications that a software program can follow to access and make use of the services and resources provided by another particular software program that implements that API}
}
\newacronym{ip}{IP}{Internet Protocol}
\newacronym{lan}{LAN}{Local Area Network}
\newacronym{smp}{SMP}{Symmetric Multi-Processing}
\newacronym{tcp}{TCP}{Transmission Control Protocol}
\begin{document}
\printglossary[type=\acronymtype]
%%% \newpage just to demonstrate that links are correct
\newpage
\printglossary[type=main]
\newpage
\noindent
\gls{tcp}
sits on top of
\gls{ip}
, and you need an
%\gls{api}
. \\
\\
\noindent
Just to repeat,
\gls{tcp}
sits on top of
\gls{ip}
, and you need an
%\gls{api}
.
\end{document}
\gls{}
invocations because the\GlsXtrLoadResources[src={entries}]
failed to load my entries.bib file (though I have it in the same folder as the document). I'm not sure how to installbib2gls
on MacOS yet.