-
Notifications
You must be signed in to change notification settings - Fork 5
/
tikz-flowchart.dtx
1174 lines (1164 loc) · 46.3 KB
/
tikz-flowchart.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% Copyright (C) 2019 by Geng Nan <nangeng@nwsuaf.edu.cn>
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any later
% version. The latest version of this license is in:
%
% http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[2011/06/27]
%<package>\ProvidesPackage{tikz-flowchart}
%<package> [2019/08/20 v1.0.01 draw flowchart using TikZ]
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\RecordChanges
\usepackage[UTF8,scheme=chinese]{ctex}
\usepackage{csquotes}
\usepackage{lmodern}
\usepackage{hyperref}
\usepackage{url}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dtxdescribe}
\usepackage[debug]{tikz-flowchart}
\usepackage{float}
% \usepackage{parskip}
\renewcommand\figureautorefname\figurename
\renewcommand\tableautorefname\tablename
% default position for floats: H
\makeatletter
\renewcommand{\fps@figure}{H}
\renewcommand{\fps@table}{H}
\makeatother
%\setlength{\parindent}{0pt}
\def\thispkg{\pkg{tikz-flowchart}}
\def\tkz{Ti\emph{k}Z}
\newcommand{\note}[2][注意]{{%
\color{magenta}{\bfseries #1:}\emph{#2}}}
\makeatletter
\DeclareRobustCommand*\Arg[1]{\@meta{#1}}
\def\@meta#1{$\m@th\langle$\textnormal{\textit{#1}}$\m@th\rangle$}
\makeatother
\begin{document}
\DocInput{tikz-flowchart.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \changes{v1.0.01}{2019/08/20}{chang .sty file to .dtx file}
%
% \GetFileInfo{tikz-flowchart.sty}
%
% \title{\thispkg{}---\tkz{}流程图绘制宏包\thanks{该文档是 \thispkg{}~\fileversion, dated~\filedate 的说明文档。}}
% \author{耿楠\thanks{https://github.com/registor/tikz-flowchart}\\ 西北农林科技大学信息工程学院计算机科学系}
% \date{\filedate}
% \thispagestyle{empty}
% \maketitle
%
% \begin{abstract}
% 这是一个使用\tkz{}绘制传统程序流程图的简单宏包,通过定义
% \Arg{proc}、\Arg{test}、\Arg{io}、\Arg{term}等\tkz{}的
% \cs{node}命令的样式选项实现。
% 该宏包核心代码摘录自\href{http://www.texample.net/tikz/examples/author/brent-longborough/}{Brent Longborough}设计的流程图绘制样例,
% 参考了\pkg{tikz-imagelabels}宏包的设计思路,提供了\cs{flowchartset}命令以设置绘制参数。
% \end{abstract}
%
% \tableofcontents
%
% \PrintChanges
%
% \StopEventually{}
%
% \section{宏包简介}
%
% 流程图是诸如手册、报告、论文等文档中经常用到的排版元素,\thispkg{}宏包的
% 目的是为在\LaTeX{}中使用\tkz{}绘制流程图提供方便。\autoref{fig:forloop}是使
% 用该宏包绘制|for|循环结构流程图的一个简单示例。
%
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% \node [proc] (p1) {表达式1};
% \node [test, join] (t1) {表达式2?};
% \node [proc] (p2) {循环体};
% \node [proc, join] (p3) {表达式3};
%
% \node [coord, above = 0.5 of p1] (c1) {};
% \node [coord] (c2) at ($(p1)!0.35!(t1)$) {};
% \node [coord, below = 0.25 of p3] (c3) {};
% \node [coord, below = 0.2 of c3] (c4) {};
% \node [coord, below = 0.5 of c4] (c5) {};
% \node [coord, right = 0.5 of t1] (c6) {};
% \node [coord, left = 0.5 of t1] (ct) {};
% \node [coord] (c7) at (c3 -| ct) {};
%
% \path (t1.south) -- node [near start, right] {$Y$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.east) -- node [near start, above] {$N$} (c6);
% \draw [norm] (t1.east) -- (c6) |- (c4) -- (c5);
%
% \draw [norm] (c1) -- (p1);
% \draw [norm] (p3.south) |- (c7) |- (c2);
% \end{tikzpicture}
% \caption{for循环流程图}
% \label{fig:forloop}
% \end{figure}
%
% \autoref{fig:forloop}由如下代码绘制:
% \begin{sourceverb}
% \begin{tikzpicture}
% % 布置结点
% \node [proc] (p1) {表达式1};
% \node [test, join] (t1) {表达式2?};
% \node [proc] (p2) {循环体};
% \node [proc, join] (p3) {表达式3};
% % 布置用于连接的坐标结点。
% \node [coord, above = 0.5 of p1] (c1) {};
% \node [coord] (c2) at ($(p1)!0.35!(t1)$) {};
% \node [coord, below = 0.25 of p3] (c3) {};
% \node [coord, below = 0.2 of c3] (c4) {};
% \node [coord, below = 0.5 of c4] (c5) {};
% \node [coord, right = 0.5 of t1] (c6) {};
% \node [coord, left = 0.5 of t1] (ct) {};
% \node [coord] (c7) at (c3 -| ct) {};
% % 判断框连线,每次绘制时,先绘制一个带有一个固定
% % 位置标注的路径(path),然后再绘制箭头本身(arrow)。
% \path (t1.south) -- node [near start, right] {$Y$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.east) -- node [near start, above] {$N$} (c6);
% \draw [norm] (t1.east) -- (c6) |- (c4) -- (c5);
% % 其它连线
% \draw [norm] (c1) -- (p1);
% \draw [norm] (p3.south) |- (c7) |- (c2);
% \end{tikzpicture}
% \end{sourceverb}
%
% \note{所有绘图代码都需在\env{tikzpicture}环境中完成。}
% \section{使用方法}
% \subsection{载入宏包}
% \DescribeOption[\thispkg{}]{debug}
% 在导言区使用:\cs{usepackage}\oarg{debug}\marg{\thispkg{}}命令
% 载入宏包。如果带有\oarg{debug}参数,则可以绘制用于调试的流程线转角点
% 标记,否则,则不绘制该标记,\autoref{fig:forloopcmark}是带有
% \oarg{debug}参数时的绘制结果。
%
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% \node [proc] (p1) {表达式1};
% \node [test, join] (t1) {表达式2?};
% \node [proc] (p2) {循环体};
% \node [proc, join] (p3) {表达式3};
%
% \node [coord, above = 0.5 of p1] (c1) {}; \cmark{1}
% \node [coord] (c2) at ($(p1)!0.35!(t1)$) {}; \cmark{2}
% \node [coord, below = 0.25 of p3] (c3) {}; \cmark{3}
% \node [coord, below = 0.2 of c3] (c4) {}; \cmark{4}
% \node [coord, below = 0.5 of c4] (c5) {}; \cmark{5}
% \node [coord, right = 0.5 of t1] (c6) {}; \cmark{6}
% \node [coord, left = 0.5 of t1] (ct) {}; \cmark{t}
% \node [coord] (c7) at (c3 -| ct) {}; \cmark{7}
%
% \path (t1.south) -- node [near start, right] {$Y$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.east) -- node [near start, above] {$N$} (c6);
% \draw [norm] (t1.east) -- (c6) |- (c4) -- (c5);
%
% \draw [norm] (c1) -- (p1);
% \draw [norm] (p3.south) |- (c7) |- (c2);
% \end{tikzpicture}
% \caption{for循环流程图}
% \label{fig:forloopcmark}
% \end{figure}
%
% \subsection{流程图绘制样式}
% \thispkg{}宏包定义了在\tkz{}中绘制流程图的绘图样式参数,以简化绘图过程。
%
% \begin{description}
% \ItemDescribeArgument[\cs{node}]{proc}\cs{node}命令绘制顺序执行框
% 的样式,如:\tikz{\node[proc]{\scriptsize 交换两个整数}}
% \ItemDescribeArgument[\cs{node}]{test}\cs{node}命令绘制判断框的样
% 式,如:\tikz{\node[test, minimum height=1ex]{\scriptsize $a > b$?}}
% \ItemDescribeArgument[\cs{node}]{io}\cs{node}命令绘制输入/输出框
% 的样式,如:\tikz{\node[io]{\scriptsize 输入两个整数}}
% \ItemDescribeArgument[\cs{node}]{term}\cs{node}命令绘制开始/结束
% 框的样式,如:\tikz{\node[term]{\scriptsize 开始}}
% \ItemDescribeArgument[\cs{node}]{it}\cs{node}命令绘制斜体标注
% 的样式,如:\tikz{\node[it]{\scriptsize 这里需要特别注意}}
% \ItemDescribeArgument[\cs{node}]{connector}\cs{node}命令绘制流程
% 图链接点的样式,如:\tikz{\node[connector]{\scriptsize 1}}
% \ItemDescribeArgument[\cs{node}]{coord}\cs{node}命令布置转角结点
% 的样式,如:\tikz{\node[coord](c1){};\cmark{1}}
% \ItemDescribeArgument[\cs{draw}]{connect}\cs{draw}命令绘制不相交
% 的两个交汇路径的样式,如:\tikz{\node[coord](c1)at(0,0){};
% \node[coord](c2)at(0.3,0){};\node[coord](c3)at(0.15,-0.15){};
% \node[coord](c4)at(0.15,0.15){};\node[coord] (c5) at (c4 |- c1)
% {};\draw[lnorm](c3)--(c4);
% \draw[lnorm, connect=(c1) to (c2) over (c5) by 1.5pt] -- (c2);}
% \ItemDescribeArgument[\cs{draw}]{lnorm}\cs{draw}命令绘制指定颜色
% 无箭头连线的样式,如:\tikz{\draw[lnorm](0,0)--(0.5,0)}
% \ItemDescribeArgument[\cs{draw}]{lfree}\cs{draw}命令绘制指定颜色
% 无箭头连线的样式,如:\tikz{\draw[lfree](0,0)--(0.5,0)}
% \ItemDescribeArgument[\cs{draw}]{lcong}\cs{draw}命令绘制指定颜色
% 无箭头连线的样式,如:\tikz{\draw[lcong](0,0)--(0.5,0)}
% \ItemDescribeArgument[\cs{draw}]{norm}\cs{draw}命令绘制指定颜色箭
% 头连线的样式,如:\tikz{\draw[norm](0,0)--(0.5,0)}
% \ItemDescribeArgument[\cs{draw}]{free}\cs{draw}命令绘制指定颜色箭
% 头连线的样式,如:\tikz{\draw[free](0,0)--(0.5,0)}
% \ItemDescribeArgument[\cs{draw}]{dotnorm}\cs{draw}命令绘制指定颜
% 色流程线实心交点的样式,如:\tikz{\draw[dotnorm](0,0) circle(1.5pt)}
% \ItemDescribeArgument[\cs{draw}]{dotfree}\cs{draw}命令绘制指定颜
% 色流程线实心交点的样式,如:\tikz{\draw[dotfree](0,0) circle(1.5pt)}
% \ItemDescribeArgument[\cs{draw}]{dotcong}\cs{draw}命令绘制指定颜
% 色流程线实心交点的样式,如:\tikz{\draw[dotcong](0,0) circle(1.5pt)}
% \ItemDescribeArgument[\cs{draw}]{cdotnorm}\cs{draw}命令绘制指定颜
% 色流程线空心交点的样式,如:\tikz{\draw[cdotnorm](0,0) circle(1.5pt)}
% \ItemDescribeArgument[\cs{draw}]{cdotfree}\cs{draw}命令绘制指定颜
% 色流程线空心交点的样式,如:\tikz{\draw[cdotfree](0,0) circle(1.5pt)}
% \ItemDescribeArgument[\cs{draw}]{cdotcong}\cs{draw}命令绘制指定颜
% 色流程线空心交点的样式,如:\tikz{\draw[cdotcong](0,0) circle(1.5pt)}
% \end{description}
%
% \subsection{样式参数设置命令}
% \DescribeMacro{\flowchartset}
% \thispkg{}宏包定义了\cs{flowchartset}命令,该命令用于设置流程图各元
% 素的绘制属性,详情见如下代码注释。
%
% \begin{sourceverb}[xleftmargin=0em]
% \flowchartset{
% free color = green, % 自由连线颜色(默认取green)
% norm color = blue, % 常规连线颜色(默认取blue)
% cong color = red, % 关联连线颜色(默认取red)
% proc fill color = white, % 顺序处理框填充颜色(默认取白色)
% test fill color = white, % 判断框填充颜色(默认取白色)
% io fill color = white, % 输入/输出框填充颜色(默认取白色)
% term fill color = white, % 开始/结束框填充颜色(默认取白色)
% proc text width = 8em, % 顺序处理框宽度(默认取8em)
% test text width = 5em, % 判断框宽度(默认取5em)
% io text width = 6em, % 输入/输出框宽度(默认取6em)
% term text width = 3em, % 开始/结束宽度(默认取3em)
% chain direction = below, % 结点自动布置方向(默认取below)
% minimum node distance = 6mm, % 最小结点间距(默认取6mm)
% maximum node distance = 60mm, % 最大结点间距(默认取60mm)
% border line width = \pgflinewidth, % 流程框边框宽度(默认取当前线条宽度)
% flow line width = \pgflinewidth, % 流程线线条宽度(默认取当前线条宽度)
% stealth length = 1.5mm, % 箭头长度(默认取1.5mm)
% stealth width = 1.0mm, % 箭头宽度(默认取1.0mm)
% }
% \end{sourceverb}
%
% 这些参数设置方式与常规的\tkz{}参数设置类似,即可以多个参数一起设置,
% 也可以分开单独设置。\cs{flowchartset}命令可以在导言区进行全局设置,
% 也可以在需要的位置进行局部设置。
% \section{流程图绘制步骤}
% \subsection{布置流程框结点}
% 使用类似``|\node [proc](p1){表达式1};|''命令,采用\thispkg{}
% 定义的``|proc|''、``|test|''、``|io|''或``|term|''样式参数布置需要的流程框结点。
%
%
% 在布置结点时,如果前一个结点不是``|test|''样式,则可以使用
% ``|join|''参数自动与前一个结点建立连接,如
% ``|\node [proc, join] (p3) {表达式3};|'',并同时绘制对应流程线。
%
% 另外,可根据需要对结点进行命名(如``|p1|''、
% ``|t1|''等),以便引用该结点。
%
% \subsection{布置坐标点}
% 使用类似``|\node[coord,above=0.5 of p1](c1){};\cmark{1}|''
% 命令,用``|coord|''样式参数布置其它坐标点
% (主要用于流程线的转接)。同时,可以使用``\cs{cmark}''命令为该点作标
% 记,在带\oarg{debug}可选参数引入
% 宏包时,则绘制标记点,若无\oarg{debug}参数,则不绘制标记点。
%
% \subsection{绘制流程线}
% 首先使用类似``|\path(t1.south)--node[near start,right]{$Y$}(p2.north);|''
% 的路径命令绘制流程线的标注文字。
%
% 然后使用类似``\verb!\draw[norm](t1.east)--(c6)|-(c4)--(c5);!''
% 绘制命令绘制带有箭头的流程线。
%
% 可以使用``|lnorm|''、``|lfree|''或
% ``|lcong|''绘制指定颜色的无箭头流程线,用``|norm|''、
% ``|free|''或``|cong|''绘制指定颜色的有箭头流程线。
%
% \note[建议]{先绘制南北方向流程线,再绘制东西方向流程线}。
%
% 可以使用``|dotnorm|''、``|dotfree|''和
% ``|dotcong|''样式绘制流程线实心交点,用``|cdotnorm|''、
% ``|cdotfree|''或``|cdotcong|''样式绘制流程线空心交点。
%
% 对于不相交的流程线,可以用``|connect|''样式进行绘制。
%
% \subsection{绘制其它图形}
% 在使用\cs{node}、\cs{path}、\cs{draw}等命令时,可以同时使用任何
% 合法的\tkz{}参数,同时,也可以使用任何合法\tkz{}命令绘制需要的其它图形。
%
% \section{改变绘图属性}
%
% \subsection{改变流程线颜色}
% 通过在导言区使用\cs{flowchartset}命令可以全局设置需要的绘图属性,
% 如:
% \begin{sourceverb}
% \usepackage{tikz-flowchart}
% \flowchartset{
% norm color = black, % 将常规连线颜色设置为black
% }
% ......
% \end{sourceverb}
%
% \note{可以多次使用\cs{flowchartset}命令,每次可仅指定需要的参数。}
%
% 例如,仅指定``\verb|norm|''类型的颜色为``\verb|black|'',得到
% \autoref{fig:forloopblack}所示的黑色流程线。
%
% \flowchartset{
% norm color = black,
% }
%
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% \node [proc] (p1) {表达式1};
% \node [test, join] (t1) {表达式2?};
% \node [proc] (p2) {循环体};
% \node [proc, join] (p3) {表达式3};
%
% \node [coord, above = 0.5 of p1] (c1) {};
% \node [coord] (c2) at ($(p1)!0.35!(t1)$) {};
% \node [coord, below = 0.25 of p3] (c3) {};
% \node [coord, below = 0.2 of c3] (c4) {};
% \node [coord, below = 0.5 of c4] (c5) {};
% \node [coord, right = 0.5 of t1] (c6) {};
% \node [coord, left = 0.5 of t1] (ct) {};
% \node [coord] (c7) at (c3 -| ct) {};
%
% \path (t1.south) -- node [near start, right] {$Y$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.east) -- node [near start, above] {$N$} (c6);
% \draw [norm] (t1.east) -- (c6) |- (c4) -- (c5);
%
% \draw [norm] (c1) -- (p1);
% \draw [norm] (p3.south) |- (c7) |- (c2);
% \end{tikzpicture}
% \caption{黑色流程线流程图}
% \label{fig:forloopblack}
% \end{figure}
%
% \subsection{改变流程框填充色和宽度}
% 也可以在需要时用\cs{flowchartset}命令进行绘图属性的局部设置。
% 如,可以用如下代码局部改变各类流程框的填充颜色和文字宽度:
% \begin{sourceverb}
% \flowchartset{
% proc fill color = orange!10,
% test fill color = green!30,
% io fill color = blue!30,
% term fill color = red!30,
% proc text width = 6em,
% test text width = 5em,
% }
% \begin{tikzpicture}
% ...
% \end{tikzpicture}
% \end{sourceverb}
%
% 绘制结果如\autoref{fig:forloopcolork}所示。
%
% \flowchartset{
% proc fill color = orange!10,
% test fill color = green!30,
% io fill color = blue!30,
% term fill color = red!30,
% proc text width = 6em,
% test text width = 5em,
% }
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% \node [proc] (p1) {表达式1};
% \node [test, join] (t1) {表达式2?};
% \node [proc] (p2) {循环体};
% \node [proc, join] (p3) {表达式3};
%
% \node [coord, above = 0.5 of p1] (c1) {};
% \node [coord] (c2) at ($(p1)!0.35!(t1)$) {};
% \node [coord, below = 0.25 of p3] (c3) {};
% \node [coord, below = 0.2 of c3] (c4) {};
% \node [coord, below = 0.5 of c4] (c5) {};
% \node [coord, right = 0.5 of t1] (c6) {};
% \node [coord, left = 0.5 of t1] (ct) {};
% \node [coord] (c7) at (c3 -| ct) {};
%
% \path (t1.south) -- node [near start, right] {$Y$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.east) -- node [near start, above] {$N$} (c6);
% \draw [norm] (t1.east) -- (c6) |- (c4) -- (c5);
%
% \draw [norm] (c1) -- (p1);
% \draw [norm] (p3.south) |- (c7) |- (c2);
% \end{tikzpicture}
% \caption{彩色流程图}
% \label{fig:forloopcolork}
% \end{figure}
%
% \subsection{使用\env{tikzpicture}环境的绘图参数}
% 可以使用任意合法的\env{tikzpicture}环境参数,如,可使用
% \env{tikzpicture}环境的参数进行流程图缩放及字号设置:
%
% \begin{sourceverb}
% \begin{tikzpicture}[font=\scriptsize, scale=0.5,
% every node/.append style = {transform shape}]
% ...
% \end{tikzpicture}
% \end{sourceverb}
%
% 绘制结果如\autoref{fig:forloopscaled}所示。
%
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}[font=\scriptsize, scale=0.5,
% every node/.append style = {transform shape}]
% \node [proc] (p1) {表达式1};
% \node [test, join] (t1) {表达式2?};
% \node [proc] (p2) {循环体};
% \node [proc, join] (p3) {表达式3};
%
% \node [coord, above = 0.5 of p1] (c1) {};
% \node [coord] (c2) at ($(p1)!0.35!(t1)$) {};
% \node [coord, below = 0.25 of p3] (c3) {};
% \node [coord, below = 0.2 of c3] (c4) {};
% \node [coord, below = 0.5 of c4] (c5) {};
% \node [coord, right = 0.5 of t1] (c6) {};
% \node [coord, left = 0.5 of t1] (ct) {};
% \node [coord] (c7) at (c3 -| ct) {};
%
% \path (t1.south) -- node [near start, right] {$Y$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.east) -- node [near start, above] {$N$} (c6);
% \draw [norm] (t1.east) -- (c6) |- (c4) -- (c5);
%
% \draw [norm] (c1) -- (p1);
% \draw [norm] (p3.south) |- (c7) |- (c2);
% \end{tikzpicture}
% \caption{流程图缩放}
% \label{fig:forloopscaled}
% \end{figure}
%
% \subsection{使用绘图命令参数}
% 可以使用任意\cs{node}、\cs{draw}等绘图命令的合法参数调整当前绘图属性,如:
%
% \begin{sourcedisplay}
% ...\\
% \cs{node}[test, join, \textcolor{red}{text width= 5em}](t1) \{表达式2?\};\\
% ...\\
% \cs{draw}[norm, \textcolor{red}{dash dot}](t1.east) -- (c6) \verb!|!- (c4) -- (c5);\\
% ...\\
% \cs{draw}[norm, \textcolor{red}{dashed}](p3.south) \verb!|!- (c7) \verb!|!- (c2);\\
% ...\\
% \end{sourcedisplay}
%
% 绘制结果如\autoref{fig:forloopdasheline}所示。
%
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% \node [proc] (p1) {表达式1};
% \node [test, join, text width= 5em] (t1) {表达式2?};
% \node [proc] (p2) {循环体};
% \node [proc, join] (p3) {表达式3};
%
% \node [coord, above = 0.5 of p1] (c1) {};
% \node [coord] (c2) at ($(p1)!0.35!(t1)$) {};
% \node [coord, below = 0.25 of p3] (c3) {};
% \node [coord, below = 0.2 of c3] (c4) {};
% \node [coord, below = 0.5 of c4] (c5) {};
% \node [coord, right = 0.5 of t1] (c6) {};
% \node [coord, left = 0.5 of t1] (ct) {};
% \node [coord] (c7) at (c3 -| ct) {};
%
% \path (t1.south) -- node [near start, right] {$Y$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.east) -- node [near start, above] {$N$} (c6);
% \draw [norm, dash dot] (t1.east) -- (c6) |- (c4) -- (c5);
%
% \draw [norm] (c1) -- (p1);
% \draw [norm, dashed] (p3.south) |- (c7) |- (c2);
% \end{tikzpicture}
% \caption{使用绘图命令参数}
% \label{fig:forloopdasheline}
% \end{figure}
%
% \subsection{流程图示例}
% \subsubsection{冒泡排序流程图}
% 如下代码绘制如\autoref{fig:bubllesort}所示的冒泡排序流程图。
%
% \begin{sourceverb}[xleftmargin=0em]
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% % 布置结点单元
% \node [term] (st) {Begin};
% \node [proc, text width = 6em, join] (p1) {\verb|int i, j|\\
% \verb|int counter|};
% \node [proc, join] (p2) {\verb|i = 0|\\\verb|counter = 0|};
% \node [test, join] (t1) {\verb|i < n - 1|};
% \node [proc] (p3) {\verb|j = 0|};
% \node [test, join] (t2) {\verb|j < n - 1|};
% \node [test, text width = 6em] (t3) {\verb|a[j] > a[j + 1]|};
% \node [proc, text width = 8em] (p4) {\verb|Swap(a[j], a[j + 1])|};
% \node [proc, join] (p5) {\verb|counter++|\\\verb|j++|};
% \node [proc] (p6) {\verb|i++|};
% \node [proc, text width = 6em] (p7) {\verb|return counter|};
% \node [term, join] (end) {End};
%
% % 布置用于连接的坐标结点,同时为其布置调试标记点。
% \node [coord] (c1) at ($(p2.south)!0.5!(t1.north)$) {};
% \node [coord] (c2) at ($(p3.south)!0.5!(t2.north)$) {};
% \node [coord] (c3) at ($(p4.south)!0.5!(p5.north)$) {};
% \node [coord, below = 0.2 of p5] (c4) {};
% \node [coord, above = 0.25 of p6] (c5) {};
% \node [coord, below = 0.2 of p6] (c6) {};
% \node [coord, above = 0.25 of p7] (c7) {};
% \node [coord, right = 2.0 of t1] (c8) {};
% \node [coord, right = 1.5 of t2] (c9) {};
% \node [coord, right = 0.4 of t3] (c10) {};
% \node [coord, left = 1.5 of t2] (ct1) {};
% \node [coord, left = 2.0 of t2] (ct2) {};
% \node [coord] (c11) at (c6 -| ct2) {};
% \node [coord] (c12) at (c4 -| ct1) {};
%
% % 判断框连线,每次绘制时,先绘制一个带有一个固定
% % 位置标注的路径(path),然后再绘制箭头本身(arrow)。
% \path (t1.south) -- node [near start, right] {$Y$} (p3.north);
% \draw [norm] (t1.south) -- (p3.north);
% \path (t1.east) -- node [near start, above] {$N$} (c8);
% \draw [norm] (t1.east) -- (c8) |- (c7) -- (p7.north);
%
% \path (t2.south) -- node [near start, right] {$Y$} (t3.north);
% \draw [norm] (t2.south) -- (t3.north);
% \path (t2.east) -- node [near start, above] {$N$} (c9);
% \draw [norm] (t2.east) -- (c9) |- (c5) -- (p6.north);
%
% \path (t3.south) -- node [near start, right] {$Y$} (p4.north);
% \draw [norm] (t3.south) -- (p4.north);
% \path (t3.east) -- node [near start, above] {$N$} (c10);
% \draw [norm] (t3.east) -- (c10) |- (c3);
%
% % 其它连线
% \draw [norm](p5.south) |- (c12) |- (c2);
% \draw [norm](p6.south) |- (c11) |- (c1);
% \end{tikzpicture}
% \caption{冒泡排序流程图}
% \label{fig:bubllesort}
% \end{figure}
% \end{sourceverb}
%
% \flowchartset{
% free color = green,
% norm color = blue,
% cong color = red,
% proc fill color = orange!10,
% test fill color = green!30,
% io fill color = blue!30,
% term fill color = red!30,
% proc text width = 10em,
% test text width = 8em,
% }
%
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% % 布置结点单元
% \node [term] (st) {Begin};
% \node [proc, join] (p1) {|int i, j|\\|int counter|};
% \node [proc, join] (p2) {|i = 0|\\|counter = 0|};
% \node [test, join] (t1) {|i < n - 1|};
% \node [proc] (p3) {|j = 0|};
% \node [test, join] (t2) {|j < n - 1|};
% \node [test] (t3) {|a[j] > a[j + 1]|};
% \node [proc] (p4) {|Swap(a[j], a[j + 1])|};
% \node [proc, join] (p5) {|counter++|\\|j++|};
% \node [proc] (p6) {|i++|};
% \node [proc] (p7) {|return counter|};
% \node [term, join] (end) {End};
%
% % 布置用于连接的坐标结点,同时为其布置调试标记点。
% \node [coord] (c1) at ($(p2.south)!0.5!(t1.north)$) {};
% \node [coord] (c2) at ($(p3.south)!0.5!(t2.north)$) {};
% \node [coord] (c3) at ($(p4.south)!0.5!(p5.north)$) {};
% \node [coord, below = 0.2 of p5] (c4) {};
% \node [coord, above = 0.25 of p6] (c5) {};
% \node [coord, below = 0.2 of p6] (c6) {};
% \node [coord, above = 0.25 of p7] (c7) {};
% \node [coord, right = 2.0 of t1] (c8) {};
% \node [coord, right = 1.5 of t2] (c9) {};
% \node [coord, right = 0.4 of t3] (c10) {};
% \node [coord, left = 1.5 of t2] (ct1) {};
% \node [coord, left = 2.0 of t2] (ct2) {};
% \node [coord] (c11) at (c6 -| ct2) {};
% \node [coord] (c12) at (c4 -| ct1) {};
%
% % 判断框连线,每次绘制时,先绘制一个带有一个固定
% % 位置标注的路径(path),然后再绘制箭头本身(arrow)。
% \path (t1.south) -- node [near start, right] {$Y$} (p3.north);
% \draw [norm] (t1.south) -- (p3.north);
% \path (t1.east) -- node [near start, above] {$N$} (c8);
% \draw [norm] (t1.east) -- (c8) |- (c7) -- (p7.north);
%
% \path (t2.south) -- node [near start, right] {$Y$} (t3.north);
% \draw [norm] (t2.south) -- (t3.north);
% \path (t2.east) -- node [near start, above] {$N$} (c9);
% \draw [norm] (t2.east) -- (c9) |- (c5) -- (p6.north);
%
% \path (t3.south) -- node [near start, right] {$Y$} (p4.north);
% \draw [norm] (t3.south) -- (p4.north);
% \path (t3.east) -- node [near start, above] {$N$} (c10);
% \draw [norm] (t3.east) -- (c10) |- (c3);
%
% % 其它连线
% \draw [norm](p5.south) |- (c12) |- (c2);
% \draw [norm](p6.south) |- (c11) |- (c1);
% \end{tikzpicture}
% \caption{冒泡排序流程图}
% \label{fig:bubllesort}
% \end{figure}
%
% \newpage
% \subsubsection{素数判定流程图}
% 如下代码绘制如\autoref{fig:primejudge}所示的素数判定流程图。
%
% \begin{sourceverb}[xleftmargin=0em]
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% % 布置结点单元
% \node [term] (st) {开始};
% \node [proc, join] (p1) {\verb|int divisor|};
% \node [test, join] (t1) {\verb|n <= 1|};
% \node [proc] (p2) {\verb|divisor = 2|};
% \node [test, join] (t2) {\verb|divisor * divisor <= n|};
% \node [test] (t3) {\verb|n % divisor == 0|};
% \node [proc] (p3) {\verb|divisor++|};
% \node [term, below = 1.6 of p3] (end) {结束};
% \node [proc, left = 4.8 of t2] (p4) {\verb|return 0|};
% \node [proc, right = 3.5 of p3] (p5) {\verb|return 0|};
% \node [proc, right = 5.8 of t3] (p6) {\verb|return 1|};
%
% % 布置用于连接的坐标结点,同时为其布置调试标记点。
% \node [coord] (c1) at ($(p2.south)!0.5!(t2.north)$) {};
% \node [coord, below = 0.25 of p3] (c2) {};
% \node [coord, above = 0.5 of end] (c3) {};
% \node [coord, left = 0.5 of t2] (ct) {};
% \node [coord] (c4) at (c3 -| p5) {};
% \node [coord] (c5) at (c2 -| ct) {};
%
% % 判断框连线,每次绘制时,先绘制一个带有一个固定
% % 位置标注的路径(path),然后再绘制箭头本身(arrow)。
% \path (t1.south) -- node [near start, right] {$N$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.west) -| node [near start, above] {$Y$} (p4.north);
% \draw [norm] (t1.west) -| (p4.north);
%
% \path (t2.south) -- node [near start, right] {$Y$} (t3.north);
% \draw [norm] (t2.south) -- (t3.north);
% \path (t2.east) -| node [near start, above] {$N$} (p6.north);
% \draw [norm] (t2.east) -| (p6.north);
%
% \path (t3.south) -- node [near start, right] {$N$} (p3.north);
% \draw [norm] (t3.south) -- (p3.north);
% \path (t3.east) -| node [near start, above] {$Y$} (p5.north);
% \draw [norm] (t3.east) -| (p5.north);
%
% % 其它连线
% \draw [norm](p3.south) |- (c5) |- (c1);
% \draw [norm](p4.south) |- (c3);
% \draw [norm](p4.south) |- (c3) -- (end);
% \draw [norm](p5.south) -- (c4);
% \draw [norm](p6.south) |- (c3);
% \draw [norm](p6.south) |- (c3) -- (end);
% \end{tikzpicture}
% \caption{素数判定流程图}
% \label{fig:primejudge}
% \end{figure}
% \end{sourceverb}
%
% \flowchartset{
% proc fill color = orange!10,
% test fill color = green!30,
% io fill color = blue!30,
% term fill color = red!30,
% proc text width = 6em,
% test text width = 10em,
% }
%
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}[scale=0.5]
% % 布置结点单元
% \node [term] (st) {开始};
% \node [proc, join] (p1) {|int divisor|};
% \node [test, join] (t1) {b|n <= 1|};
% \node [proc] (p2) {|divisor = 2|};
% \node [test, join] (t2) {|divisor * divisor <= n|};
% \node [test] (t3) {|n % divisor == 0|};
% \node [proc] (p3) {|divisor++|};
% \node [term, below = 1.6 of p3] (end) {结束};
% \node [proc, left = 4.8 of t2] (p4) {|return 0|};
% \node [proc, right = 3.5 of p3] (p5) {|return 0|};
% \node [proc, right = 5.8 of t3] (p6) {|return 1|};
%
% % 布置用于连接的坐标结点,同时为其布置调试标记点。
% \node [coord] (c1) at ($(p2.south)!0.5!(t2.north)$) {};
% \node [coord, below = 0.25 of p3] (c2) {};
% \node [coord, above = 0.5 of end] (c3) {};
% \node [coord, left = 0.5 of t2] (ct) {};
% \node [coord] (c4) at (c3 -| p5) {};
% \node [coord] (c5) at (c2 -| ct) {};
%
% % 判断框连线,每次绘制时,先绘制一个带有一个固定
% % 位置标注的路径(path),然后再绘制箭头本身(arrow)。
% \path (t1.south) -- node [near start, right] {$N$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.west) -| node [near start, above] {$Y$} (p4.north);
% \draw [norm] (t1.west) -| (p4.north);
%
% \path (t2.south) -- node [near start, right] {$Y$} (t3.north);
% \draw [norm] (t2.south) -- (t3.north);
% \path (t2.east) -| node [near start, above] {$N$} (p6.north);
% \draw [norm] (t2.east) -| (p6.north);
%
% \path (t3.south) -- node [near start, right] {$N$} (p3.north);
% \draw [norm] (t3.south) -- (p3.north);
% \path (t3.east) -| node [near start, above] {$Y$} (p5.north);
% \draw [norm] (t3.east) -| (p5.north);
%
% % 其它连线
% \draw [norm](p3.south) |- (c5) |- (c1);
% \draw [norm](p4.south) |- (c3);
% \draw [norm](p4.south) |- (c3) -- (end);
% \draw [norm](p5.south) -- (c4);
% \draw [norm](p6.south) |- (c3);
% \draw [norm](p6.south) |- (c3) -- (end);
% \end{tikzpicture}
% \caption{素数判定流程图}
% \label{fig:primejudge}
% \end{figure}
%
% \newpage
% \subsubsection{求最大公约数流程图}
% 如下代码绘制如\autoref{fig:getgcd}所示的求最大公约数流程图。
%
% \begin{sourceverb}[xleftmargin=0em]
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% % 布置结点单元
% % 用异或交换两个整数
% \node [term] (st) {Begin};
% \node [proc, join] (p1) {\verb|int r = 0|};
% \node [test, join] (t1) {\verb|m < n|};
% \node [proc] (p2) {\verb|m ^= n|\\\verb|n ^= m|\\\verb|m ^= n|};
% \node [test, join] (t2) {\verb|n != 0|};
% \node [proc] (p3) {\verb|r = m % n|\\\verb|m = n|\\\verb|n = r|};
% \node [proc] (p4) {\verb|return m|};
% \node [term, join] (end) {End};
%
% % 布置用于连接的坐标结点,同时为其布置调试标记点。
% \node [coord] (c1) at ($(p2.south)!0.5!(t2.north)$) {};
% \node [coord, below = 0.25 of p3] (c2) {};
% \node [coord, above = 0.25 of p4] (c3) {};
% \node [coord, right = 1.0 of t1] (c4) {};
% \node [coord, right = 1.0 of t2] (c5) {};
% \node [coord, left = 1.0 of t2] (ct) {};
% \node [coord] (c6) at (ct |- c2) {};
%
% % 判断框连线,每次绘制时,先绘制一个带有一个固定
% % 位置标注的路径(path),然后再绘制箭头本身(arrow)。
% \path (t1.south) -- node [near start, right] {$Y$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.east) -- node [near start, above] {$N$} (c4);
% \draw [norm] (t1.east) -- (c4) |- (c1);
% \path (t2.south) -- node [near start, right] {$Y$} (p3.north);
% \draw [norm] (t2.south) -- (p3.north);
% \path (t2.east) -- node [near start, above] {$N$} (c5);
% \draw [norm] (t2.east) -- (c5) |- (c3) -- (p4.north);
%
% % 其它连线
% \draw [norm](p3.south) |- (c6) |- (c1);
% \end{tikzpicture}
% \caption{求最大公约数}
% \label{fig:getgcd}
% \end{figure}
% \end{sourceverb}
%
% \flowchartset{
% proc fill color = orange!10,
% test fill color = green!30,
% io fill color = blue!30,
% term fill color = red!30,
% proc text width = 5em,
% test text width = 5em,
% }
%
% \begin{figure}[!htp]
% \centering
% \begin{tikzpicture}
% % 布置结点单元
% % 用异或交换两个整数
% \node [term] (st) {Begin};
% \node [proc, join] (p1) {|int r = 0|};
% \node [test, join] (t1) {|m < n|};
% \node [proc] (p2) {|m ^= n|\\|n ^= m|\\|m ^= n|};
% \node [test, join] (t2) {|n != 0|};
% \node [proc] (p3) {|r = m % n|\\|m = n|\\|n = r|};
% \node [proc] (p4) {|return m|};
% \node [term, join] (end) {End};
%
% % 布置用于连接的坐标结点,同时为其布置调试标记点。
% \node [coord] (c1) at ($(p2.south)!0.5!(t2.north)$) {};
% \node [coord, below = 0.25 of p3] (c2) {};
% \node [coord, above = 0.25 of p4] (c3) {};
% \node [coord, right = 1.0 of t1] (c4) {};
% \node [coord, right = 1.0 of t2] (c5) {};
% \node [coord, left = 1.0 of t2] (ct) {};
% \node [coord] (c6) at (ct |- c2) {};
%
% % 判断框连线,每次绘制时,先绘制一个带有一个固定
% % 位置标注的路径(path),然后再绘制箭头本身(arrow)。
% \path (t1.south) -- node [near start, right] {$Y$} (p2.north);
% \draw [norm] (t1.south) -- (p2.north);
% \path (t1.east) -- node [near start, above] {$N$} (c4);
% \draw [norm] (t1.east) -- (c4) |- (c1);
% \path (t2.south) -- node [near start, right] {$Y$} (p3.north);
% \draw [norm] (t2.south) -- (p3.north);
% \path (t2.east) -- node [near start, above] {$N$} (c5);
% \draw [norm] (t2.east) -- (c5) |- (c3) -- (p4.north);
%
% % 其它连线
% \draw [norm](p3.south) |- (c6) |- (c1);
% \end{tikzpicture}
% \caption{求最大公约数}
% \label{fig:getgcd}
% \end{figure}
%
% \newpage
% \section{代码实现}
% 该宏包仅需要载入|tikz|和|xifthen|宏包,如果这些宏包没有载入,则自
% 动载入这些宏包。
% \begin{macrocode}
\RequirePackage{tikz}
\RequirePackage{xifthen}
%
% \end{macrocode}
% \subsection{宏包选项}
% 使用 \pkg{kvoptions} 来处理传给该宏包的参数。
% \begin{macrocode}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
family=flowchart,
prefix=flowchart@,
setkeys=\kvsetkeys
}
% \end{macrocode}
%
% 定义调试状态参数(布尔类型)。
% \begin{macrocode}
\DeclareBoolOption[false]{debug}
% \end{macrocode}
%
% 参数解析,获取定义的宏包参数。
% \begin{macrocode}
\DeclareDefaultOption{}
\kvsetkeys{flowchart}{}
\ProcessKeyvalOptions*
% \end{macrocode}
% 载入需要的\tkz{}宏包运行库。
% \begin{macrocode}
\usetikzlibrary{
arrows.meta, % 箭头形状
shapes.geometric, % 几何形状
chains, % 链式布局
calc, % 坐标计算
}
% \end{macrocode}
%
% \subsection{配置命令}
% 为|\flowchartset|命令定义一个|pgfkeys|族,所有配置参数(例如:
% \meta{norm color}等)都会存储在|/flowchart|PGF键中。这能够确保这些配
% 置参数不会覆盖别的同类参数。
% \begin{macrocode}
\pgfkeys{
/flowchart/.is family,
/flowchart/.search also={/tikz},
}
\def\flowchartset{\pgfqkeys{/flowchart}}
% \end{macrocode}
% 然后,定义存储这些参数值的宏命令。
% \begin{macrocode}
\flowchartset{
free color/.store in = \freecolor, % 自由连线颜色
norm color/.store in = \normcolor, % 常规连线颜色
cong color/.store in = \congcolor, % 关联连线颜色
proc fill color/.store in = \procfillcolor, % 顺序处理框填充颜色
test fill color/.store in = \testfillcolor, % 判断框填充颜色
io fill color/.store in = \iofillcolor, % 输入/输出框填充颜色
term fill color/.store in = \termfillcolor, % 开始/结束框填充颜色
proc text width/.store in = \proctxtwd, % 顺序处理框宽度
test text width/.store in = \testtxtwd, % 判断框宽度
io text width/.store in = \iotxtwd, % 输入/输出框宽度
term text width/.store in = \termtxtwd, % 开始/结束宽度
chain direction/.store in = \chaindir, % 结点自动布置方向
minimum node distance/.store in = \minnodedis, % 最小结点间距
maximum node distance/.store in = \maxnodedis, % 最大结点间距
border line width/.store in = \bdlinewd, % 各类流程框边框宽度
flow line width/.store in = \flowlinewd, % 各类流程线线条宽度
stealth length/.store in = \stealthlen, % 箭头长度
stealth width/.store in = \stealthwd, % 箭头宽度
}
% \end{macrocode}
%
% \subsection{默认参数值}
% 为各个参数设置默认值以确保预设的各个宏的值有效,这些值可以由用户单独
% 进行修改,修改后的值会覆盖参数默认值。
% \begin{macrocode}
\flowchartset{
free color = green, % 自由连线颜色(默认取green)
norm color = blue, % 常规连线颜色(默认取blue)
cong color = red, % 关联连线颜色(默认取red)
proc fill color = white, % 顺序处理框填充颜色(默认取白色)
test fill color = white, % 判断框填充颜色(默认取白色)
io fill color = white, % 输入/输出框填充颜色(默认取白色)
term fill color = white, % 开始/结束框填充颜色(默认取白色)
proc text width = 8em, % 顺序处理框宽度(默认取8em)
test text width = 5em, % 判断框宽度(默认取5em)
io text width = 6em, % 输入/输出框宽度(默认取6em)
term text width = 3em, % 开始/结束宽度(默认取3em)
chain direction = below, % 结点自动布置方向(默认取below)
minimum node distance = 6mm, % 最小结点间距(默认取6mm)
maximum node distance = 60mm, % 最大结点间距(默认取60mm)
border line width = \pgflinewidth, % 各类流程框边框宽度(默认取当前线条宽度)
flow line width = \pgflinewidth, % 各类流程线线条宽度(默认取当前线条宽度)
stealth length = 1.5mm, % 箭头长度(默认取1.5mm)
stealth width = 1.0mm, % 箭头宽度(默认取1.0mm)
}
% \end{macrocode}
%
% \subsection{样式定义}
% 以下是所有绘制流程图中需要的样式定义。
% \begin{macrocode}
\tikzset{
% \end{macrocode}
% 首先,定义结点布局方式:
% \begin{macrocode}
start chain = going \chaindir, % 结点自动布置方向(默认取below)
node distance = \minnodedis and \maxnodedis, % 结点间距
every join/.style = {norm}, % 默认自动连接线的连线样式
% \end{macrocode}
% 其次,定义基础绘图样式:
% \begin{macrocode}
% 流程框样式的基础样式
base/.style = {line width = \bdlinewd, % 边框线宽
draw, % 绘制边框
on chain, % 沿布局方向绘制
on grid, % 沿网格布局
align=center, % 内容居中对齐