2

The "pdftooltip" command from the pdfcomment package requires rectangular trigger regions. This is problematic when annotating figures. Take for example:

\documentclass{article}
\usepackage{tikz}
\usepackage{pdfcomment}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}

\draw[fill=green] (0,0) -- (3,0) -- (1.5,3) -- cycle 
  let 
    \p1 = (current path bounding box.south west), 
    \p2 = (current path bounding box.north east) 
  innode at (current path bounding box) 
   {\pdftooltip{\rule{\dimexpr\x2-\x1\relax}{0pt}\rule{0pt}{\dimexpr\y2-\y1\relax}}%
  {Green}};

\draw[fill=blue] (3,0) -- (1.5,3) -- (3,3) -- cycle 
  let 
    \p1 = (current path bounding box.south west), 
    \p2 = (current path bounding box.north east) 
  innode at (current path bounding box) 
   {\pdftooltip{\rule{\dimexpr\x2-\x1\relax}{0pt}\rule{0pt}{\dimexpr\y2-\y1\relax}}%
  {Blue}};

\end{tikzpicture}
\end{document}

As the example describes two triangles, the tooltips overlap. This can lead to the situation that the user hovers over a triangle and gets the tooltip for the other triangle:

Hovering example

How can I use TikZ to compute something like an inner box for the current path and restrict the tooltip to be shown only when hovering over this inner box.

For example, computing the largest squares that still fit into the triangles and displaying the tooltips only when hovering over these squares would be suitable. In this way, all tooltips shown in Acrobat Reader at runtime are correct, and a good part of the triangles act as trigger regions to the tooltips.


The motivation for adding tooltips to figures is to enrich them in the PDFs with seldomly needed additional information that the reader can retrieve by hovering over the respective part of the figure (e.g., where the data points that are represented by the filled path actually come from when merging multiple data sets into a single figure).

marked as duplicate by Symbol 1, Stefan Pinnow, CarLaTeX, Mensch, Zarko tikz-pgf Apr 22 '17 at 21:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Cannot it be just a square of size 1cm centered at the center of triangle? – Symbol 1 Mar 12 '15 at 15:22
  • @Symbol1 In this example, that would be possible. In general, the paths can be much "smaller" though, so a uniform size isn't a good solution. For example, triangles with edge lengths of 10cm and 0.1cm can be in the same figure. – DCTLib Mar 12 '15 at 15:27

Browse other questions tagged or ask your own question.