4

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}

enter image description here

3

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}

Result

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}

Result, shortened arrow line

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.