5

I'm writing a presentation for the Shannon Switching Game. In this game, players take turns picking edges from a graph. For fun, I decided to try to include an example game in the presentation.

The effect I want: when I click on a certain edge, I go to a specified slide. The edges will not always be vertical or horizontal.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

\begin{tikzpicture}\label{picture:first}
  \node (A) {$A$};
  \node (B) [below right=2 and 3 of A] {$B$};
  \path (A) edge[line width=5pt] (B); % I want this edge to be click-able
\end{tikzpicture}

\newpage

\begin{tikzpicture}\label{picture:second}
  \node (A) {$A$};
  \node (B) [below right=2 and 3 of A] {$B$};
  \path (A) edge[line width=5pt,red] (B)
\end{tikzpicture}

\end{document}

I've found answers to similar questions, either where the node is a hyperlink or where the edge is horizontal. Until I find a way to do this, my temporary solution is to put a node by each edge to label it and click on the edge labels.

9
  • 2
    it's the PDF hyperlink specification that makes this not possible.
    – percusse
    May 2, 2016 at 0:00
  • Would it be possible to generate several invisible nodes along the path each being a link?
    – Pi Fisher
    May 2, 2016 at 0:03
  • If you already know how to add nodes and make them hyperlinks, can't you do this already? If the nodes have no content, they will be invisible (other things being equal).
    – cfr
    May 2, 2016 at 0:11
  • Another possibility is to hide lyperlinks under the image. See tex.stackexchange.com/questions/176280/… May 2, 2016 at 0:51
  • 1
    Oh, and please don't use minimal for examples. I've illustrated the idea I had, guessing how you created the links. You can just make the nodes invisible and on top of the edge. I created 6. Of course you could make more.
    – cfr
    May 2, 2016 at 1:21

1 Answer 1

5

This creates 6 hyperlinks along the first edge which link to the second slide.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
  \begin{frame}{First}
  \begin{tikzpicture}\label{picture:first}
    \node (A) {$A$};
    \node (B) [below right=2 and 3 of A] {$B$};
    \path (A) edge [line width=5pt] node [pos=0, circle] {\hyperlink<1>{target}{}} node [pos=.2, circle] {\hyperlink<1>{target}{}} node [pos=.4, circle] {\hyperlink<1>{target}{}} node [pos=.6, circle] {\hyperlink<1>{target}{}} node [pos=.8, circle] {\hyperlink<1>{target}{}} node [pos=1, circle] {\hyperlink<1>{target}{}}  (B);
  \end{tikzpicture}
\end{frame}
\begin{frame}{Second}
  \hypertarget<1>{target}{}
  \begin{tikzpicture}\label{picture:second}
    \node (A) {$A$};
    \node (B) [below right=2 and 3 of A] {$B$};
    \path (A) edge [line width=5pt, red] (B);
  \end{tikzpicture}
\end{frame}
\end{document}

EDIT

Since it doesn't have to be an edge, it is straightforward to create a number of nodes along the path with a \foreach loop. I've also made the links a bit bigger by adding some more substantial invisible content ;). Here, I create 11 links:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
  \begin{frame}{First}
  \begin{tikzpicture}\label{picture:first}
    \node (A) {$A$};
    \node (B) [below right=2 and 3 of A] {$B$};
    \draw [line width=5pt] (A) -- (B) \foreach \i in {0,...,10} { node [pos=\i/10, circle] {\hyperlink<1>{target}{\phantom{X}}} };
  \end{tikzpicture}
\end{frame}
\begin{frame}{Second}
  \hypertarget<1>{target}{}
  \begin{tikzpicture}\label{picture:second}
    \node (A) {$A$};
    \node (B) [below right=2 and 3 of A] {$B$};
    \path (A) edge [line width=5pt, red] (B);
  \end{tikzpicture}
\end{frame}
\end{document}
4
  • Cool! Is there a way to not have to specify each node individually? Maybe a foreach loop?
    – Pi Fisher
    May 2, 2016 at 1:20
  • I tried a foreach loop but couldn't get it to work. Does it have to be an edge? If it was a regular path, it would be easy.
    – cfr
    May 2, 2016 at 1:23
  • It does not need to be an edge. I'm just used to using edges in graphs because the first example I saw for how to make automata used them.
    – Pi Fisher
    May 2, 2016 at 1:44
  • 1
    @PiFisher In that case, please see edit above.
    – cfr
    May 2, 2016 at 2:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .