1

I would like to be able to click inside a (white) box in an image like: enter image description here and then jump to the description of that function. I tried:

\documentclass[twoside]{book}

\usepackage{float}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}

\usepackage{ifpdf}
\ifpdf
  \usepackage[pdftex,pagebackref=true]{hyperref}
\else
  \usepackage[ps2pdf,pagebackref=true]{hyperref}
\fi
\hypersetup{%
  colorlinks=true,%
  linkcolor=blue,%
  citecolor=blue,%
  unicode%
}

\begin{document}

\hypersetup{pageanchor=false,
             bookmarksnumbered=true,
             pdfencoding=unicode
            }

\section{\texorpdfstring{fie1()}{fie1()}}

References \mbox{\hyperlink{aa_8h_af60813d22831048d88007bf793ba9df2}{fie2}} ().

Here is the call graph for this function:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=180pt]{aa_8h_a321294a1af6610f2dc1563ebee9cdfbe_cgraph}
\end{center}
\end{figure}
\section{\texorpdfstring{fie2()}{fie2()}}

\end{document}

with the include image based on (the .dot file):

digraph "fie1"
{
 // INTERACTIVE_SVG=YES
  edge [fontname="Helvetica",fontsize="10",labelfontname="Helvetica",labelfontsize="10"];
  node [fontname="Helvetica",fontsize="10",shape=record];
  rankdir="LR";
  Node0 [label="fie1",height=0.2,width=0.4,color="black", fillcolor="grey75", style="filled", fontcolor="black"];
  Node0 -> Node1 [color="midnightblue",fontsize="10",style="solid"];
  Node1 [label="fie2",height=0.2,width=0.4,color="black", fillcolor="white", style="filled",URL="$aa_8h.html#af60813d22831048d88007bf793ba9df2"];
}

but this leads not to a clickable situation. I also tried with svg (after installing Inkscape):

\documentclass[twoside]{book}

\usepackage{float}
\usepackage{svg}
\usepackage[utf8]{inputenc}

\usepackage{ifpdf}
\ifpdf
  \usepackage[pdftex,pagebackref=true]{hyperref}
\else
  \usepackage[ps2pdf,pagebackref=true]{hyperref}
\fi
\hypersetup{%
  colorlinks=true,%
  linkcolor=blue,%
  citecolor=blue,%
  unicode%
}

\begin{document}

\hypersetup{pageanchor=false,
             bookmarksnumbered=true,
             pdfencoding=unicode
            }

\section{\texorpdfstring{fie1()}{fie1()}}

References \mbox{\hyperlink{aa_8h_af60813d22831048d88007bf793ba9df2}{fie2}} ().

Here is the call graph for this function:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includesvg{aa_8h_a321294a1af6610f2dc1563ebee9cdfbe_cgraph}
\end{center}
\end{figure}
\section{\texorpdfstring{fie2()}{fie2()}}

\end{document}

with the necessary SVG file being:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
 -->
<!-- Title: fie1 Pages: 1 -->
<svg width="108pt" height="28pt"
 viewBox="0.00 0.00 108.00 28.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 24)">
<title>fie1</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-24 104,-24 104,4 -4,4"/>
<!-- Node0 -->
<g id="node1" class="node"><title>Node0</title>
<polygon fill="#bfbfbf" stroke="black" points="0,-0.5 0,-19.5 32,-19.5 32,-0.5 0,-0.5"/>
<text text-anchor="middle" x="16" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">fie1</text>
</g>
<!-- Node1 -->
<g id="node2" class="node"><title>Node1</title>
<g id="a_node2"><a xlink:href="aa_8h.html#af60813d22831048d88007bf793ba9df2" target="_top" xlink:title="fie2">
<polygon fill="white" stroke="black" points="68,-0.5 68,-19.5 100,-19.5 100,-0.5 68,-0.5"/>
<text text-anchor="middle" x="84" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">fie2</text>
</a>
</g>
</g>
<!-- Node0&#45;&gt;Node1 -->
<g id="edge1" class="edge"><title>Node0&#45;&gt;Node1</title>
<path fill="none" stroke="midnightblue" d="M32.3076,-10C39.8047,-10 49.0314,-10 57.5491,-10"/>
<polygon fill="midnightblue" stroke="midnightblue" points="57.7754,-13.5001 67.7754,-10 57.7754,-6.5001 57.7754,-13.5001"/>
</g>
</g>
</svg>

