Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to be able to reference a section, table or other \labeled item when defining an acronym or other glossary entry. The glossaries package uses the see attribute or \glssee command to set up cross-referencing, but cross-referencing does not seem to support non-glossary items, such as sections, tables, figures, etc.

I've tried just typing into the description something like see \autoref{whatever}, but this doesn't look the same as other glossary entries. My hack is particularly painful for acronyms, as shown below, because you need to manually enter first and short.

\documentclass{article}

\usepackage[nopostdot,section,numberedsection=autolabel]{glossaries}
\usepackage[pdftex]{hyperref}

\makeglossaries

% the way i'd like it to work...
  \newacronym{ACR}{ACR}{horrible spelling of acronym}
  \glssee[see]{ACR}{sect:acr}

% a way that almost works...
% but it is not consistent the the see= attribute (one is before one is after)
  \newglossaryentry{ACR2}{
    type=\acronymtype,
    name={ACR2},
    description={horrendous spelling of acronym, \emph{see \autoref{sect:acr}}},
    first={horrendous spelling of acronym (ACR2)},
    short={ACR2}
  }

% linking to another glossary entry
  \newglossaryentry{nice-ref}{
    name={nice ref},
    description={nice ref cleanly uses the \texttt{glossaries}
                 packages built-in see attribute to point to ACR.},
    see={another-entry}
  }
  \newglossaryentry{another-entry}{
    name={another entry},
    description={another entry}
  }


\begin{document}

\section{First section}
I'm using \gls{ACR} and \gls{ACR2}.

Now onto interesting things, like \gls{another-entry} and \gls{nice-ref}.

\section{Second section, this one about ACR}
\label{sect:acr}

  \gls{ACR} and \gls{ACR2} are awesome\ldots soooooooo awesome.

  \printglossary

\end{document}

Example output: Example of different behaviors and inability to reference non-glossary items

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Internally the glossaries package uses the makeindex/xindy cross-referencing mechanism. The see key and \glssee command are provided as a safeguard against misspelling the referenced term or cross-referencing a non-existent term, but you don't have to use them. They also provide a processor-independent interface, since makeindex and xindy have different ways of tagging cross-references. With makeindex, this is just done by using a formatting command that takes two arguments: the first is the cross-referenced text and the second is the location, which is ignored.

So you can just define a command that takes your label as the argument:

\newcommand*{\seeref}[2]{\emph{see} \autoref{#1}}

and reference the entry using that command as the format:

\newacronym{ACR2}{ACR2}{horrible spelling of acronym}
\glsadd[format=seeref{sect:acr}]{ACR2}

Here's the complete MWE:

\documentclass{article}

\usepackage[nopostdot,section,numberedsection=autolabel]{glossaries}
\usepackage[pdftex]{hyperref}

\makeglossaries

\newacronym{ACR}{ACR}{horrible spelling of acronym}

\newcommand*{\seeref}[2]{\emph{see} \autoref{#1}}

\newacronym{ACR2}{ACR2}{horrible spelling of acronym}
\glsadd[format=seeref{sect:acr}]{ACR2}

% linking to another glossary entry
  \newglossaryentry{nice-ref}{
    name={nice ref},
    description={nice ref cleanly uses the \texttt{glossaries}
                 packages built-in see attribute to point to ACR.},
    see={another-entry}
  }
  \newglossaryentry{another-entry}{
    name={another entry},
    description={another entry}
  }

\begin{document}

\section{First section}
I'm using \gls{ACR} and \gls{ACR2}.

Now onto interesting things, like \gls{another-entry} and \gls{nice-ref}.

\section{Second section, this one about ACR}
\label{sect:acr}

  \gls{ACR} and \gls{ACR2} are awesome\ldots soooooooo awesome.

  \printglossary

\end{document}

This produces:

Image of resulting document

share|improve this answer
    
Awesome, thanks! –  SimplyKnownAsG Jul 17 at 19:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.