Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the following example, clicking the text on the two blocks will take us to either the second section or a piece of text within that section. I would like to be able to navigate using the edge connecting the two blocks, that is, I want to click on the edge and be taken to a label or hypertarget. Is this doable?

\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes}
\usepackage{hyperref}
\begin{document}

\section{First section}

\begin{tikzpicture}
  \node[draw, rectangle] (A) {\hyperlink{gotext}{Go to linked text}};
  \node[draw, rectangle, right=of A] (B) {\hyperref[sec:mysection]{Go to 2nd section}};

  \draw (A) -- (B);    % The edge I want to click on to navigate.
\end{tikzpicture}

\newpage
\section{Second section}
\label{sec:mysection}

Corruption can occur on different scales. There is corruption that occurs as small favours between a small number of people (petty corruption), corruption that affects the government on a large scale (grand corruption), and corruption that is so prevalent that it is part of the every day structure of society, including corruption as one of the symptoms of organized crime (systemic corruption).

Judicial corruption refers to corruption related misconduct of judges, through receiving or giving bribes, improper sentencing of convicted criminals, bias in the hearing and judgement of arguments and other such misconduct.

\hypertarget{gotext}{%
Governmental corruption} of judiciary is broadly known in many transitional and developing countries because the budget is almost completely controlled by the executive. The latter undermines the separation of powers, as it creates a critical financial dependence of the judiciary. The proper national wealth distribution including the government spending on the judiciary is subject of the constitutional economics.

\newpage
empty page

\end{document}

This question is somewhat related to what I want although I could not make much sense of what is happening there.

share|improve this question

1 Answer 1

up vote 11 down vote accepted

Here is some hair pin curve.

   \path let   \p1=(A.east),
                \p2=(B.west) ,
                \n1={veclen(\x2-\x1,\y2-\y1)} in
   node[outer sep=0pt,inner xsep=0pt,align=left,anchor=west,minimum width=\n1,minimum height=1ex] 
                              at (A.east) (link)  {\hyperlink{gotext}{\hphantom{\hspace*{\n1}}}};

Full code:

\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,calc}
\usepackage{hyperref}
\begin{document}

\section{First section}

\begin{tikzpicture}
  \node[draw, rectangle] (A) {{Go to linked text}};
  \node[draw, rectangle, right=of A] (B) {\hyperref[sec:mysection]{Go to 2nd section}};

   \path let   \p1=(A.east),
                \p2=(B.west) ,
                \n1={veclen(\x2-\x1,\y2-\y1)} in
   node[outer sep=0pt,inner xsep=0pt,align=left,anchor=west,minimum width=\n1,minimum height=1ex] at (A.east) (link)  {\hyperlink{gotext}{\hphantom{\hspace*{\n1}}}};
%  \node[minimum width={veclen(A.east-B.west)}] at (A.east) {\hyperlink{gotext}{}};
  \draw (A) -- (B);    % The edge I want to click on to navigate.
\end{tikzpicture}

\newpage
\section{Second section}
\label{sec:mysection}

Corruption can occur on different scales. There is corruption that occurs as small favours between a small number of people (petty corruption), corruption that affects the government on a large scale (grand corruption), and corruption that is so prevalent that it is part of the every day structure of society, including corruption as one of the symptoms of organized crime (systemic corruption).

Judicial corruption refers to corruption related misconduct of judges, through receiving or giving bribes, improper sentencing of convicted criminals, bias in the hearing and judgement of arguments and other such misconduct.

\hypertarget{gotext}{%
Governmental corruption} of judiciary is broadly known in many transitional and developing countries because the budget is almost completely controlled by the executive. The latter undermines the separation of powers, as it creates a critical financial dependence of the judiciary. The proper national wealth distribution including the government spending on the judiciary is subject of the constitutional economics.

\newpage
empty page

\end{document}

enter image description here

Run the code, click yourself and testify ;)

share|improve this answer
1  
+1: genius solution! –  Claudio Fiandrino Apr 2 at 13:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.