6

I am using the acronym package in my thesis and creating a table of acronyms in the process. Throughout the thesis the acronyms are hyperlinked back to the table.

However, I don't want acronyms in sections titles to be linked as well because this creates a weird link within the ToC and also within page headers.

Can I redefine the hyperref macro for the \chapter, \section, \subsection environments so that it won't link them? And how? (This answer has it document wide for the \ac* commands)

MWE

\documentclass{book}

\usepackage{acronym} \usepackage{hyperref} \title {Example Thesis}

\begin{document} \tableofcontents \chapter*{Definitions and Abbreviations} \begin{acronym} \acro{RF}{Radio Frequency} \acro{PA}{power amplifier} \acro{WPAN}{wireless personal area networks} \end{acronym} \mainmatter \chapter{\acs{RF} Communication} \acf{RF} Communication can be used to transfer information between devices in \ac{WPAN}. \end{document}

Double links when acronyms in the contents page

EdL
  • 191

1 Answers1

4

Here a new command \acrNoHyperlink{<acr command>}{<acr argument>} is provided. It creates a new group, locally disables the acronym hyperlink, then runs <acr command>{<acr argument>}.

\documentclass{book}

\usepackage{acronym} \usepackage{hyperref} \title{Example Thesis}

\makeatletter \DeclareRobustCommand\acrNoHyperlink[2]{% % to avoid warning "Token not allowed in a PDF string" \texorpdfstring{% \begingroup \disableAcronymHyperlink #1{#2}% \endgroup }{#1{#2}}% }

\newcommand{\disableAcronymHyperlink}{% % copied from acronym.sty, lines 125--128 \def\AC@hyperlink##1##2{##2}% \def\AC@hyperref[##1]##2{##2}% \def\AC@hypertarget##1##2{##2}% \def\AC@phantomsection{}% } \makeatother

\begin{document} \tableofcontents \chapter*{Definitions and Abbreviations} \begin{acronym} \acro{RF}{Radio Frequency} \acro{PA}{power amplifier} \acro{WPAN}{wireless personal area networks} \end{acronym} \mainmatter

\chapter{\acrNoHyperlink{\acs}{RF} Communication} \acf{RF} Communication can be used to transfer information between devices in \ac{WPAN}. \newpage a \end{document}

See images of output showing chapter title in toc, text and header. enter image description here enter image description here enter image description here

muzimuzhi Z
  • 26,474
  • 1
    Is there anyway to automatically use this command in the chapter subsection environment? – EdL Jul 13 '20 at 13:58
  • 2
    @EdL It is doable, but need to hack into internals of sectioning commands. That will cause potential compatibility problems. – muzimuzhi Z Jul 13 '20 at 15:15