2

I have a series of images I want to make interactive. As an example let us say I have three images: a cat, a dog and a mouse.

I want have all three in a single figure in my document, but not shown simultaneously. In fact, I want the reader to be able to click on corresponding text to change the image. So: The same figure with clickable areas in the image - or text beneath. When clicked the image changes, like in the mockup below.

I know interactive videos, 3D models and questionnaires can be made using LaTeX. Can something like this also be done? I am guessing PDF layers and pgf/tikz might do it, but I am unsure as to how

Mockup

1
  • 1
    PDF Layers via pkg ocgx2 could be an option.
    – AlexG
    Commented Jul 15, 2022 at 12:54

1 Answer 1

4

This can be achieved with PDF Layers via package ocgx2. Note the use of the common option radiobtngrp to make the visibility of the grouped layers mutually exclusive.

\documentclass{article}

\usepackage{hyperref}
\usepackage{ocgx2}
\usepackage{graphicx}

\begin{document}
\begin{center}
  \makebox[0pt][l]{%
    \begin{ocg}[radiobtngrp=letters]{A}{A}{on}
      \includegraphics[width=\linewidth]{example-image-a}
    \end{ocg}
  }%
  \makebox[0pt][l]{%
    \begin{ocg}[radiobtngrp=letters]{B}{B}{off}
      \includegraphics[width=\linewidth]{example-image-b}
    \end{ocg}
  }%
  \begin{ocg}[radiobtngrp=letters]{C}{C}{off}
    \includegraphics[width=\linewidth]{example-image-c}
  \end{ocg}
  
  \showocg{A}{Letter ``A''}\quad
  \showocg{B}{Letter ``B''}\quad
  \showocg{C}{Letter ``C''}
\end{center}
\end{document}

You must log in to answer this question.

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