加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tikz-flowchart.sty 9.21 KB
一键复制 编辑 原始数据 按行查看 历史
%%
%% This is file `tikz-flowchart.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tikz-flowchart.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright (C) 2019 by Geng Nan <nangeng@nwsuaf.edu.cn>
%%
%% This work 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.
%%
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\ProvidesPackage{tikz-flowchart}
[2019/08/20 v1.0.01 draw flowchart using TikZ]
\RequirePackage{tikz}
\RequirePackage{xifthen}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
family=flowchart,
prefix=flowchart@,
setkeys=\kvsetkeys
}
\DeclareBoolOption[false]{debug}
\DeclareDefaultOption{}
\kvsetkeys{flowchart}{}
\ProcessKeyvalOptions*
\usetikzlibrary{
arrows.meta, % 箭头形状
shapes.geometric, % 几何形状
chains, % 链式布局
calc, % 坐标计算
}
\pgfkeys{
/flowchart/.is family,
/flowchart/.search also={/tikz},
}
\def\flowchartset{\pgfqkeys{/flowchart}}
\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, % 箭头宽度
}
\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)
}
\tikzset{
start chain = going \chaindir, % 结点自动布置方向(默认取below)
node distance = \minnodedis and \maxnodedis, % 结点间距
every join/.style = {norm}, % 默认自动连接线的连线样式
% 流程框样式的基础样式
base/.style = {line width = \bdlinewd, % 边框线宽
draw, % 绘制边框
on chain, % 沿布局方向绘制
on grid, % 沿网格布局
align=center, % 内容居中对齐
minimum height=2ex, % 流程框最小高度
},
% 顺序处理框样式
proc/.style={base, % 基础样式
rectangle, % 矩形边框
text width=\proctxtwd, % 最大文本宽度(超过会自动换行)
fill=\procfillcolor, % 填充色
},
% 判断框样式
test/.style={base, % 基础样式
diamond, % 菱形边框
aspect=2.5, % 长高比例
text width=\testtxtwd, % 最大文本宽度(超过会自动换行)
fill=\testfillcolor, % 填充色
},
% 输入/输出框样式
io/.style={base, % 基础样式
trapezium, % 平行四边形
trapezium left angle=70, % 平行四边形左倾角
trapezium right angle=110, % 平行四边形右倾角
text width=\iotxtwd, % 最大文本宽度(超过会自动换行)
fill=\iofillcolor, % 填充色
},
% 开始/结束框样式
term/.style={proc, % 基于proc样式
rounded corners=2.0mm, % 为矩形添加圆角属性
text width=\termtxtwd, % 最大文本宽度(超过会自动换行)
fill=\termfillcolor, % 填充色
},
% 流程连接点样式
connector/.style = {draw, % 绘制边框
circle, % 圆形
node distance=3cm, % 节点间距
},
% 绕接连线点样式(不相交的两个交汇路径)
connect/.style args={(#1) to (#2) over (#3) by #4}{
insert path={
let \p1=($(#1)-(#3)$), \n1={veclen(\x1,\y1)},
\n2={atan2(\y1,\x1)}, \n3={abs(#4)}, \n4={#4>0 ?-180:180} in
(#1) -- ($(#1)!\n1-\n3!(#3)$) arc (\n2:\n2+\n4:\n3) -- (#2)
}
},
% coord结点样式(用于布置流程线连接点)
coord/.style={coordinate, % 笛卡尔坐标系
%on chain, % 沿布局方向绘制
%on grid, % 沿网格布局
node distance=6mm and 25mm, % 节点间距
},
% nmark结点样式(用于布置调试坐标标记点)
nmark/.style={draw, % 绘制边框
cyan, % 青色
circle, % 圆形
font={\sffamily\bfseries}, % 字体
},
% -------------------------------------------------
% 无箭头连线样式
lnorm/.style={line width = \flowlinewd, % 线宽
draw, % 绘制
\normcolor, % 颜色
},
lfree/.style={line width = \flowlinewd,
draw,
\freecolor,
},
lcong/.style={line width = \flowlinewd,
draw,
\congcolor,
},
% 流程线实心交点样式
dotnorm/.style={draw, % 绘制
fill = \normcolor, % 填充颜色
\normcolor, % 颜色
},
dotfree/.style={draw,
fill = \freecolor,
\freecolor,
},
dotcong/.style={draw,
fill = \congcolor,
\congcolor,
},
% 流程线空心交点样式
cdotnorm/.style={draw, % 绘制
\normcolor, % 颜色
},
cdotfree/.style={draw,
\freecolor,
},
cdotcong/.style={draw,
\congcolor,
},
% 带箭头连线样式
norm/.style={line width = \flowlinewd, % 线宽
-{Stealth[length=\stealthlen, % 箭头长度
width=\stealthwd, % 箭头宽度
]
},
draw, % 绘制
\normcolor, % 颜色
},
free/.style={line width = \flowlinewd,
-{Stealth[length=\stealthlen,
width=\stealthwd,
]
},
draw,
\freecolor,
},
cong/.style={line width = \flowlinewd,
-{Stealth[length=\stealthlen,
width=\stealthwd,
]
},
draw,
\congcolor,
},
% 斜体字样式
it/.style={font={\small\itshape}},
}
%% 判断是否为宏包传入了debug参数以打开调试功能,若没有传入debug参数,则关闭调试功能。
\ifflowchart@debug
% 设置一个用于调试的标记符号图层,注意确保这一图层位于顶层
\pgfdeclarelayer{marx}
\pgfsetlayers{main,marx}
\newcommand{\cmark}[2][]{%
\begin{pgfonlayer}{marx}
\node [nmark] at (c#2#1) {#2};
\end{pgfonlayer}{marx}
}
\else
\newcommand{\cmark}[2][]{\relax}
\fi
\endinput
%%
%% End of file `tikz-flowchart.sty'.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化