but unfortunately also without result.

There is a restriction that the image cannot be draw by hand as it is automatically generated and a document can have quite a few of these type of images that also change when the underlying code changes. It is, probably, possible to modify the generating code.

Any ideas?

8
  • Couldn't you generate TikZ and not SVG? – Oleg Lobachev May 19 '18 at 15:01
  • Probably I can generate TikZ, but I have no experience with TikZ (but I can and I'm willing to learn it). The given picture is quite easy, but normally the pictures contain (many) more nodes and dot nicely arranges these, I don't know if this is automatically possible with TikZ. Any hints in this direction are very welcome. – albert May 19 '18 at 15:29
  • Well, if you generate TikZ, you don't need to know it. And the final assembly is easy, since TikZ is LaTeX. – Oleg Lobachev May 19 '18 at 15:53
  • Thanks. Just for my knowledge would it be possible to create something like the .dot file? Or how would the TikZ file / part look like analogous to the above .dot file (so I have a nice jump start)? – albert May 19 '18 at 15:58
  • I don't really get it with .dot file and have troubles directly converting you SVG to TikZ with github.com/paaguti/svg2tikz. – Oleg Lobachev May 19 '18 at 16:22
2

This is possible with pdf layers named ocg (Optional Content Groups). These are layers of the pdf file that can be displayed or hidden by a simple mouse click. Not all pdf readers support them, I know that Adobe reader, Evince or Foxit reader manage these ocg layers.

There are several packages that allow to use them: ocg, ocg-p, ocgtools, ocgx and ocgx2.

The most complete manual and examples are the ocgx package available here: ocgx-manual A beautiful demo of ocgx package is here: demo-ocgx

I didn't quite understand your request and maybe I didn't do what you wanted.

In the following code, clicking on the rectangle fie2 changes the display of the rectangle fie1 and displays the word definition. It is of course possible to do it differently, to display or not the arrow, etc..

I used tikz to draw and display rectangles, but you can also hide and display something else like text or an image.

In the following code, node (a) is a rectangle that displays the default word fie1. Node (b) is a fie2 rectangle containing a link that makes visible the layer I called fie1 displaying the word definition.

\documentclass{article}
\usepackage[tikz]{ocgx2}

\begin{document}
\begin{tikzpicture}
\node (a) at (0,0) [draw,very thick,rounded corners=1pt,minimum height=1cm,minimum width=2cm] {fie1};   
\node (b) at (4,0) [draw,very thick,rounded corners=1pt,minimum height=1cm,minimum width=2cm,switch ocg=fie1] {fie2};   
\path[->](a) edge [very thick,blue](b);

\begin{scope}[ocg={name=fie1,ref=fie1,status=invisible}]
\node (a) at (0,0) [draw,very thick,rounded corners=1pt,minimum height=1cm,minimum width=2cm,fill=white] {definition};
\end{scope}
\end{tikzpicture}

\end{document}

On the image below, the ocg layer fie1 is inactive and the message displayed is the default fie1.

inactive-ocg

On the image below, the ocg layer fie1 has been activated by clicking fie2 and now displays the word definition.

active-ocg

If I didn't understand your request correctly, say so.

Translated with www.DeepL.com/Translator

6
  • The idea is that when clicking on fie2 one jumps to another part in the pdf file / documentation where the function is described. – albert Aug 26 '18 at 16:45
  • @albert Is this part on the same page or on another page of the pdf? – AndréC Aug 26 '18 at 17:06
  • Both are possible, but I have an hypertarget (in the original SVG shown as: xlink:href="aa_8h.html#af60813d22831048d88007bf793ba9df2 for the LaTex document this target would be af60813d22831048d88007bf793ba9df2, I can influence this). – albert Aug 26 '18 at 17:35
  • @albert If the definition is on the same page, it is possible to display a tooltip with the packages fancytooltips, cooltooltips and maybe (I'm not sure of that) pdfcomment – AndréC Aug 26 '18 at 18:10
  • OK I will have to study those packages. – albert Aug 26 '18 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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