答案1
一个更先进的解决方案:-)。
使用 Ti钾Z 库arrows.meta
和chains
,positioning
图像代码变得非常简洁。图像元素样式收集在tikzpicture
选项中,但可以使用 写在文档前言(或文档正文)中\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}
答案2
使用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}
编辑:卡拉泰克斯的建议:替换\tikzstyle
命令
答案3
纯 TikZ 的一个优点是初学者可以猜出代码的含义。这里有一个简单的方法。该库arrows.meta
提供了很多箭头提示,请参阅第 16.5 节参考:箭头提示PGF 手册。
\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}