2

I'm a bit confused as I read the TikZ manual. Is there a opportunity to hyperref out of an externalized TikZ graphic into the main document?

When I compile the following code with pdflatex and --shell-escape and then do a make command and then again pdflatex, I get a main document without the hyperlink in the graph.

enter image description here

But when I compile it without externalize it works well.

enter image description here

Is there a solution for this Problem?

It would be great :-)

\documentclass{article}
\usepackage{hyperref}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[mode=list and make]
\begin{document}
\begin{tikzpicture}
  \node {root}
    child {node {\ref{eq:einstein}left}}
    child {node {right}
    };
\end{tikzpicture}

Gleichung Nr.\ref{eq:einstein}.
\newpage
\begin{equation}
 \label{eq:einstein}
 E = m \cdot c^2
\end{equation}
\end{document}

2 Answers2

2

Well, with current MiKTeX I can compile your given code without errors but one warning that one image is not up to date and schould be generated. But I can see the hyperlink to the equation:

enter image description here

Mensch
  • 65,388
1

Ok, I found out, that it is only possible to get the label number. But there is no possibility to get the hyperlink when you do the externalization. This is technically not possible.

It is written here in german: https://golatex.de/keine-hyperref-funktion-in-externer-tikz-grafik-t21388.html

So I changed to LuaLaTeX and do it all at once without externalization. It works fine, but takes reaaally long to compile.

There was an idea to recover the links with pax: https://tex.stackexchange.com/a/44104/2388 But I couldn't make it...

So if anyone can achive this, just add an answer please...

  • 1
    Indeed hypertargets to sub-PDFs are lost on inclusion, which is a technical limitation. I would just bite the sour apple and compile it in full once your document is final. I had such a thing on my PhD thesis and didn't minded to wait 10min for the final PDF as long I get a nearly correct review version within 30s using externalization technics (However, I used standalone for that, well actually I wrote standalone for just that). – Martin Scharrer Jan 09 '19 at 14:10