2

Please, consider the following mwe:

    \documentclass[tikz,border=5mm]{standalone}
    \usetikzlibrary{arrows,calc,chains,positioning,shapes.callouts}
\begin{document}
    \begin{tikzpicture}[
    every   pin/.style = {pin distance=9mm, pin edge={<-,solid,black,shorten <>=0mm}, 
                          text=blue},
     shorten <>/.style = {shorten >=#1, shorten <=#1},
           Line/.style = {line width=2.4mm, gray, -triangle 60, shorten <>=2mm},
    node distance=33mm,
    start chain = going below,    
                        ]
\node   (a) [draw,minimum width=44mm,on chain]    {node 1};
\node   (b) [draw,minimum width=44mm,on chain]    {node 2};
    \draw (a) -- (b);
    \draw[Line,transform canvas={xshift=7mm}] 
          (a) to node (c) [inner sep=0pt,text=white,pin=below  left:line 1] {1}   (b);
    \draw[Line,transform canvas={xshift=19mm}]
          (b) to node (d) [inner sep=0pt,text=white,pin=below right:line 2] {2}   (a);
\node[rectangle callout,draw,callout absolute pointer=(c.west),
      align=center, above left=3mm of c.west]  {note about\\   line num. 1};
\node[rectangle callout,draw,callout absolute pointer=(d.east),
      align=center, above right=3mm of d.east]  {note about\\   line num. 2};
      \end{tikzpicture}
\end{document}

Solution for line shift in mwe is taken from Shifting a line joining nodes in TikZ. I liked it because it enable me to shift number of lines in a scope.

I wonder, why nodes on lines are on right place, but using they names for anchor for another node gives (to me) unexpected results: like the nodes on shifted lines actually are on non-shifted line?

enter image description here

Zarko
  • 296,517

1 Answers1

4

Use scopes so the transform canvas correctly applies to all the necessary elements (the Line and the callout, in this case) and not just to the particular \draw:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,chains,positioning,shapes.callouts}

\begin{document}

\begin{tikzpicture}[
every   pin/.style = {
  pin distance=9mm,
  pin edge={<-,
    solid,black,
    shorten <>=0mm
    }, 
  text=blue
},
shorten <>/.style = {
  shorten >=#1,
  shorten <=#1
},
Line/.style = {
  line width=2.4mm, 
  gray,
  -triangle 60,
  shorten <>=2mm
},
node distance=33mm,
start chain = going below,    
]
\node (a) [draw,minimum width=44mm,on chain] {node 1};
\node (b) [draw,minimum width=44mm,on chain] {node 2};
\draw (a) -- (b);
\begin{scope}[transform canvas={xshift=7mm}]
  \draw[Line] 
    (a) to node (c) [inner sep=0pt,text=white,pin=below  left:line 1] {1}   (b);
  \node[rectangle callout,draw,callout absolute pointer=(c.west),
    align=center, above left=3mm of c.west]  {note about\\   line num. 1};
\end{scope}
\begin{scope}[transform canvas={xshift=19mm}]
  \draw[Line]
    (b) to node (d) [inner sep=0pt,text=white,pin=below right:line 2] {2}   (a);
  \node[rectangle callout,draw,callout absolute pointer=(d.east),
    align=center, above right=3mm of d.east]  {note about\\   line num. 2};
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128