I am just starting to learn using Tikz and am a little lost within its seemingly infinite amount of options and possibilities.
What I am trying to do is visualize a few Matlab function interaction (which one calls which one, what is the in- and output). Since there are only about six subroutines, I place each one manually as a node. This is an example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\begin{document}
\begin{tikzpicture}[auto]
\node [rounded rectangle,draw] (node1) {Node 1};
\coordinate [above=of node1] (input);
\node [rounded rectangle,draw] at (-10:6cm) (node2) {Node 2};
\draw [->,very thick] ([xshift=0.1cm] input.south) --
node {right} ([xshift=0.1cm] node1.north);
\draw [->,very thick] ([xshift=-0.1cm] node1.north) --
node {left} ([xshift=-0.1cm] input.south);
\draw (node1) -- (node2);
\end{tikzpicture}
\end{document}
Now I would like to apply these double in/out arrows I (probably pretty awkwardly) created using xshift to all node connections, so in this example also for the connection between Node 1 and Node 2. Ideally, the space between these two arrows would be the same, independant of their angle and they would nicely connect to the outer line of the nodes.
Any idea how I could achieve this? Similar questions I have found only used rectangle and orthogonal lines.
Best Answer
A Minimal Code
Step by Step
Without lost of generality, assume arrows are pointing from left to right.
In
pgfcorearrows.code.tex
, Tikz shifts arrow tips using\pgf@arrow@drawer@shift
, defined asThis step is necessary because sometimes we have
shorten >=
orsep=
(in case there are more tips). But noy shift
is applied because logically arrow tips are aligned to the main path.So we have a dirty step which rewrites this macro as follows
Next we want to make
shear=
acts likesep=
. So I modified the code ofsep/.code
So now we can achieve the following by something like
[-{>[shear=0pt .5 .5]>[shear]>[shear=0pt .5 .5]>[shear]}]
Line Width Dependent
However,
\pgfarrowslinewidthdependent
will never produce the right amount ofy shift
. If you look at the manual carefully, it calculatesWhich is, equivalently
While what we want is
It leads to
I do not know why TikZ do so. Anyway, we can do it ourself.
For Convenience
We define
So we can have
Code