4

This code gives me the following figure.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{float}
\usepackage{subfig}
\usepackage{tikz}
\title{test}
\author{test}%
\date{January 2022}
\usepackage{graphicx}
\begin{document}
\begin{figure}
    \centering
    \subfloat{
    
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=\textwidth,trim={0 0 0 0},clip]{example-image-a}};
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
    \draw [-stealth, thick] (0.75,0.9) -- (0.75,-1);
    \end{scope}
\end{tikzpicture}}\\
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=\textwidth,trim={0 0 0 0},clip]{example-image-a}};   
\end{tikzpicture}}
    \caption{}
    \label{fig:ablation}
\end{figure}
\end{document}

enter image description here

I would like the arrow to be drawn over the other image instead of pushing it away like this

enter image description here

How can I declare tikzpicture over multiple tikzpictures?

1
  • 1
    look around page 260 of pgfmanual.pdf, remember picture and overlay key
    – user202729
    Aug 12 at 5:05

1 Answer 1

4

Here is a way with overlay:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{float}
\usepackage{subfig}

\title{test}
\author{test}%
\date{January 2022}
\usepackage{graphicx}
\begin{document}
\begin{figure}
    \centering
    \subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0pt] (image1) at (0,0) {\includegraphics[width=\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\\
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0pt] (image2) at (0,0) {\includegraphics[width=\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}
\begin{tikzpicture}[overlay,remember picture]
\begin{scope}
    \draw [-stealth, ultra thick,] ($(image1.east)+(-1.25,0)$)--($(image2.east)+(-1.25,0)$);
    \end{scope}
\end{tikzpicture}
    \caption{}
    \label{fig:ablation}
\end{figure}
\end{document}

Feel free to change the "shifts" to your preferred values

Output:

enter image description here

2
  • 1
    You will need a second compilation, Since overlay picture will find the real paths after the first compilation
    – koleygr
    Aug 12 at 5:20
  • thank you so very much. After spending so much time trying to understand the syntax I finally get it now!
    – Kong
    Aug 12 at 18:33

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.