2

I'm using a custom command \addacronym which creates two glossary entries for each acronym:

  • the main entry and
  • a cross-reference from the abbreviation to the main entry.

I also had to redefine the \glsseeitemformat command to change the text of the cross-reference links to the long versions of the acronyms by calling \acrlong.

The problem is that this command adds a new entry location to the main glossary term. How can I avoid that?

Here is a MWE:

\documentclass{article}

\usepackage[hidelinks]{hyperref}

\usepackage{glossaries}

\makeglossaries

% A new command creates two glossary entries for each acronym (the main entry
% and a cross-reference from abbreviation to the main entry).
% Syntax: \addacronym[options]{label}{abbreviation}{long}{description}
\newcommand{\addacronym}[5][]{
  % Create the main glossary entry with \newacronym
  % \newacronym[key-val list]{label}{abbrv}{long}
  \newacronym[
    name={#4 (#3)},
    description={#5},
    #1 % pass additional options to \newglossaryentry
    ]
    {#2}{#3}{#4}
  % Create a cross-reference from the abbreviation to the main glossary entry by
  % creating an auxiliary glossary entry (note: we set the label of this entry
  % to '<original label>_auxiliary' to avoid clashes)
  \newglossaryentry{#2_auxiliary}{
    name={#3},
    sort={#3},
    description={\makefirstuc{#4}},
    see=[See:]{#2}
  }
}

% Change the text of the cross-reference links to long versions of the acronyms
\renewcommand*{\glsseeitemformat}[1]{\emph{\acrlong{#1}}.}

\addacronym
 {sample} % label
 {ABR} % abbreviation
 {long version of the acronym}
 {Description of the acronym}

\begin{document}

The first occurrence of the acronym would look like:
\gls{sample}.
Further occurrences would look like: \gls{sample}.

\newpage

\printglossaries

\end{document}

It produces two pages. First page:

enter image description here

Second page:

enter image description here

The entry location I want to remove is crossed-out in red.

2
  • Try using \glsentrylong instead of \acrlong. The former just displays the text associated with the long version without indexing it or creating a hyperlink. If you want a hyperlink you can use \glshyperlink[\glsentrylong{sample}]{sample} Commented Aug 17, 2013 at 11:47
  • @NicolaTalbot, your solution works like a charm. Thanks! Please, create an answer, so I can accept it.
    – tjanez
    Commented Aug 17, 2013 at 13:20

1 Answer 1

3

\glsentrylong just displays the text associated with the long version without indexing it or creating a hyperlink, so you can use \glsentrylong instead of \acrlong. If you want a hyperlink as well, you can use \glsentrylong in the optional argument of \glshyperlink. Example:

\documentclass{article}

\usepackage[hidelinks]{hyperref}

\usepackage{glossaries}

\makeglossaries

% A new command creates two glossary entries for each acronym (the main entry
% and a cross-reference from abbreviation to the main entry).
% Syntax: \addacronym[options]{label}{abbreviation}{long}{description}
\newcommand{\addacronym}[5][]{
  % Create the main glossary entry with \newacronym
  % \newacronym[key-val list]{label}{abbrv}{long}
  \newacronym[
    name={#4 (#3)},
    description={#5},
    #1 % pass additional options to \newglossaryentry
    ]
    {#2}{#3}{#4}
  % Create a cross-reference from the abbreviation to the main glossary entry by
  % creating an auxiliary glossary entry (note: we set the label of this entry
  % to '<original label>_auxiliary' to avoid clashes)
  \newglossaryentry{#2_auxiliary}{
    name={#3},
    sort={#3},
    description={\makefirstuc{#4}},
    see=[See:]{#2}
  }
}

% Change the text of the cross-reference links to long versions of the acronyms
\renewcommand*{\glsseeitemformat}[1]{\emph{\glshyperlink[\glsentrylong{#1}]{#1}}.}

\addacronym
 {sample} % label
 {ABR} % abbreviation
 {long version of the acronym}
 {Description of the acronym}

\begin{document}

The first occurrence of the acronym would look like:
\gls{sample}.
Further occurrences would look like: \gls{sample}.

\newpage

\printglossaries

\end{document}

This produces:

Image of resulting glossary

You must log in to answer this question.

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