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.

Hi I'm new to the TikZ package (so I apologize if this is an easy question) and I'm having trouble with some formatting. Here's what I have so far:

    \documentclass{article}
    \usepackage[latin1]{inputenc}
    \usepackage{tikz}
    \usetikzlibrary{shapes,arrows}
    \usepackage{caption}

    \begin{document}

      \sffamily
      \footnotesize
      \begin{tikzpicture}[auto,
       block_full/.style ={rectangle, draw=black, thick, fill=white,
          text width=20em, text ragged, minimum height=4em, inner sep=6pt},
        block_left/.style ={rectangle, draw=black, thick, fill=white,
          text width=20em, text ragged, minimum height=4em, inner sep=6pt},
        block_noborder/.style ={rectangle, draw=none, thick, fill=none,
          text width=18em, text centered, minimum height=1em},
        block_assign/.style ={rectangle, draw=black, thick, fill=white,
          text width=12em, text centered, minimum height=3em, inner sep=6pt},
          line/.style ={draw, very thin, -latex', shorten >=0pt}]
        % outlining the flowchart using the PGF/TikZ matrix funtion

             \matrix [column sep=3mm,row sep=3mm] {
          % row 1
          \node [block_full] (presub) {Pre-Submission:\\ 
            -  \\
            -  \\
            - }; \\

          %  row 2
          \node [block_noborder] (input) {Input data};\\

          % row 3
          \node [block_full] (routine) {Routine Checks:\\ 
            -  \\
           -   };  \\

          %  row 4
                \node [block_noborder] (bad1) {Bad result}; 

          &  \node [block_noborder] (good1) {Good result}; \\

          % row 5
          \node [block_left] (influence) {Influence: \\
            -  \\
            -  \\ }; &      \\

          % row 6
          \node [block_left] (inliers) {Inliers:\\ 
          -  \\
          -  \\ }; &      \\

          % row 7
          \node [block_left] (multiple) {Multiple: \\
          -  \\
          -  \\ }; &      \\

          % row 8
          \node [block_left] (cat) {Categorical Variables:\\ 
            -  \\
            -  \\  }; &    \\

          %  row 9
          \node [block_noborder] (bad2) {Bad Result};
          & ;     \node [block_noborder] (good2) {Good Result}; \\                

         % row 10
             \node [block_left] (digit) {Digits:\\ 
            -  \\
            -  \\  }; &    \\

        % row 11
           \node [block_assign] (concludeyes) {Conclude yes};
          & \node [block_assign] (concludeno) {Conclude no}; \\
        };% end matrix
      \end{tikzpicture}
    \end{document}

Which outputs this: enter image description here

I haven't added in the pathways yet, but I was wondering if there is a way to enlarge center the first two boxes but keep the two column branches below the Routine box?

I drew a little picture of what I'm envisioning for the final chart for clarity. enter image description here

share|improve this question

2 Answers 2

Using matrix as you did is a bit tricky. You could put two "auxiliar" nodes of appropiate sizes but without contents at the rows where you want the "big boxes" to appear, and then use fit library to create a node which fits those auxiliar nodes. I find this solution a bit clumsy.

Instead I propose a different approach. Do not use matrix, which has a rigid structure not very appropiate for this diagram, but positioning library to specify the position of each box relative to other previously drawn boxes.

This is my code:

\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{caption}

\begin{document}

\tikzset{
   block_full/.style ={rectangle, draw=black, thick, fill=white,
      text width=20em, text ragged, minimum height=4em, inner sep=6pt},
    block_left/.style ={rectangle, draw=black, thick, fill=white,
      text width=20em, text ragged, minimum height=4em, inner sep=6pt},
    block_noborder/.style ={rectangle, draw=none, thick, fill=none,
      text width=20em, text centered, minimum height=1em, inner sep=6pt},
    block_assign/.style ={rectangle, draw=black, thick, fill=white,
      text width=12em, text centered, minimum height=3em, inner sep=6pt},
      line/.style ={draw, very thin, -latex', shorten >=0pt},
}

\sffamily
\footnotesize
\begin{tikzpicture}[node distance=3mm]
  \node [block_full, text width=40em] (presub) {
    Pre-Submission:\\ 
    -  \\
    -  \\
    - }; 

  \node [block_noborder, below=of presub] (input) {Input data};

  \node [block_full, text width=40em, below=of input] (routine) {
    Routine Checks:\\ 
    -  \\
    - }; 

  \node [block_noborder, below=of routine.south west, anchor=north west] (bad1) {Bad result}; 
  \node [block_noborder, below=of routine.south east, anchor=north east] (good1) {Good result};

  \node [block_left, below=of bad1.south west, anchor=north west] (influence) {
    Influence: \\
    -  \\
    -  \\ }; 

  \node [block_left, below=of influence] (inliers) {
    Inliers:\\ 
    -  \\
    -  \\ }; 

  \node [block_left, below=of inliers] (multiple) {
    Multiple: \\
    -  \\
    -  \\ };

  \node [block_left, below=of multiple] (cat) {
    Categorical Variables:\\ 
    -  \\
    -  \\  };

  \node [block_noborder, below=of cat] (bad2) {Bad Result};
  \node [block_noborder] at (bad2-|good1) (good2) {Good Result}; 

  \node [block_left, below=of bad2] (digit) {
    Digits:\\ 
    -  \\
    -  \\  };

  \node [block_assign, below=of digit] (concludeyes) {Conclude yes};
  \node [block_assign ] at (concludeyes-|good2)(concludeno) {Conclude no};
\end{tikzpicture}
\end{document}

And this is the result:

Result

Note that for some of the nodes (good2 and concludeno), instead of specifying the position using the positioning syntax (which is below=of..., etc); I used the very convenient syntax at (foo-|bar) which means "at the intersection of a horizontal line passing through foo and a vertical one passing through bar".

Update

I added the connections:

  \draw[->] (presub) -- (input);
  \draw[->] (input) -- (routine);
  \draw[->] (routine.south-|bad1) -- (bad1);
  \draw[->] (routine.south-|good1) -- (good1);
  \xdef\prevnode{bad1}
  \foreach \n in {influence, inliers, multiple, cat, bad2, digit, concludeyes} {
      \draw[->] (\prevnode) -- (\n);
      \xdef\prevnode{\n}
  }
  \draw[->] (cat) -| (good2);
  \draw[->] (good2) -- (concludeno);

Result

share|improve this answer

I would be inclined to draw it as a tree. This means that only one connecting line needs to be added by hand and you can make the connections a little fancier if you wish.

This code uses forest. Note that I changed the fill of the block nodes just to keep track of what I was doing. (fill=white is hard to see when the background is white!)

Note that the arrows library is deprecated. See the tikz manual for details.

\documentclass{standalone}
\usepackage{forest}
\usetikzlibrary{arrows.meta}

\begin{document}

 \sffamily
 \footnotesize

\pgfkeys{/forest,
   noborder/.append style={draw=none, fill=none, text width=18em, text centered, minimum height=1em, align=center},
   assign/.append style={align=center, minimum height=3em, inner sep=6pt},
   full/.append style={text width=35em},
}
\begin{forest}
 for tree={
   font=\sffamily\footnotesize,
   draw,
   thick,
   fill=blue!10,
   align=left,
   text width=20em,
   minimum height=4em,
   inner sep=6pt,
   edge path={
     \noexpand\path[very thin, -{Latex[]}, \forestoption{edge}]
      (!u.parent anchor) -- +(0,-5pt) -| (.child anchor)\forestoption{edge label};
    },
   child anchor=north,
   parent anchor=south,
   l sep+=5pt,
 }
 [{Pre-Submission:\\---\\---\\---}, name=presub, full
   [Input Data, name=input, full, noborder
     [{Routine Checks:\\---\\---}, name=routine, full
       [Bad Result, name=bad1, noborder
         [{Influence:\\---\\---}, name=influence
           [{Inliers:\\---\\---}, name=inliers
             [{Multiple:\\---\\---}, name=multiple
                [{Categorical Variables:\\---\\---}, name=cat
                  [Bad Result, name=bad2, noborder, tier=result2
                    [{Digits:\\--\\--}, name=digit
                      [Conclude Yes, name=concludeyes, assign, tier=conclude]
                    ]
                  ]
               ]
             ]
           ]
         ]
       ]
       [Good Result, name=good1, noborder
          [,phantom%
            [Good Result, name=good2, noborder, tier=result2
              [Conclude No, name=concludeno, assign, tier=conclude]
            ]
          ]
       ]
     ]
   ]
 ]
 \draw [very thin, -{Latex[]}] (cat.east) -| (good2.north);
\end{forest}

\end{document}

Diagram as tree

share|improve this answer

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.