4

Can someone reproduce the following in LateX:

enter image description here

I have looked extensively at various packages and techniques but none seem quite able to reproduce the desired behavior. I essentially wish to draw an arrow going from A to B with impunity: regardless of what is on the page (LateX tables, images, equations).

This is the MWE to generate the table and contents shown:

\documentclass{article}
\usepackage{array}
\usepackage{graphicx}
\usepackage{cellspace}

\begin{document} \begingroup \setlength\cellspacetoplimit{3pt} \setlength\cellspacebottomlimit{3pt} \begin{table}[h!] \begin{tabular}{| S{p{0.5\linewidth}} | S{p{0.7\linewidth}} |} \hline \begin{minipage}[t]{0.5\textwidth} \vspace{0pt} \includegraphics[width=0.7\linewidth]{gadget1a} \newline Set the leftmost control to equal the point 3 value \newline
\end{minipage}
& \begin{minipage}[t]{0.9\textwidth} \vspace{0pt} \includegraphics[width=0.75\linewidth]{gadget1b} \end{minipage} \ \hline \end{tabular} \end{table
} \endgroup

\end{document}

F. Pantigny
  • 40,250
  • I think the question is too open, but maybe here you find some kind of starting point – Jes Mar 14 '21 at 15:24
  • 1
    @R.Estevan -- since the images are not available the concept is outlined in the answer below-- use the images as two nodes separated by 2mm -- the arrow origin is selected 2pt above the south of nodeA and the exit angle -60 degrees -- the origin is also put in circle node which can be changed to ellipse etc -- the arrow style can also be changed to taste – js bibra Mar 14 '21 at 15:28
  • @jsbibra: Thanks for your input. You are correct. – R. Estevan Apr 20 '21 at 14:21

2 Answers2

5

You can use the tikzmark library to place things in arbitrary positions quite easily. In general you want to try to avoid having to calculate positions on the page directly, and the \tikzmark command allows you to place a node within any sort of text that can then be referred to in an overlayed tikzpicture. For arbitrary points on top of images, it's easiest to insert the image as a TikZ node using the \tikzmarknode command and then do absolute positioning manually with respect the actual image. Here's a version of your document (I copied the images from your sample, so the leftovers of your arrow remain.)

You must compile documents using TikZ [overlay, remember picture] twice to see the effects properly, so don't be alarmed if the fist compilation appears to place the overlaid material incorrectly.

\documentclass[]{article}
\usepackage{array}
\usepackage{graphicx}
\usepackage{cellspace}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}

\begin{document} \begingroup \setlength\cellspacetoplimit{3pt} \setlength\cellspacebottomlimit{3pt} \begin{table}[h!] \begin{tabular}{| S{p{0.5\linewidth}} | S{p{0.7\linewidth}} |} \hline \begin{minipage}[t]{0.5\textwidth} \vspace{0pt} \includegraphics[width=0.7\linewidth]{gadget1a} \newline Set the leftmost control to equal the point 3 \tikzmarknode[draw=red,very thick, inner sep=2pt]{value}{value} \newline
\end{minipage}
& \begin{minipage}[t]{0.9\textwidth} \vspace{0pt} \tikzmarknode{gadget1b}{\includegraphics[width=0.75\linewidth]{gadget1b}} \end{minipage} \ \hline \end{tabular} \end{table
} \endgroup \begin{tikzpicture}[remember picture,overlay] \node[draw=red,very thick,minimum width=.5in,minimum height=.15in] at ($(gadget1b.center)-(1in,.175in)$) (c) {}; \draw[->,red,very thick] (value.east) [in=-90,out=-10] to (c); \end{tikzpicture} \end{document}

output of code

Alan Munn
  • 218,180
  • Hooray for tikzmark! – Andrew Stacey Apr 14 '21 at 18:40
  • @AndrewStacey :) I had used my own version for quite while before I even became aware of yours. – Alan Munn Apr 14 '21 at 18:41
  • I do feel I've gotten quite a lot of mileage out of something that was, in origin, really quite a simple thing. Admittedly it has now morphed considerably as it has gained features so it is quite complex now and I feel slightly less guilty about promoting the tikzmark over all the other versions! – Andrew Stacey Apr 14 '21 at 20:17
  • Thank you @AlanMunn, I was able to reproduce your example and you have therefore solved the problem. The code you provided (+ explanation) makes clear what needs to be done. – R. Estevan Apr 20 '21 at 14:15
2

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning,
quotes, shapes}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[
node distance = 2mm,
image/.style = {scale=0.4,},
arr/.style = {-Triangle, semithick}
]
\node[image] (A) {\includegraphics[height=8in, width=3in]{example-image-a}};
\node[image,above right=of A] (B) {\includegraphics{example-image-b}};
\draw[blue, dashed, arr, ]
(A.south)++(0,16pt)node[red,circle,draw,inner sep=6pt]{} to[out=-60,in=-90, looseness=1.2]
(B.south)++(0,12pt)
;
\end{tikzpicture}
\caption{a caption}
\label{fig12}
\end{figure}
\end{document}
js bibra
  • 21,280
  • Thanks, js bibra, but in your example you are using an image as the point of departure and another image as the point of arrival. In my example, the arrow starts from actual text (with surrounding ellipse; it was all originally made in MS Word) and ends on a specific point in the target image.

    This is what I meant by saying "with impunity" because my understanding is that tikz works only with handles on nodes such as "north", "south", and so on. But not with arbitrary page coordinates as far as I can tell - or am I missing something?

    – R. Estevan Mar 14 '21 at 17:54