LaTeX forum ⇒ Graphics, Figures & Tableshyperlinks in tikz Topic is solved

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

hyperlinks in tikz

Postby omerangel » Sat Oct 29, 2016 11:36 pm

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


  1. \documentclass{article}
  2.  
  3. \usepackage{amsthm}
  4. \newtheorem{theorem}{Theorem}
  5.  
  6. \usepackage{tikz}
  7. \usetikzlibrary{calc}
  8.  
  9. \usepackage{hyperref}
  10.  
  11. \begin{document}
  12. \section{A graph for Omer}
  13.  
  14. \begin{tikzpicture}
  15. \node(A) at (0,0) {$A$};
  16. \node(B) at (10,0) {$B$};
  17. \draw[->] (A)-- node[below]{\hyperlink{tikz_thm1}{Theorem 1}} (B);
  18. \end{tikzpicture}
  19.  
  20. \begin{theorem}\label{thm1}\hypertarget{tikz_thm1}
  21. 1+1+2.
  22. \end{theorem}
  23. \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?

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

Postby rais » Sun Oct 30, 2016 10:04 am

you mean, like this?
  1. \documentclass{article}
  2.  
  3. \usepackage{amsthm}
  4. \newtheorem{theorem}{Theorem}
  5.  
  6. \usepackage{tikz}
  7. \usetikzlibrary{calc}
  8.  
  9. \usepackage{hyperref}
  10.  
  11. \begin{document}
  12. \section{A graph for Omer}
  13.  
  14. \begin{tikzpicture}
  15. \node(A) at (0,0) {$A$};
  16. \node(B) at (10,0) {$B$};
  17. \draw[->] (A)-- node[below]{\autoref{thm1}} (B);
  18. \end{tikzpicture}
  19.  
  20. \begin{theorem}\label{thm1}
  21. 1+1+2.
  22. \end{theorem}
  23. \end{document}

KR
Rainer

omerangel
Posts: 2
Joined: Sat Oct 29, 2016 8:55 pm

Postby omerangel » Mon Oct 31, 2016 7:55 am

Looks great. Thanks!


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 11 guests