# How to draw a top to bottom block diagram (flowchart) using the schemabloc package

I looked at a few examples for drawing a flowchart and so I picked the schemabloc package. As I've worked with it, I've noticed, all the blocks are linked left to right or right to left. Although blocks can be positioned above or below the main line, the arrows still connect to them at the midpoints of their left or right edges.

My block diagram does not fit in that manner so I'd like to do a top to bottom block diagram. Is there anyway I can do that using schemabloc?

so i have as an example:

\documentclass{article}
\usepackage{graphicx,schemabloc}
\usetikzlibrary{circuits}

\begin{document}
\begin{figure}
\begin{tikzpicture}
\sbEntree{start}
\sbBloc{block}{Block}{start}
\sbRelier[input]{start}{block}
\sbSortie{end}{block}
\sbRelier[output]{block}{end}
\end{tikzpicture}
\end{figure}

\end{document}


and that's it. It compiles for me on the desktop.

-
Instead of posting code snippets, it is always best to compose a MWE including the \documentclass and the appropriate pacakges so that those trying to help don't have to recreate it. –  Peter Grill Nov 2 '11 at 21:00
I didn't know how to :) –  Eshwar Nov 2 '11 at 21:04
Just take what you have above, add the \documentclass{article}, or whatever one you are using, and the appropriate packages so that the given example compiles and results in the problem that you are seeing. –  Peter Grill Nov 2 '11 at 21:06
But that does not compile for me. Since the problem you describe is not related to that, please adjust the MWE so that it compiles. –  Peter Grill Nov 2 '11 at 21:11
Much better. It does not seem as if you need verbatim package for this example so you could remove that. –  Peter Grill Nov 2 '11 at 21:15

Since the documentation is only in french, I don't know the official way to adjust this, but here is a hack solution that produces better output:

\documentclass{article}
\usepackage{graphicx,schemabloc}
\usetikzlibrary{circuits}

\newcommand{\Spacing}{\phantom{ab}}%

\begin{document}
\begin{figure}
\begin{tikzpicture}
\sbEntree{start}
\sbBloc{block}{Block}{start}
\sbRelier[input\Spacing]{start}{block}
\sbSortie{end}{block}
\sbRelier[\Spacing output]{block}{end}
\end{tikzpicture}
\end{figure}
\end{document}

-
Thanks Peter! I did understand most of the document by guesswork but I need top to bottom to solve the problem unfortunately. Considering looking at the pgf manual for another solution completely. –  Eshwar Nov 3 '11 at 9:36

schemabloc was designed with control system block diagram representation in mind, where in fact you don't really have arrows coming out/pointing to the bottom top of the blocks (except for adders).

Unfortunately, this is why it is impossible to force the arrows in schemabloc to start from the bottom or top of the block, this is the way the package is implemented. You could either copy the code from the package source file and edit the copy to suit your needs (I think that with a decent knowledge of TikZ this is not such a big deal) or you can draw the diagram using blocks that line up vertically, but have the arrows sideways:

\documentclass{article}
\usepackage{graphicx,schemabloc}
\usetikzlibrary{circuits}

\begin{document}
\begin{tikzpicture}
\sbEntree{E}
\sbComp{comp}{E}
\sbRelier[$E_1$]{E}{comp}
\sbBloc{sys}{Systeme}{comp}
\sbRelier[u]{comp}{sys}
\sbSortie{S}{sys}
\sbRelier{sys}{S}
\sbDecaleNoeudy[4]{S}{U}
\sbBlocr{cap}{Capteur}{U}
\sbRelieryx{sys-S}{cap}
\sbDecaleNoeudy[8]{comp}{D}
\sbBlocL[6]{U}{Other}{D}
\sbSortie{S2}{U}
\sbRelier[$S_2$]{U}{S2}
\sbRelieryx{cap}{U}
\end{tikzpicture}
\end{document}


Which is probably not really what you want:

Note: The optional argument in \sbBlocL[6]{U}{Other}{D} is the length of the arrow preceding the block. Lengths in schemabloc are all given in em and there is no way to directly specify other units (according to the documentation).

-
Thanks Count! So tell me, using \node and \draw commands for tikz boxes and arrows, is there anyway the package will calculate the positioning automatically? –  Eshwar Nov 3 '11 at 9:37

Schémabloc the package allows for some vertical links but it takes a little "cheat" with the vertical positioning of the blocks.

this appropriate?

\documentclass{article}
\usepackage{tikz}
\usepackage{schemabloc}

\begin{document}
{\centering

\begin{tikzpicture}
\sbEntree{E}

\sbBlocL[5]{H1}{$H_1$}{E}
\sbBlocL{H2}{$H_2$}{H1}
\sbDecaleNoeudy[4]{H2}{H3}
\sbBloc[3]{H3}{$H_3$}{H3}
\sbRelierxy[aa]{H2}{H3}

\sbDecaleNoeudy[10]{H2}{H4}
\sbBloc[3]{H4}{$H_4$}{H4}
\sbRelier[bb]{H3}{H4}

\sbDecaleNoeudy[4]{H4}{H5}
\sbBloc[3]{H5}{$H_5$}{H5}
\sbRelieryx{H4}{H5}

\sbBlocL{H6}{$H_6$}{H5}

\end{tikzpicture}

}

\end{document}



-
Thanks for that! I decided against using schemabloc. I just used stock Tikz with polygons and that worked out much better for me :)! –  Eshwar Mar 14 '12 at 22:13