TransWikia.com

How to connect 3 images side by side with arrows that have wordings on them

TeX - LaTeX Asked by Shegs01 on August 11, 2020

I want to accomplish something like this:

enter image description here

The only thing I have being able to get done is to separate the 3 images without arrows. Please, see my sample code below. I really appreciate your help.

begin{figure}
centering
mbox{subfigure{includegraphics[width=0.8in]{ss.png}}quad
hspace{1.0in}%
subfigure{includegraphics[width=0.8in]{ser.png}
hspace{1.0in}%
subfigure{includegraphics[width=0.8in]{ss.png} }}}
caption{Text pertaining to both graphs ...} label{fig12}
end{figure}

2 Answers

With use relative positioning of nodes and the quotes library for text on arrows:

documentclass{article}
usepackage{tikz}
usetikzlibrary{arrows.meta, 
                positioning,
                quotes}
usepackage{graphicx}

begin{document}
    begin{figure}
    centering
    setkeys{Gin}{height=20mm, width=linewidth}
begin{tikzpicture}[
node distance = 2mm and 44mm,
image/.style = {text width=10mm, inner ysep=0pt},   % style for images
  num/.style = {font=small, text=blue},            % blue numbers
every edge quotes/.style= {auto, font=small},
  arr/.style = {-Triangle, semithick}
                   ]
node[image, label=Caller (R)]  (A) {includegraphics{example-image-a}};
node[image, label=Server (S),
      right=of A]               (B) {includegraphics{example-image-b}};
node[image, label=Calee (E),
      right=of B]               (C) {includegraphics{example-image-c}};
%
    begin{scope}[node distance = 2mm and 0mm,
                  nodes=num]  
node[below right=of A.north east]  (1) {$(1)$};
node[above right=of A.south east]  (3) {$(3)$};
node[right=of B.east]              (2) {$(2)$};
    end{scope}
%
draw[arr] (1) to ["Call Ph. Num(E)"]       (1 -| B.west);
draw[arr] (3 -| B.west) to ["$Ein$ AuthentiCall Users" ']  (3);
draw[arr] (2) to ["Incoming call from R"]  (C.west);
%
draw[blue, dashed, arr]
    ([yshift=-2mm] A.south)
        node[below right, text=black] {textit{ID(R), PhNum(R), dots}} --
    ([yshift=-2mm] C.south)
        node[below  left, text=black] {textit{ID(E), PhNum(E), dots}};
end{tikzpicture}
    caption{Text pertaining to both graphs ...} 
label{fig12}
    end{figure}
end{document}

enter image description here

Correct answer by Zarko on August 11, 2020

Perhaps something like this:

enter image description here

This is done using the code:

documentclass{article}
usepackage{tikz}
usetikzlibrary{arrows.meta,calc}
usepackage{mwe}
begin{document}

begin{figure}
  centering
  begin{tikzpicture}[image/.style={minimum width=0.8in}, % style for images
                      num/.style={blue, font=small},     % blue numbers
                      >=LaTeX
    ]
    node[image] (A) at (0,0){includegraphics[width=0.8in]{example-image-a}};
    node[image] (B) at (2.5in,0){includegraphics[width=0.8in]{example-image-b}};
    node[image] (C) at (5in,0){includegraphics[width=0.8in]{example-image-c}};
    node[num] (1) at ($ (0.2,0)+(A.north east) $) {$(1)$};
    node[num] (2) at ($ (0.2,0)+(B.east)       $) {$(2)$};
    node[num] (3) at ($ (0.2,0)+(A.south east) $) {$(3)$};
    draw[->](1)--node[above]{Call Ph. Num(E)}(B.north west);
    draw[<-](3)--node[above]{$Ein$ AuthentiCall Users}(B.south west);
    draw[->](2)--node[above]{Incoming call from R}(C.west);
  end{tikzpicture}
  caption{Text pertaining to both graphs ...} label{fig12}
end{figure}

end{document}

As far as I can see the subfigure environments are not necessary. If the the same idea would work with overlay specifications.

Answered by Andrew on August 11, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP