0

In this superb answer, @Ulrike Fischer gives an answer how to deactivate hyperref and keep the bookmarks bar working. MWE is there in the answer.

I, however, want to keep hyperrefs working in the table of contents (but not after that). Any neat solution?

Using the environment \begin{NoHyper}…\end{NoHyper} (after the toc) doesn’t work in the same way (besides it’s not good use for a document of 500 pages to put it into this environment; and \AtBeginDocument{\NoHyper} is no possible solution, since the toc should have enabled links).

hh93
  • 79

1 Answers1

3

\begin{shameless-advertising}

I just uploaded to ctan the pdfmanagement-testphase package which contains the test version of new PDF management code for LaTeX. This bundle contains also a new hyperref driver which allows to locally disable link types. It also use nicer colors ...

Attention

  • Todays installation in texlive is faulty, they put two files in the doc folder and not into the tex/latex, but it should be okay tomorrow.
  • The package is called -testphase as it is still in the testphase. It is not compatible with every package and things can be wrong or be missing.

So currently you use it at your risk.

\RequirePackage{pdfmanagement-testphase} %first thing!
\DeclareDocumentMetadata{} %required!

\documentclass{article}

\usepackage{hyperref}

\begin{document} \tableofcontents

some text

\ref{test}

\url{https://tex.stackexchange.com/}

\hypersetup{link=false,url=false}

\ref{test}

\url{https://tex.stackexchange.com/}

\newpage \section{section}\label{test}

\end{document}

enter image description here

\end{shameless-advertising}

Ulrike Fischer
  • 327,261
  • Thank you! I'm currently unable to install the package (due to restrictions on my pc from work). Will definitly look into it in the (not so near) future. Then – at least I assume from answers you’ve given so far – I will accept the answer. – hh93 Feb 26 '21 at 14:41
  • Thank you once more! I tried it on my pretty loaded document (dissertation with > 500 pages, and many, many packages, some of them outdated). It worked perfectly as far as I can tell. – hh93 Mar 16 '21 at 15:02
  • May this be related to the package: TeXstudio’s curser–pdf–linking mechanism doesn’t work (so when navigating through the code, my pdf will not follow my editing) ? – hh93 Mar 16 '21 at 15:12
  • sorry no idea, I don't know what texstudio does. – Ulrike Fischer Mar 16 '21 at 15:13
  • Has to do with -synctex=1. I'm looking into it right now… – hh93 Mar 16 '21 at 15:55
  • Ok, a simple MWE does not procude this problem. So it’s not due to pdfmanagement-testphase, at least not directly. If I encounter interference with another package, I will write you. For now, it is really great! – hh93 Mar 16 '21 at 17:03