# shifting an arrow between two blocks up and down

I need to shift the arrow between two blocks up or down.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows}
\usepackage{graphicx}
\begin{document}

\noindent\resizebox{\textwidth}{!}{
\begin{tikzpicture}[auto,node distance=5cm,>=stealth']
\tikzset{
block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle, node distance=2cm},
input/.style  = {coordinate},
output/.style = {coordinate}}

\node [block] (A) {};
\node [block, right of=A] (B) {};
\draw [->] (A) -- node {} (B);

\end{tikzpicture}
}
\end{document}


The arrow can be moved by a canvas transformation:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows}
\usepackage{graphicx}
\begin{document}

\noindent\resizebox{\textwidth}{!}{%
\begin{tikzpicture}[auto,node distance=5cm,>=stealth']
\tikzset{
block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle, node distance=2cm},
input/.style  = {coordinate},
output/.style = {coordinate}}

\node [block] (A) {};
\node [block, right of=A] (B) {};
\begin{scope}[transform canvas={yshift=.7em}]
\draw [->] (A) -- node {} (B);
\end{scope}

\end{tikzpicture}%
}
\end{document}


The length of the arrow (or lines) can be modified by shorten < and shorten >:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows}
\usepackage{graphicx}
\begin{document}

\noindent\resizebox{\textwidth}{!}{%
\begin{tikzpicture}[auto,node distance=5cm,>=stealth']
\tikzset{
block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle, node distance=2cm},
input/.style  = {coordinate},
output/.style = {coordinate}}

\node [block] (A) {};
\node [block, right of=A] (B) {};
\begin{scope}[transform canvas={yshift=.7em}]
\draw [->, shorten <=5mm, shorten >=5mm] (A) -- node {} (B);
\end{scope}

\end{tikzpicture}%
}
\end{document}


Remark:

• Inside \resizebox TeX is in horizontal mode. Therefore spaces matter and the unwanted spaced by line ends need to be removed, e.g. by adding the comment character at the end of line.
• how to change the length as well? – CroCo Sep 15 '14 at 3:06
• Perfect. Thank you @Heiko Oberdiek so much. – CroCo Sep 15 '14 at 19:22