2

The Problem

I'm creating a document using the acronym package. I want to have my uses of \ac, \Ac, \iac, etc. link to the corresponding entry in my list of acronyms (created using the acronym environment), but I do not want the acronyms in the list to be hyperlinks to their first uses. How do I do this?

MWE

\documentclass{minimal}
\usepackage{hyperref}
\usepackage{acronym}

\begin{document}

The \ac{QBF} jumps over \iac{LD}. The \ac{LD} jumps over \iac{QBF}.

\begin{acronym}
    \acro{QBF}{quick brown fox}
    \acro{LD}{lazy dog} \acrodefindefinite{LD}{an}{a}
\end{acronym}

\end{document}

Desired Output

Note that the hyperlinks in the "Desired Output" section do not actually go anywhere. They are intended to demonstrate where hyperlinks appear in the outputted document.

Description: In the text of the document, all uses of the acronym link to the corresponding entry in the list of acronyms. In the list of acronyms (within the acronym environment), the entries are not hyperlinks.

The quick brown fox (QBF) jumps over a lazy dog (LD). The LD jumps over a QBF.

QBF quick brown fox
LD lazy dog

Actual Output

Note that the hyperlinks in the "Actual Output" section do not actually go anywhere. They are intended to demonstrate where hyperlinks appear in the outputted document.

Description: In the text of the document, all uses of the acronym link to the corresponding entry in the list of acronyms. In the list of acronyms (within the acronym environment), each entry links back to the first use of its respective acronym in the document.

The quick brown fox (QBF) jumps over a lazy dog (LD). The LD jumps over a QBF.

QBF quick brown fox
LD lazy dog

What I tried

Based on section 4.2 of the acronym package documentation, which discusses the implementation of the package, I was hopeful that this would solve the problem, but it didn't work.

\documentclass{minimal}
\usepackage{hyperref}
\usepackage{acronym}

\begin{document}

The \ac{QBF} jumps over \iac{LD}. The \ac{LD} jumps over \iac{QBF}.

{\makeatletter\AC@nohyperlinkstrue\makeatother
    \begin{acronym}
        \acro{QBF}{quick brown fox}
        \acro{LD}{lazy dog} \acrodefindefinite{LD}{an}{a}
    \end{acronym}
}

\end{document}

1 Answer 1

3

First of all, \acrodefindefinite has three mandatory arguments, e.g., \acrodefindefinite{LD}{an}{a}. Because you are using only two argument, your examples result in errors. Please, see the manual for more information how to use it.

To not have links from the list of acronyms to the usage of the acronyms, you can locally redefine \AC@hyperref inside the environment. To do so, either add

\makeatletter
\def\AC@hyperref[#1]#2{#2}
\makeatother

immediately after \begin{acronym} or use the generic LaTeX hook mechanism (see lthooks-doc.pdf for more information):

\documentclass{article}
\usepackage{hyperref}
\usepackage{acronym}

\makeatletter
\AddToHook{env/acronym/begin}{\def\AC@hyperref[#1]#2{#2}}
\makeatother

\begin{document}

The \ac{QBF} jumps over \iac{LD}. The \ac{LD} jumps over \iac{QBF}.

\section*{List of acronyms}
\begin{acronym}
  \acro{QBF}{quick brown fox}
  \acro{LD}{lazy dog}
\end{acronym}

\end{document}

links to the list of acronyms but not the usage of the acronyms

0

You must log in to answer this question.

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