Tikz:流程图

%  此文件是liuchengtu.tex 因为在TikzEdt中可以实时看到结果。但不支持中文,
% 所以分两文件写,主文件用来编辑中文。
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri}
\begin{tikzpicture}[
%定义格式
%箭头的模式是latex 默认模式
>=latex,
%两个结点距离
node distance=5mm,
% hv path 表示一个结点到另一个结点是先水平再垂直。vh 相反。skip loop 表示
%垂直-水平-垂直 vskip loop 表示水平-垂直-水平
hv path/.style={to path={-| (\tikztotarget)}},
vh path/.style={to path={|- (\tikztotarget)}},
skip loop/.style={to path={-- ++(0,#1) -| (\tikztotarget)}},
vskip loop/.style={to path={-- ++(#1,0) |- (\tikztotarget)}},
%开始结束框模式
startend/.style={
draw,
rectangle,
rounded corners=2mm,
minimum size = 6mm,
thick
},
%输入输出模式
ioput/.style = {
draw,
trapezium,
trapezium left angle=60, trapezium right angle=120,
inner sep = 5pt
},
%处理框模式
 chuli/.style={
 draw,
rectangle,
minimum size=6mm,
thick,
font=\itshape
},
%判断模式
 panduan/.style={
 draw,
diamond,
minimum size=6mm,
shape aspect=3,
inner sep = 0.1pt,
thick,
font=\itshape
}
]
%----------------------------------模板----------------------------------------
%设置点及位置
%
%\node (a) [startend] {start};
%\node (b) [ioput,below = of a] {input integer l,m,n};
%\node (c) [panduan,below = of b,font=\small] {$l^2+m^2+n^2=0$};
%\node (d) [chuli,below = of c,yshift = 5pt,font=\small] {$y=70l+21m+15n$};
%\node (e) [panduan,below = of d,yshift=-10mm,font=\small] {$y>105$};
%\node (f) [ioput,below = of e] {output y};
%\node (g) [startend,below = of f] {end};
%
%\node (h) [chuli,below left = of d] {$y=105$};
%\node (i) [chuli,below right = of d,yshift=-5pt] {$y=y-105$};
%%画线
%\path     (a) edge[->]        (b)
%           (b) edge[->]        (c)
%        (c) edge[->]        (d)
%        (d) edge[->]        (e)
%        (e) edge[->]        (f)
%        (f) edge[->]        (g);
%
%\path    (h)    edge [<-,vh path]      (c);
%\path    (h)    edge [->,vh path]         ($(e.south)!0.5!(f.north)$);
%\path    (i)    edge [->,vh path]      ($(d.south)+(0,-2mm)$);
%\path    (i)    edge [<-,vh path]         (e);
%
%%写标签
%\node at (-2.1,-2.3) {是};
%\node at (0.45,-6.5) {否};
%-------------------------------------------------模板-------------------------------------------
\node (a) [startend] {开始};
\node (b) [chuli,below = of a] {$M=0,N=0,i=1$};
\node (c) [chuli,below = of b] {产生$0\sim1$之间的两个随机数分别赋给$x_i,y_i$};
\node (d) [panduan,below = of c ] {$x^2+y^2 \leq 1$};
\node (e) [chuli,below = of d] {$M=M+1$};
\node (f) [chuli,below = of e] {$i=i+1$};
\node (g) [panduan,below = of f ] {$i>1000$};
\node (h) [chuli,below = of g,minimum width = 2cm] {};
\node (i) [ioput,below = of h ]{输出P};
\node (j) [ioput,below = of i ]{结束};
\node (k)[chuli,right = of e] {$N = N+1$};
\path     (a) edge[->]        (b)
           (b) edge[->]        (c)
        (c) edge[->]        (d)
        (d) edge[->]        (e)
        (e) edge[->]        (f)
        (f) edge[->]        (g)
        (g) edge[->]        (h)
        (h) edge[->]        (i)
        (i) edge[->]        (j);
\path (g.west) edge [->,vskip loop=-3cm]         ($(b.south)!.5!(c.north)$);
\path (d) edge [->,hv path]         (k);
\path (k) edge [->,vh path]         ($(e)!.5!(f)$);


\node at (2,-3.35) {否};

\node at (0.35,-4.3) {是};
\node at (-1.55,-6.9) {否};
\end{tikzpicture}
\documentclass{ctexart}
\usepackage{tikz}
\usepackage[top=1in,bottom=1in,right=1in,left=1in]{geometry}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\usetikzlibrary{shapes,arrows,intersections,patterns}
\usetikzlibrary{calc}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri}

\begin{document}
\input{liuchengtu}
\end{document}

 

转载于:https://www.cnblogs.com/wangl393/p/3416859.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
传统的 LaTeX 流程图通常使用 TikZ 宏包来绘制。下面是一个简单的示例,展示了如何使用 LaTeX 绘制一个传统的流程图: 1. 首先,在 LaTeX 文档的导言区添加以下代码,以引入 TikZ 宏包: \usepackage{tikz} 2. 在文档中的适当位置,使用以下代码创建一个 TikZ 图形环境: \begin{tikzpicture} % 在这里添加流程图的绘制代码 \end{tikzpicture} 3. 在图形环境中,可以使用一系列的命令和选项来绘制流程图。例如,可以使用以下命令创建一个矩形框表示某个步骤: \node [rectangle, draw] (step1) {Step 1}; 其中,"rectangle" 表示矩形形状,"draw" 表示绘制边框,"step1" 是该节点的名称,"Step 1" 是节点内显示的文本。 4. 可以使用箭头连接不同的步骤。例如,可以使用以下命令创建一个箭头连接两个步骤: \draw [->] (step1) -- (step2); 其中,"->" 表示箭头的方向,"(step1)" 和 "(step2)" 是要连接的两个节点的名称。 5. 可以根据需要添加更多的步骤和连接,以构建完整的流程图。 下面是一个完整的示例代码,展示了一个简单的流程图: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node [rectangle, draw] (step1) {Step 1}; \node [rectangle, draw, below of=step1] (step2) {Step 2}; \node [rectangle, draw, below of=step2] (step3) {Step 3}; \draw [->] (step1) -- (step3); \end{tikzpicture} \end{document} 这个示例中,流程图包含三个步骤,每个步骤都是一个矩形框,通过箭头连接起来。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值