You can specify which is the length
of the arrow in this way:
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(0,1.5)$);
where the length
is 1cm
.
Here is the revised example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) -- (6,0) -- (6,3) -- (0, 3) -- cycle;
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(0,1.5)$);
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(6,1.5)$);
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(3,3)$);
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(3,0)$);
\shade[shading=ball, ball color=black!90] (3,1.5) circle (0.25em);
\end{tikzpicture}
\end{document}
The result:
You can find more information on the calc
library on the documentation (13.5 Coordinate Calculations, pgfmanual version October 25, 2010).
A quickest implementation:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newlength\arrowlength
\setlength{\arrowlength}{1cm}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) -- (6,0) -- (6,3) -- (0, 3) -- cycle;
\foreach \destination in
{{0,1.5},{6,1.5},{3,3},{3,0}}
\draw[->, thick] (3,1.5) -- ($(3,1.5)!\arrowlength!(\destination)$);
\shade[shading=ball, ball color=black!90] (3,1.5) circle (0.25em);
\end{tikzpicture}
\end{document}
I don't really get the question so I hope this is what you wanted. If you include a full document (such that we copy paste and see the problem on our systems) things are much more easier.
Here, you can change the default setting within a scope but your block
style had a node distance
which was resetting every time it is issued. I've made it 2mm such that we can see the difference easier.
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,shapes.geometric,positioning}
\begin{document}
\begin{tikzpicture}[decision/.style={diamond, draw, text width=4.5em, text badly centered, node distance=3.5cm, inner sep=0pt},
block/.style ={rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em, minimum height=2em},
cloud/.style ={draw, ellipse, minimum height=2em},
line/.style ={draw,-latex'},
node distance = 1cm,
auto]
\node [block] (1st) {1st};
\node [block, right= of 1st] (2nd1) {2nd1};
\begin{scope}[node distance=2mm and 10mm]%Here we change it for everything inside this scope
\node [block, above= of 2nd1] (2nd2) {2nd2};
\node [block, below= of 2nd1] (2nd3) {2nd3};
\node [block, right= of 2nd1] (3rd1) {3rd1};
\node [block, above= of 3rd1] (3rd2) {3rd2};
\node [block, above= of 3rd2] (3rd3) {3rd3};
\end{scope}
\node [block, below= of 3rd1] (3rd4) {3rd4};
\node [block, below= of 3rd4] (3rd5) {3rd5};
\path [line] (1st) -- (2nd1);
\path [line] (2nd1) -- (2nd2);
\path [line] (2nd1) -- (2nd3);
\path [line] (2nd2) -- (3rd3);
\path [line] (2nd1) -- (3rd1);
\path [line] (1st) -- (2nd1);
\end{tikzpicture}
\end{document}
Best Answer
Here is a version that modifies the
to path
. So you need to replace--
byto
, and to apply the style, e.g.The
to path
is modified in such a way that a sloped arrow (from theshapes.arrows
library) is attached in the middle of the path.allow upside down
is used to avoid that TikZ intelligently rotates the arrows in a way that is appropriate for texts. I also would use symbolic coordinates, and the nodes can be placed in the centers of the triangles withbarycentric cs:
.