I am creating a block diagram, and in it I want create two arrows in opposite direction. For that I created two nodes with an arrow from test 1
to below test 1
, but when I try to shift it in the x direction I get kind of broken result.
The green line starts is from center to center and the red line is from bottom to top but starts shifted but ends in the midpoint again.
Below my MWE:
\documentclass[tikz,margin=3mm]{standalone}
\usepackage[svgnames]{xcolor}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{arrows,arrows.meta, positioning}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{tikzpicture}
\tikzstyle{line} = [draw, thick, -latex',shorten >=5pt];
\node(T1) [rectangle, draw=red, fill=red!30, thick, minimum width=3cm, minimum height=2cm, text centered, rounded corners] {Test 1};
\node(T2) [below=of T1, rectangle, dashed, draw=red!80, fill=red!15, thick, minimum width=3cm, minimum height=2cm, text centered, rounded corners] {Below test 1};
\tikzstyle{every path}=[line]
% Arrows TC -> PR
\path [dashed] (T1) -- (T2);
\path [draw=green, dashed] (T1) ++ (0.5,0) -- (T2) ++ (0.5,0);
\path [draw=red, dashed] (T1.south) ++ (0.5,0) -- (T2.north) ++ (0.5,0);
\end{tikzpicture}
\end{document}
I need just two vertical lines/arrows just a bit moved from north/south anchor but I'm unable to get it right.
Best Answer
See here: Should \tikzset or \tikzstyle be used to define TikZ styles? But if you need the styles only for this picture you even don't need
tikzset
, your could put your settings directly as an option of thetikzpicture
environment.Moreover,
arrows
library is deprecated.For the arrows positioning, I think the simplest way is to use
xshift
.I've also modified a bit the shortening because, in my opinion, it looks better this way:
shorten >=2pt, shorten <=2pt
.