Graphics, Figures & TablesHow to increase the productivity, creating algorythm schemes

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
usr345
Posts: 37
Joined: Fri Apr 01, 2011 11:39 pm

How to increase the productivity, creating algorythm schemes

Post by usr345 »

I created an algorythm scheme. And had to write all the nodes and lines between them manually. Is it possible to increase the productivity? For example, 2 branches look similar. Is it possible to write a macro with parameters?

In Russian "да" = yes, "нет" = no

For those, who use leo editor I attached the leo file, cause structured text is better.
TikZ-scheme.png
TikZ-scheme.png (39.26 KiB) Viewed 1581 times

Code: Select all

\documentclass{article}
\usepackage[a4paper,landscape]{geometry}
\usepackage[cm]{fullpage}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,backgrounds,calc}
\begin{document}
\begin{tikzpicture}
\tikzset{
	pointer/.style={signal, signal to=east},
	mnemonic-block/.style={rectangle, anchor=west, inner sep=4mm},
}
\matrix[nodes={draw}, row  sep=5mm,
    column sep=2mm,minimum width=.875cm, minimum height=1cm]
{
	\node[pointer] {ОПУ}; & \node[mnemonic-block] {Общедомовой прибор учета}; \\
	\node[pointer] {ИПУ}; & \node[mnemonic-block] {Индивидуальный прибор учета}; \\
};
\end{tikzpicture}
\vspace{0.8cm}

\begin{tikzpicture}[node distance = 1.7cm, auto]
\tikzset{
	line/.style = {draw},
	block/.style = {rectangle, draw, text width=3em, text centered, rounded corners, minimum height=2em},
	comment/.style = {rectangle, draw, text centered, rounded corners, minimum height=2em,fill=white},
	question/.style = {shape=chamfered rectangle, chamfered rectangle xsep=2cm, draw},
	terminator/.style = {shape=rounded rectangle, draw, inner sep=2mm},
}

\node[terminator] (node-1) {\parbox{4.1cm}{Определение платы\\ за коммунальные услуги\\ в многоквартирном доме}};

\node [comment, below of=node-1, node distance = 2cm] (node-15) {В конце указаны пункты 307 ПП};

\begin{scope}[on background layer]
	\draw[fill=gray!10] ($(node-15.south west)+(-2mm,-2mm)$) rectangle ($(node-15.north east)+(2mm, 2mm)$);
\end{scope}

\path [line] (node-1) -- ($(node-15.north)+(0mm,+2mm)$);

\node [question, below of=node-15] (node-2) {ОПУ установлены?};

\path [line] ($(node-15.south)+(0mm,-2mm)$) -- (node-2);
\node [question, below of=node-2] (node-3) {ИПУ установлены?};
\node [block, below of=node-3] (node-4) {23};

\path [line] (node-3) -- node [near start] {да} (node-4);

\node [question, right of=node-4, node distance=4cm] (node-5) {Жилое помещение?};

\path [line] (node-3) -|  node [very near start] {нет} (node-5);

\node [block, below of=node-5] (node-6) {21};
\node [block, right of=node-6, node distance=3cm] (node-7) {20};

\path [line] (node-5) -- node [near start] {да} (node-6);
\path [line] (node-5) -| node [near start] {нет} (node-7);

\path [line] (node-2) -- node [near start] {да} (node-3);
\node [question, right of=node-3, node distance=10cm] (node-8) {ИПУ установлены?};
\node [block, below of=node-8] (node-9) {16};

\path [line] (node-8) -- node [near start] {да} (node-9);

\node [question, right of=node-9, node distance=4cm] (node-10) {Жилое помещение?};

\path [line] (node-8) -| node [very near start] {нет} (node-10);

\node [block, below of=node-10] (node-11) {19};
\node [block, right of=node-11, node distance=3cm] (node-12) {20};

\path [line] (node-10) -- node [near start] {да} (node-11);
\path [line] (node-10) -| node [near start] {нет} (node-12);

\path [line] (node-2) -| node [pos=0.03] {нет} (node-8);

\node[coordinate, below of=node-4, node distance=3.3cm] (node-13) {};

\path [line] (node-4) -- (node-13);
\path [line] (node-6) |- (node-13);
\path [line] (node-7) |- (node-13);
\path [line] (node-9) |- (node-13);
\path [line] (node-11) |- (node-13);
\path [line] (node-12) |- (node-13);

\node[terminator, below of=node-13, node distance=1.5cm] (node-14) {конец};

\path [line] (node-13) -- (node-14);

\end{tikzpicture}

\end{document}

Attachments
shag.zip
leo file in archive
(1.71 KiB) Downloaded 129 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply