How to make a horizontal flow diagram in latex like:
If posible i would like some colors in it.
Thank you
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communitySomething like this:
MWE:
\documentclass[border=3mm,tikz,preview]{standalone}
\usetikzlibrary{arrows.meta,chains}
\begin{document}
\begin{tikzpicture}[
> = {Latex[]},
start chain = going right,
node distance=7mm,
block/.style={shape=rectangle, draw,
inner sep=1mm, align=center,
minimum height=7mm,
join=by ->, on chain}]
%placing the blocks
\node[block] (n1) {Hydraulikstation};
\node[block] (n2) {Kontraventil};
\node[block] (n3) {Cointainer};
\node[block] (n4) {Oliefilter};
\node[block] (n5) {Proportional ventil};
%
\draw[->] (n5.south) -- + (0,-7mm) -| (n1.south);
\end{tikzpicture}%
\end{document}
Put any colour as you like:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,chains}
\begin{document}
\begin{tikzpicture}[
> = {Latex[]},
auto,
start chain = going right,
node distance=5mm,
block/.style={shape=rectangle, draw,top color=olive,bottom color=magenta,
inner sep=1mm, align=center,
minimum height=3em,
join=by ->, on chain}]
\node[block] (n1) {Hydraulikstation};
\node[block] (n2) {Kontraventil};
\node[block] (n3) {Container};
\node[block] (n4) {Oliefilter};
\node[block] (n5) {Proportinalventil};
\draw[->] (n5.south) -- ++(0,-4mm) -| (n1.south);
\end{tikzpicture}%
\end{document}
Edit: After reading of other (very nice and interesting answers) I recognize, that the coloring is one of wishes in questions ... :-). How to do this, I explained in other answers as well showed in Harish Kumar (thank youu!) hijack of this one. So I will add an example with shadows. In it I also slightly change TikZ (pre)settings: now the style of joins are defined separately, what enable more freedom in their design.
\begin{tikzpicture}[
> = {Triangle[]},
start chain = going right,
node distance = 7mm,
every join/.style = {->, very thick, gray},
block/.style={shape=rectangle, draw,
inner sep=1mm, align=center,
minimum height=7mm,
fill=white, drop shadow,
join, on chain}]
%placing the blocks
\node[block] (n1) {Hydraulikstation};
\node[block] (n2) {Kontraventil};
\node[block] (n3) {Cointainer};
\node[block] (n4) {Oliefilter};
\node[block] (n5) {Proportional ventil};
%
\draw[every join] (n5.south) -- + (0,-7mm) -| (n1.south);
\end{tikzpicture}%
\end{document}
With a small hack into the package code, it is possible to get arrows with the right direction:
\documentclass[border=10pt]{standalone}
\usepackage{smartdiagram}
\makeatletter
\NewDocumentCommand{\smartdiagramx}{r[] m}{%
\StrCut{#1}{:}\diagramtype\option
\IfStrEq{\diagramtype}{flow diagram}{% true-flow diagram
\begin{tikzpicture}[every node/.style={align=center,let hypenation}]
\foreach \smitem [count=\xi] in {#2} {\global\let\maxsmitem\xi}
\foreach \smitem [count=\xi] in {#2}{%
\edef\col{\@nameuse{color@\xi}}
\IfStrEq{\option}{horizontal}{% true-horizontal-flow diagram
\path let \n1 = {int(0-\xi)}, \n2={0+\xi*\sm@core@modulexsep} in
node[module,drop shadow] (module\xi) at +(\n2,0) {\smitem};
}{% false-horizontal-flow diagram
\path let \n1 = {int(0-\xi)}, \n2={0-\xi*\sm@core@moduleysep} in
node[module,drop shadow] (module\xi) at +(0,\n2) {\smitem};
}
}%
\foreach \smitem [count=\xi] in {#2}{%
\pgfmathtruncatemacro{\xj}{mod(\xi, \maxsmitem) + 1)}
\edef\col{\@nameuse{color@\xj}}
\ifnum\xi<\maxsmitem
\begin{pgfonlayer}{smart diagram arrow back}
\draw[diagram arrow type] (module\xi) -- (module\xj);
\end{pgfonlayer}
\fi
% last arrow - not display it in background - check if disabled
\ifbackarrowdisabled
\relax
\else
\ifnum\xi=\maxsmitem
\IfStrEq{\option}{horizontal}{% true-horizontal-flow diagram
\tikzset{square arrow/.style={
to path={-- ++(0,-\sm@core@backarrowdistance) -| (\tikztotarget)}
}
}
\begin{pgfonlayer}{smart diagram arrow back}
\draw[diagram arrow type, square arrow]
(module\xi.south) to (module\xj.south); % <==
\end{pgfonlayer}
}{% false-horizontal-flow diagram
\tikzset{square arrow/.style={
to path={-- ++(\sm@core@backarrowdistance,0) |- (\tikztotarget)}
}
}
\draw[diagram arrow type,square arrow]
(module\xj.east) to (module\xi);
}
\fi
\fi
}%
\end{tikzpicture}
}{}% end-flow diagram
}
\makeatother
\begin{document}
\smartdiagramset{set color list={darkgray!90, darkgray!70,gray!70,gray!50,gray!25},
arrow style=-latex,
uniform arrow color=true,
arrow color=gray,
module x sep=4.5,
back arrow distance=0.75,
arrow line width=2.5pt,
text width =3cm,
}
\smartdiagramx[flow diagram:horizontal]{Hydraulikstation,Kontraventil,
Cointainer,Oliefilter,Proportional ventil}
\end{document}
The result:
smartdiagram
is simpler to use, but TikZ is obviously more flexible because smartdiagram
is providing you with ready-made TikZ solutions and any recipe book limits your degrees of freedom by design.
For simple diagrams, smartdiagram
allows you to just list the elements and type of diagram you want. For example:
\documentclass{article}
\usepackage{smartdiagram}
\usesmartdiagramlibrary{additions}
\begin{document}
\smartdiagramset{back arrow disabled=true}
\smartdiagramadd[flow diagram:horizontal]{%
Thing 1, Thing 2, Thing 3, Thing 4, Thing 5
}{%
below of module1/,below of module2/,below of module3/,below of module4/,below of module5/
}
\smartdiagramconnect{<-}{module1/additional-module1.center}
\smartdiagramconnect{-,line cap=round}{additional-module1.center/additional-module5.center}
\smartdiagramconnect{-}{module5/additional-module5.center}
\end{document}
The colours, arrows etc. can be customised using the package's keys.
If you can have the arrow between the last and first thing above the diagram, it is simpler:
\documentclass{article}
\usepackage{smartdiagram}
\begin{document}
\smartdiagram[flow diagram:horizontal]{%
Thing 1, Thing 2, Thing 3, Thing 4, Thing 5
}
\end{document}
Again, colours and arrows can be customised to your liking.
EDIT Corrected the gappy arrow in the first version thanks to Harish Kumar's suggestion.
line cap=round
in \smartdiagramconnect{-,line cap=round}{additional-module1.center/additional-module5.center}
will make that connection well connected.