3

Is it possible to remove the hyperlink from the table number (or the figure number) in the list of tables (or list of figures) in a way similar to that for chapters, sections and subsections using the etoc package?

For example,

\usepackage{etoc}
\makeatletter
\let\latchapter\l@chapter
\etocsetstyle{chapter}{}{}{\latchapter{\numberline{\etocthenumber}\etocname}{\etocpage}}{}
\makeatother

produces the following for the Introduction chapter:

such that the hyperlink has been removed from the number "1" on the left-hand side, which is what I want.

However, the list of Figures still has the hyperlink on the number:

enter image description here

So, how can I remove the hyperlink from "1.1"?

[EDIT] Here is a minimal working example:

\documentclass{book}
\usepackage{xcolor}
\usepackage[colorlinks=true, linkcolor=purple]{hyperref}

\usepackage{etoc}
\makeatletter
\let\latchapter\l@chapter
\etocsetstyle{chapter}{}{}
{\latchapter{\numberline{\etocthenumber}\etocname}{\etocpage}}{}
\makeatother

\begin{document}

\tableofcontents
\listoffigures

\chapter{Introduction}
\begin{figure}
    \caption[Arp~220 SED]{}
\end{figure}

\end{document}
ajrlewis
  • 191
  • If you drop everything from \makeatletter to \makeatother the ToC sets with a hyperlink covering the entire 1 Introduction. – Werner Feb 21 '18 at 23:50
  • @Werner I wish to remove the hyperlink from the list of Figures - in a similar way to that done for the table of contents. Do you know how to do this? – ajrlewis Feb 22 '18 at 00:04
  • 1
    For what it's worth, can you please provide the community with a minimal example that replicates your current setup? It should start with \documentclass and end with \end{document} and allow the community to copy-and-paste-and-compile your code and see exactly what you're seeing. – Werner Feb 22 '18 at 00:30
  • @JohnKormylo This does not work ... I get the following error: "(/usr/local/texlive/2017/texmf-dist/tex/latex/etoc/etoc.sty (/usr/local/texlive/2017/texmf-dist/tex/latex/tools/multicol.sty)) ! Missing \endcsname inserted. \Etoc@figure@l.336" – ajrlewis Feb 22 '18 at 08:18
  • @Werner I have added a minimal working example. As can be seen this adds a link to 1.1 before Arp 220 SED in the List of Figures, which I want to remove, please. Thanks for any help. – ajrlewis Feb 22 '18 at 11:52

1 Answers1

3

Apparently etoc only affects the TOC, not the LOF.

As it turns out, there is a hyperref option to disable page references, so I was able to use my solution from here without any changes.

\documentclass{book}
\usepackage{xcolor}
\usepackage[colorlinks=true, linkcolor=purple, linktocpage=false]{hyperref}

% begin code to remove section numbers from the TOC
\makeatletter
\newcommand{\@savenumber}{}% reserve global names
\newcommand{\@savetitle}{}

\def\contentsline#1#2#3#4{%
  %\hypertarget{toc.#4}{}% set up backlink
  \bgroup% separate \numberline from title
    \renewcommand{\numberline}[1]{\xdef\@savenumber{##1}}%
    \sbox0{#2}%
    \let\numberline=\@gobble
    \xdef\@savetitle{#2}%
  \egroup
  \begingroup
    \Hy@safe@activestrue
  \edef\x{\endgroup
    \def\noexpand\Hy@tocdestname{#4}%
  }\x
  \ifx\Hy@tocdestname\ltx@empty
    \csname l@#1\endcsname{#2}{#3}%
  \else
    \ifcase\Hy@linktoc % none
      \csname l@#1\endcsname{#2}{#3}%
    \or % section
      \csname l@#1\endcsname{\numberline{\@savenumber}%
        \hyper@linkstart{link}{\Hy@tocdestname}{\@savetitle}\hyper@linkend
      }{#3}%
    \or % page
      \def\Hy@temp{#3}%
      \ifx\Hy@temp\ltx@empty
        \csname l@#1\endcsname{#2}{#3}%
      \else
        \csname l@#1\endcsname{{#2}}{%
          \hyper@linkstart{link}{\Hy@tocdestname}{#3}\hyper@linkend
        }%
      \fi
    \else % all
      \def\Hy@temp{#3}%
      \ifx\Hy@temp\ltx@empty
        \csname l@#1\endcsname{\numberline{\@savenumber}%
          \hyper@linkstart{link}{\Hy@tocdestname}{\@savetitle}\hyper@linkend
        \egroup}{}%
      \else
        \csname l@#1\endcsname{\numberline{\@savenumber}%
          \hyper@linkstart{link}{\Hy@tocdestname}{\@savetitle}\hyper@linkend
        }{%
          \hyper@linkstart{link}{\Hy@tocdestname}{#3}\hyper@linkend
        }%
      \fi
    \fi
  \fi
}
\makeatother

\begin{document}

\tableofcontents
\listoffigures

\chapter{Introduction}
\begin{figure}
    \caption[Arp~220 SED]{}
\end{figure}

\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • That's great - thanks for your time/help – ajrlewis Feb 22 '18 at 19:08
  • @Alex Good to hear that the answer helped you. If you are satisfied with the solution, please consider accepting it (by clicking on the checkmark ✓, see How do you accept an answer?). This shows others that the question is solved and will remove it from the list of unanswered questions. As a bonus, this will not only give a reward to the answer, but you will get 2 reputation points, too. – samcarter_is_at_topanswers.xyz Feb 24 '18 at 19:33