Simple block diagram

I have to ask for your help again. I am trying to produce a block diagram, a really simple one. Simple block diagram

So far I have gotten to this part:

\documentclass{article}  \usepackage[latin1]{inputenc} \usepackage{tikz} \usetikzlibrary{shapes,arrows}  %%%< \usepackage{verbatim} \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength\PreviewBorder{5pt}% %%%> \begin{document} \pagestyle{empty} % Define block styles \tikzstyle{answer} = [rectangle, draw, text width=15em, text badly centered, node distance=1cm, inner sep=0pt, minimum height=4em] \tikzstyle{block} = [rectangle, draw, text width=30em, text centered, rounded corners, minimum height=4em] \tikzstyle{line} = [draw, -latex']  \begin{tikzpicture}[node distance = 2cm, auto] % Place nodes \node [block] (development) {text}; \node [block, below of=development] (quantitive) {text}; \node [block, below of=quantitive] (significances) {text}; \node [block, below of=significances] (utility) {text}; \node [block, below of=utility] (optimization) {text}; \node [block, below of=optimization] (decide) {text?};\\ \matrix [column sep=2mm,row sep=3mm] {\node [answer, below of=decide, node distance=1cm] (answerno) {text}; & \node [answer, below of=decide, node distance=1cm] (answeryes) {text};\\}; % Draw edges \path [line] (development) -- (quantitive); \path [line] (quantitive) -- (significances); \path [line] (significances) -- (utility); \path [line] (utility) -- (optimization); \path [line] (optimization) -- (decide); \path [line] (decide) -- node {No} (answerno); \path [line] (decide) -- node {Yes} (answeryes); \path [line] (answerno) -- (development); \end{tikzpicture}  \end{document} 

And it produces a nasty view. Is there even an option to have two arrows like that? Or will I have to rethink the diagram design. Appreciate any suggestions. sleeping

Replay

Some quick improvements:

  • \tikzstyle is obsolete, use \tikzset instead. See my code to see how to use it.
  • Although arrows is still supported, it's deprecated. You can use it if you prefer, but arrows.meta is the current library.
  • The library positioning should be used, changing from below of=..., to below =of....
  • The standalone class is very useful for showing small examples.
  • \path[draw] is equivalent to \draw, the second means less typing and neater code, though.

Output

Simple block diagram

Code

\documentclass[margin=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes, arrows.meta}

\tikzset{
    answer/.style={rectangle, draw, text width=15em, text badly centered, node distance=1cm, inner sep=0pt, minimum height=4em},
    block/.style={rectangle, draw, text width=30em, text centered, rounded corners, minimum height=4em},
    line/.style={-{Stealth}}
}

\begin{document}
\begin{tikzpicture}[node distance = 5mm, auto]
% Place nodes
\node [block] (development) {text};
\node [block, below =of development] (quantitive) {text};
\node [block, below =of quantitive] (significances) {text};
\node [block, below =of significances] (utility) {text};
\node [block, below =of utility] (optimization) {text};
\node [block, below =of optimization] (decide) {text?};

\node [answer, below =of decide.south west, anchor=north west] (answerno) {text};
\node [answer, below =of decide.south east, anchor=north east] (answeryes) {text};
% Draw edges
\draw[line] (development) -- (quantitive);
\draw[line] (quantitive) -- (significances);
\draw[line] (significances) -- (utility);
\draw[line] (utility) -- (optimization);
\draw[line] (optimization) -- (decide);
\draw[{Stealth}-] (answerno) -- (answerno|-decide.south) node[right, midway] {No};
\draw[{Stealth}-] (answeryes) -- (answeryes|-decide.south) node[right, midway] {Yes};
\draw[line] (answerno.west) -- ++ (-2,0) |- (development.west);
\end{tikzpicture}
\end{document}

This gets everything onto a single page.

My follow-up question:

How do I know how tall I can make the tikz grid in the right-column? And how would I know? There are 28 rows in that grid now, but if I add one more, the document spreads across two pages. Why? There appears to be plenty of vertical space for more rows.

Thanks!

\documentclass{article}

\usepackage[left=1.75cm,right=1.75cm,top=2cm,bottom=2cm]{geometry}

\usepackage{tabularx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage{tikz}

\begin{document}

\begin{tabularx}{18cm}{C{5cm}Y}

\begin{tikzpicture}[scale=0.4]
 \node at (0,0) {2 \tikz[baseline=-0.3cm]{\draw (0,-0.1) circle (0.5cm);} \(\frac{5}{3}\)};
\end{tikzpicture}

\vspace{4cm}

\begin{tikzpicture}
 \node at (0,0) {\(\frac{2}{3}\) \tikz[baseline=-0.3cm]{\draw (0,-0.1) circle (0.5cm);} \(\frac{9}{10}\)};
\end{tikzpicture}

\vspace{4cm}

\begin{tikzpicture}
 \node at (0,0) {\(1\frac{1}{4}\) \tikz[baseline=-0.3cm]{\draw (0,-0.1) circle (0.5cm);} \(\frac{5}{4}\)};
\end{tikzpicture}

\vspace{4cm}

&

\begin{flushleft}
\begin{tikzpicture}[scale=0.6]
 \draw[help lines, thin][gray] (0,0) grid (12,28);
\end{tikzpicture}
\end{flushleft}

\end{tabularx}

\end{document}

Category: diagrams Time: 2016-07-29 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.195 (s). 12 q(s)