Graphics, Figures & Tableshyperlinks in tikz

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
omerangel
Posts: 2
Joined: Sat Oct 29, 2016 8:55 pm

hyperlinks in tikz

Post by omerangel »

I wish to have a figure with numerous hyperlinks to theorems in the paper. I have the following construction:

\documentclass{article}

\usepackage{amsthm}
\newtheorem{theorem}{Theorem}

\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{hyperref}

\begin{document}
 \section{A graph for Omer}

\begin{tikzpicture}
  \node(A) at (0,0) {$A$};
  \node(B) at (10,0) {$B$};
  \draw[->] (A)-- node[below]{\hyperlink{tikz_thm1}{Theorem 1}} (B);
\end{tikzpicture}

\begin{theorem}\label{thm1}\hypertarget{tikz_thm1}
  1+1+2.
\end{theorem}
\end{document}
However, I would much prefer if I could use the theorem labels already in place, instead of having a separate hypertarget anchors, and if the link text could be created automatically, similarly to using \ref{thm1} in the above context (or better yet \cref{thm1} with cleveref.) Can this be done?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

hyperlinks in tikz

Post by rais »

you mean, like this?

Code: Select all

    \documentclass{article}

    \usepackage{amsthm}
    \newtheorem{theorem}{Theorem}

    \usepackage{tikz}
    \usetikzlibrary{calc}

    \usepackage{hyperref}

    \begin{document}
     \section{A graph for Omer}

    \begin{tikzpicture}
      \node(A) at (0,0) {$A$};
      \node(B) at (10,0) {$B$};
      \draw[->] (A)-- node[below]{\autoref{thm1}} (B);
    \end{tikzpicture}

    \begin{theorem}\label{thm1}
      1+1+2.
    \end{theorem}
    \end{document}
KR
Rainer
omerangel
Posts: 2
Joined: Sat Oct 29, 2016 8:55 pm

Re: hyperlinks in tikz

Post by omerangel »

Looks great. Thanks!
Post Reply