Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to fit these to flowcharts in one page. This is what I got so far, not so nicely done I think. Any suggestions how I can get the flowcharts at the top of the page, nicely next to each other with own captions?

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,shapes.multipart}
\usetikzlibrary{calc}
\usepackage{graphicx}


\begin{document}

\tikzset{
offpageconnector/.style = {draw (1,0) -- (0,1) -- (-1,0) -- (0,-1) -- cycle, fill=orange!20},
decision/.style = {diamond, draw, fill=orange!20, 
  text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt},
block/.style = {rectangle, draw, fill=blue!20, 
  text width=5em, text centered, minimum height=1cm},
terminator/.style = {rectangle, rounded corners, draw, fill=blue!20, 
  text width=5em, text centered, minimum height=1cm, node distance=3cm},
line/.style = {draw, -latex'},
cloud/.style = {draw, ellipse,fill=red!20, node distance=1.5cm,
  minimum height=2em},
subroutine/.style = {draw,rectangle split, rectangle split horizontal,
  rectangle split parts=3,minimum height=1cm,
  rectangle split part fill={green!50}},
connector/.style = {draw,circle,node distance=3cm,fill=purple!20},
data/.style = {draw, trapezium,trapezium left angle=70,trapezium right angle=-70,minimum height=1cm,node distance=3cm,fill=olive!20},
cloud/.style = {draw, ellipse,fill=red!20, node distance=3cm,
    minimum height=2em}}

\begin{figure}[!hbt]
   \begin{minipage}[b]{0.4\textwidth}

      \begin{center}
\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [cloud] (start) {Start};
    \node [block, below of=start,node distance=2cm] (init) {Init};
    \node [block, below of=init,node distance=2cm] (1ebyteop) {$1^{e}$ byte ophalen};
    \node [decision,below of=1ebyteop,node distance=2cm] (contreof) {EOF?};
    \node [terminator, right of=contreof] (end1) {END};
    \node [block, below of=contreof] (2ebyteop) {$2^{e}$ byte ophalen};
    \node [decision,below of=2ebyteop,node distance=2cm] (contreof2) {EOF?};
    \node [terminator, right of=contreof2] (end2) {END};
    \node [subroutine, below of=contreof2, node distance=2cm] (sub1) {\nodepart{two} SUB1};
    \node [subroutine, below of=sub1, node distance=2cm] (sub2) {\nodepart{two} SUB2};



    % Draw edges
    \path [line] (start) -- (init);
    \path [line] (init) -- (1ebyteop);
    \path [line] (1ebyteop) -- (contreof);
    \path [line] (contreof) -- node {yes} (end1);
    \path [line] (contreof) -- node {no}(2ebyteop);
    \path [line] (2ebyteop) -- (contreof2);
    \path [line] (contreof2) -- node {yes} (end2);
    \path [line] (contreof2) -- node {no}(sub1);
    \path [line] (sub1) -- (sub2);
    \path [line] (sub2) |- ($(sub2.south west) - (0.7,0.7)$) |- (1ebyteop);

\end{tikzpicture}
\end{center}
      \caption{Flow1}
      \label{fig:flow1}
   \end{minipage}
   \hfill
   \begin{minipage}[b]{0.4\textwidth}

\noindent\resizebox{0.25\textheight}{!}{
\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [connector,text width=1cm] (letter) {LET};
    \node [subroutine, below of=letter, node distance=2cm] (sub31) {\nodepart{two} SUB3};
    \node [decision,below of=sub31,node distance=2cm] (@) {@?};
    \node [connector, right of=@,text width=1cm] (fout1) {FOUT};
    \node [subroutine, below of=@, node distance=2cm] (sub32) {\nodepart{two} SUB3};
    \node [decision,below of=sub32,node distance=2cm] (leesteken) {Leesteken?};
    \node [connector, right of=leesteken,text width=1cm] (fout2) {FOUT};
    \node [subroutine, below of=leesteken, node distance=2cm] (sub33) {\nodepart{two} SUB3};
    \node [decision,below of=sub33,node distance=2cm] (atotf) {A-F?};
    \node [connector, right of=atotf,text width=1cm] (fout3) {FOUT};
    \node [block, below of=atotf,node distance=2cm] (vorm0x0h) {In vorm 0x0H};
    \node [block, below of=vorm0x0h,node distance=2cm] (add09) {ADD 0x09};
    \node [decision,below of=add09,node distance=2cm] (1eof2e) {$1^e$ of $2^e$ byte?};
    \node [block, right of=1eof2e,node distance=3cm] (rotate) {4 maal rotate};
    \node [block, below of=1eof2e,node distance=2cm] (inr3) {A in R3};
    \node [block, below of=rotate,node distance=2cm] (inr2) {A in R2};
    \node [block, below of=inr3,node distance=2cm] (incr1) {INC R1};
    \node [decision,below of=incr1,node distance=2cm] (1eof2e2) {$1^e$ of $2^e$ byte?};
    \node [connector, right of=1eof2e2,node distance=3cm,text width=1cm] (second) {SEC};
    \node [block, below of=1eof2e2,node distance=2cm] (ret) {RET};
    % Draw edges
    \path [line] (letter) -- (sub31);
    \path [line] (sub31) -- (@);
    \path [line] (@) -- node {yes} (fout1);
    \path [line] (@) -- node {no}(sub32);
    \path [line] (sub32) -- (leesteken);
    \path [line] (leesteken) -- node {yes} (fout2);
    \path [line] (leesteken) -- node {no}(sub33);
    \path [line] (sub33) -- (atotf);
    \path [line] (atotf) -- node {yes} (fout3);
    \path [line] (atotf) -- node {no}(vorm0x0h);
    \path [line] (vorm0x0h) -- (add09);
    \path [line] (add09) -- (1eof2e);
    \path [line] (1eof2e) -- node {1e} (rotate);
    \path [line] (1eof2e) -- node {2e}(inr3);
    \path [line] (rotate) -- (inr2);
    \path [line] (inr3) -- (incr1);
    \path [line] (incr1) -- (1eof2e2);
    \path [line] (add09) -- (1eof2e);
    \path [line] (inr2) |- ($(incr1.south east) - (1,0.1)$);
    \path [line] (1eof2e2) -- (ret);
    \path [line] (1eof2e2) -- (second);

\end{tikzpicture}
}     
      \caption{Flow2}
      \label{fig:flow2}
   \end{minipage}
\end{figure}    


\end{document}
share|improve this question
    
[!hbt] do you intend to prevent this float going on a float page and force it on to a page that contains text? The main effect of that optional argument is to have that effect as it removes p which would be allowed by default. –  David Carlisle Oct 23 '12 at 19:15
    
My final goal is indeed force it on to a page that contains text as well. And I don't understand your second sentence though. –  Jasper Lammens Oct 23 '12 at 19:22
    
normally latex tries to position floats in the top bottom or here areas of text pages, or in float pages that just contain floats, [hbt] says to only allow hb and t so in particular it prevents latex making float pages (except for the emergency operation at clearpage or end{document} when all pending floats are dumped out. Not including p makes it vastly more likely that all floats go to the end of the document. –  David Carlisle Oct 23 '12 at 19:25
    
Yes I get that. But with every parameter, my charts are clamped at the bottom of my page. –  Jasper Lammens Oct 23 '12 at 19:32
    
The parameters are in fact ignored as the size of the diagram is too large to fit so it doesn't fit in any area so holds up all figures till end of document when it is just dumped out as an emergency recovery action. –  David Carlisle Oct 23 '12 at 19:37
add comment

1 Answer

You can move everything up eg

\begin{figure}[!hbpt]
\vspace{-2in}
   \begin{minipage}[b]{0.4\textwidth}\centering
\begin{tikzpicture}[node distance = 2cm, auto]
...

But the vertical size is greater than the distance betwen the physical top of the page and the page numbers, so you either need to use \thispagestyle{empty} to remove the page numbers or make the figure smaller by wrapping it in \resizebox or using tikz own scaling mechanisms.

Note I used \centering rather than \begin{center} as it takes less vertical space.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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