1

I want to draw a picture like this:

enter image description here

I have tried, and got:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes.geometric}

\begin{document} \begin{tikzpicture}[node distance=10pt] \node[draw, rounded corners, align=center, fill=blue!20, fill opacity=0.6, minimum width=2cm,minimum height=1cm] (start) {\textbf{Firstly}\$A$};

\node[draw, below=of start, align=center, fill=blue!40, fill opacity=0.7, minimum width=3cm,minimum height=1cm] (step 1) {\textbf{Secondly}\$B$};

\node[draw, below=of step 1, align=center, fill=blue!40, fill opacity=0.7, minimum width=3cm,minimum height=1cm] (step 2) {\textbf{data}\$A+B$};

\node[draw, ellipse, right=30pt of step 2, align=center, fill=yellow!40, fill opacity=0.7] (step x1) {e};

\node[draw, below=of step 2, align=center, fill=blue!40, fill opacity=0.7, minimum width=3cm,minimum height=1cm]                        (step 3)   {\textbf{Finally}};

\node[draw, ellipse, right=30pt of step 3, align=center, fill=yellow!40, fill opacity=0.7, minimum width=2cm,minimum height=1cm] (step x2) {\textbf{e}};

\node[draw, rounded corners, fill=blue!40, fill opacity=0.7, below=20pt of step 3] (end) {End};

\draw[->] (start) -- (step 1); \draw[->] (step 1) -- (step 2); \draw[->] (step 2) -- (step 3); \draw[->] (step 3) -- (end); \draw[->] (step 1) -| (step x1); \draw[->] (step x1) -- (step 2); \draw[->] (step 2) -| (step x2); \draw[->] (step x2) -- (step 3); \end{tikzpicture} \end{document}

How to handle the split and the curving arrow? enter image description here

karry
  • 137

1 Answers1

1

Like this?

enter image description here

By use of the tikz libraries, arrows.meta, calc,
chains, ext.paths.ortho, positioning and shapes.geometric:

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                calc, chains,
                ext.paths.ortho,    % defined in the tikz-ext package
                positioning, 
                shapes.geometric}

\begin{document} \begin{tikzpicture}[ node distance = 8mm and 6mm, start chain = going below, arr/.style = {-Stealth}, M/.style = {draw, fill=blue!40, minimum height=1cm, text width=1.2cm, align=center}, N/.style args = {#1/#2}{draw, fill=#1, minimum height=1cm, text width=#2, align=center, on chain, join=by arr}, N/.default = blue!40/3cm, E/.style = {ellipse, draw, fill=yellow!40, inner xsep= 0pt, minimum width=1cm, align=center} ] \node[N=blue!20/2cm, rounded corners] (start) {\textbf{Firstly}\$A$}; \node[N] (step 1) {\textbf{Secondly}\ $B$}; \node[N] (step 2) {\textbf{data}\ $A+B$}; \node[N] (step 3) {\textbf{Finally}}; % \node[E, right=of $(step 1.east)!0.5!(step 2.east)$] (step e) {e}; \node[E, right=of $(step 2.east)!0.5!(step 3.east)$] (step f) {f}; % \node[M, below right=8mm and 0mm of step 3.south west] (c) {$C$}; \node[M, below left=8mm and 0mm of step 3.south east] (d) {$D$}; % arrows not considered in join macro \draw[arr] (step 1.east) to[bend left] (step e); \draw[arr] (step e) to[bend left] ([yshift=+2mm] step 2.east); \draw[arr] ([yshift=-2mm] step 2.east) to[bend left] (step f); \draw[arr] (step f) to[bend left] (step 3.east); % \draw[arr] (step 3) |-| (c); % <--- \draw[arr] (step 3) |-| (d); % <--- \end{tikzpicture} \end{document}

Zarko
  • 296,517
  • Should I download any package? Because it said:! Package tikz Error: I did not find the tikz library 'ext.paths.ortho'. I look ed for files named tikzlibraryext.paths.ortho.code.tex and pgflibraryext.paths. ortho.code.tex, but neither could be found in the current texmf trees.. – karry Oct 14 '23 at 07:11
  • 1
    @Mengr, apparently you not have installed tikz-ext package (see comment in my answer code). Install it by utility of your LaTeX distribution (at MiKTeX by MiKTeX Console). – Zarko Oct 14 '23 at 07:32
  • Thank you so much , all done! : ) – karry Oct 15 '23 at 05:41
  • How can I change the arc of curving arrow? and also I want to get the same color as the first picture. – karry Oct 15 '23 at 06:45
  • It seems that it is useless though I set the same size for the three matrices: "minimum width=3cm,minimum height=1cm". Why the matrix size changes as the text, so bad!! – karry Oct 15 '23 at 07:34
  • @Mengr, you can prescribe bending angle, for example as bend left=30, or use -| and |- syntax for arrows, for example \draw[arr, rounded corners] ([yshift=-1mm] step 2.east) -| (step f); \draw[arr, rounded corners] (step f) |- (step 3.east);. Sorry, I don't understand your last comment. I use the same size of flowchart black as you defined in your code example and don't see any bad in text in them. Please explain yours assertion. – Zarko Oct 15 '23 at 08:08
  • If I change the text size, like from {\textbf{data}\ $A+B$} to {\textbf{data}\ $A+B+C+D+E+F+G$}, then this matrix size is different with others. And the code "minimum width=3cm,minimum height=1cm" doesn't work. I hope the size of rectangle can be fixed. – karry Oct 15 '23 at 08:14
  • @Mengr, of course can be fixed, but first let clarify your comment: (i) my solution doesn't contain any matrix, but chain of nodes, (ii) rectangle nodes has defined text width, so their contents is automatically broken into several lines (as much as is needed), (iii) only nodes with ellipse shapes has defined minimum width (since their really content is unknown) . Test with \node[N] (step 2) {\textbf{data}\\ $A+B+C+D+E+F+G$}; gives nice result : node's content is in three lines. I suggest you to ask new question with link to my answer where you clearly explain what is your new problem. – Zarko Oct 15 '23 at 11:33