2

This flowchart has given me nothing but pain and frustration. I've been trying to recreate it for a few days and not been able yet. I use the tikz package.

enter image description here

3
  • 1
    Welcome to TeX.SE! Since you tried something, could you post a minimal example of what you did so far?
    – CarLaTeX
    Nov 26 '21 at 8:47
  • Well my first attempt is using the node function while the second is using matrix. I don't really want to post my example as they cause 20 error messages.
    – Anon
    Nov 26 '21 at 8:52
  • 1
    You could try making a MWE, that way it's easier for others to help.
    – Jaap
    Nov 26 '21 at 9:05
6

A wee bit more advance solution :-).

With use of TikZ libraries arrows.meta, chains and positioning, the image code become very concise. Image elements styles are collected in tikzpicture options, but can be written in document preamble (or in document body) using \tikzset:

\documentclass[border=3.141592]{standalone}
%\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                positioning}
\begin{document}
    \begin{tikzpicture}[
node distance = 4mm and 2mm,
  start chain = A going below,
   arr/.style = {-Straight Barb},
   box/.style = {draw, text width=7em, align=center,
                 on chain, join=by arr}
                        ]
\node   [box]   {text 1};   % <--- node name: A-1
\node   [box]   {example of two lines long text};
\node   [box]   {text 3};
%
\node   (A-4)  [below right=of A-3] {text 4};
\draw[arr]  (A-3) |- (A-4);
    \end{tikzpicture}
\end{document}

enter image description here

5
  • How do you linebreak in text 4 using this method?
    – Anon
    Dec 27 '21 at 7:33
  • @Anon, it break automatically when it is longer than prescribed width of node (by text width). Now I see, that in code is older text in second node. I will correct this ASAP. I suggest you, to start reading some documentation about tikz. At least part III of TikZ & PGF manual and by this make yourself more familiar with it.
    – Zarko
    Dec 27 '21 at 7:45
  • But what about (A-4)? It doesn't have the [box] style.
    – Anon
    Dec 27 '21 at 9:59
  • @Anon, see package documentation: TikZ $ PGF manual for version 3.1.9a , chapter 13 Specifying Coordinates, pages 136 -- 152, specifically section 13.3.1 Intersections of Perpendicular Lines on page 144.
    – Zarko
    Dec 27 '21 at 10:22
  • @Anon, please analyze MWE. The analysis should clearly show you that the last node is offset from the penultimate node by the distance between the nodes- Arrow between them is defined by \draw[arr] (A-3) |- (A-4); where meaning of |- symbol is described in section 13.3.1 Intersections of Perpendicular Lines as I noted in the previous comment.
    – Zarko
    Dec 27 '21 at 10:33
6

Using tikz:

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\pagestyle{empty}


% Define block styles
\tikzset{block/.style={rectangle, draw, text width=5em, text centered, minimum height=4em}}
% Define line style
\tikzset{line/.style={draw, -latex'}}
    
\begin{tikzpicture}[node distance = 2cm, auto]
    \node [block] (bl1) {text 1};
    \node [block, below of=bl1, node distance=3cm] (bl2) {text 2};
    \node [block, below of=bl2, node distance=3cm] (bl3) {text 3};
    \node [below right of = bl3, node distance=3cm] (bl4) {text 4};
    % Draw edges
    \path [line] (bl1) -- (bl2);
    \path [line] (bl2) -- (bl3);
    \path [line] (bl3) |- (bl4);
\end{tikzpicture}


\end{document}

screenshot


Edit: carlatex's suggestion: replaced \tikzstyle command

3
  • 1
    Thank you! I hope you have a nice day!
    – Anon
    Nov 26 '21 at 9:05
  • Also how do you add this to the code for more flat boxes? \tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=none]
    – Anon
    Nov 26 '21 at 9:08
  • 1
    Try experimenting, with the code, in the \tikzstyle definition adjust the value for minimum height. Use the \node parameters to i.e. adjust the distance between the nodes.
    – Jaap
    Nov 26 '21 at 9:15
1

One of the advantages of plain TikZ is that beginners can guess the meaning of the code. Here is a simple way. The library arrows.meta provides a lot of arrow tips, see Section 16.5 Reference: Arrow Tips in the PGF Manual.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\usepackage[utf8]{vietnam}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[box/.style={draw,minimum width=4cm,minimum height=1.2cm},>=Straight Barb,font=\sffamily]
\def\a{2}
\path
(0,0)     node[box] (SNC) {Hạt giống SNC}       
(0,-\a)   node[box] (NC) {Hạt giống NC}
(0,-2*\a) node[box] (XN) {Hạt giống XN}
;
\draw[->] (SNC)--(NC);
\draw[->] (NC)--(XN);
\draw[->] (XN)|-+(1.5*\a,-\a/2) node[right]{Sản xuất đại trà};
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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