My solution leads to:
The code to realize it is:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,fit}
\tikzset{box/.style={draw, rectangle, rounded corners, thick, node distance=7em, text width=6em, text centered, minimum height=3.5em}}
\tikzset{container/.style={draw, rectangle, dashed, inner sep=2em}}
\tikzset{line/.style={draw, thick, -latex'}}
\begin{document}
\begin{tikzpicture}[auto]
\node [box] (planning) {Planning};
\node [box, below of=planning] (resources) {Resources};
\node [box, below of=resources] (sensors) {Sensors};
\node [box, below of=sensors] (processing) {Processing};
\coordinate (middle) at ($(resources.west)!0.5!(sensors.west)$);
\node [box, left of=middle, node distance=10em] (archive) {Archive};
\node [box, left of=archive, node distance=10em] (reporting) {Reporting};
\node[container, fit=(resources) (sensors)] (or) {};
\node at (or.north west) [above right,node distance=0 and 0] {OR};
\node[container, fit=(archive) (reporting)] (his) {};
\node at (his.north west) [above right,node distance=0 and 0] {HIS};
\path [line] (planning) -- (resources);
\path [line] (resources) -- (sensors);
\path [line] (sensors) -- (processing);
\path [line] (archive) |- (planning);
\path [line] (archive) |- (processing);
\path [line] (processing)--($(processing.south)-(0,0.5)$) -| (reporting);
\draw [line] ($(processing.south)-(0,0.5)$) -- ++(4,0) node(lowerright){} |- (planning.east);
\draw [line] (lowerright |- or.east) -- (or.east -| resources.south east);
\draw[line] (archive.170)--(reporting.10);
\draw[line] (reporting.350)--(archive.190);
\end{tikzpicture}
\end{document}
Explanation
To shift down from the Reporting
to Processing
box I used this trick:
\path [line] (processing)--($(processing.south)-(0,0.5)$) -| (reporting);
to draw a line below the box using as reference its south
anchor. Of course ($(processing.south)-(0,0.5)$)
is the new reference also to connect the Planning
box to the Processing
one:
\draw [line] ($(processing.south)-(0,0.5)$) -- ++(4,0) node(lowerright){} |- (planning.east);
Notice that here I extended your ++(2,0)
to cope with the fact that the new starting position is in the middle of the box.
Finally, to draw connection lines between Reporting
and Archive
box I used definitions that you can find in the TikZ documentation 48.2 Predefined Shapes (rectangle).
The first thing to try is, of course, reducing the arrow lengths. If all else fails, use \mathclap
that, however, requires ampersand replacement
; or enclose the diagram in an lrbox
.
I'll show all three possibilities.
\documentclass[12pt,a4paper]{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\newsavebox{\wideeqbox}
\newcommand{\sample}{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate.}
\begin{document}
\sample
\[
\mathclap{
\begin{tikzcd}[ampersand replacement=\&]
\bullet \dar \rar \&
\bullet \dar \rar \&
\bullet \dar \rar \&
\bullet \dar \rar \&
\bullet \dar \rar \&
\bullet \dar \rar \&
\bullet \dar \rar \&
\bullet \dar \rar \&
\bullet \dar \rar \&
\bullet \dar \\
\bullet \rar \&
\bullet \rar \&
\bullet \rar \&
\bullet \rar \&
\bullet \rar \&
\bullet \rar \&
\bullet \rar \&
\bullet \rar \&
\bullet \rar \&
\bullet
\end{tikzcd}
}
\]
\sample
\[
\begin{lrbox}{\wideeqbox}
$\begin{tikzcd}
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \\
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet
\end{tikzcd}$
\end{lrbox}
\makebox[0pt]{\usebox{\wideeqbox}}
\]
\sample
\[
\begin{tikzcd}[column sep=2em,row sep=1.5em]
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \rar &
\bullet \dar \\
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet \rar &
\bullet
\end{tikzcd}
\]
\sample
\end{document}
The lrbox
solution can be packaged into an environment:
\newsavebox{\wideeqbox}
\newenvironment{wideeq}
{\begin{displaymath}\begin{lrbox}{\wideeqbox}$\displaystyle}
{$\end{lrbox}\makebox[0pt]{\usebox{\wideeqbox}}\end{displaymath}}
Then
text
\begin{wideeq}
\begin{tikzcd}
...
\end{tikzcd}
\end{wideeq}
text
will do. Any math mode material can be used.
Best Answer
This is an issue with curved arrows when they are very short. Two suggestions:
sep
so the nodes are farther apart.bend
angle. I usedbend right=15
in the diagram. (Then you'll probably want toshift
the arrow right also.)Here is the code: