tikz-flowchart
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTikZ Flowchart Skill
TikZ 流程图技能
This skill provides a standardized template/style for establishing professional technical diagrams using LaTeX TikZ. It is designed for creating flowcharts, architecture diagrams, and process flows.
本技能为使用LaTeX TikZ制作专业技术图表提供了标准化模板/样式,适用于创建流程图、架构图和流程示意图。
Usage
使用方法
When asked to "create a flowchart" or "draw a diagram" in this project, use the template below as a starting point. Adjust styles (, , etc.) as needed for the specific content.
dataNodeopNode当在本项目中被要求「创建流程图」或「绘制图表」时,请以下方模板为起点。可根据具体内容调整样式(如、等)。
dataNodeopNodeStyle Guide
样式指南
Colors
配色方案
The template uses a Google Material-like palette:
- Green (/
greenFill): Data, Inputs, Outputs, Tensors.greenStroke - Orange/Memory (/
memFill): Memory, Weights, Checkpoints.memStroke - Blue/Core (/
coreFill): Operations, Compute Kernels, Processes.coreStroke - Pink/Optimization (/
optFill): Optimizations, Special Steps.optStroke - Yellow/Process (/
procFill): General Processing Steps.procStroke
本模板采用类Google Material配色方案:
- 绿色(/
greenFill):数据、输入、输出、张量。greenStroke - 橙色/内存(/
memFill):内存、权重、检查点。memStroke - 蓝色/核心(/
coreFill):操作、计算内核、流程。coreStroke - 粉色/优化(/
optFill):优化、特殊步骤。optStroke - 黄色/流程(/
procFill):通用处理步骤。procStroke
Standard Nodes
标准节点
- : Rectangles for data flow (green).
dataNode - : Cylinders for storage/weights (orange).
memNode - : Rectangles for operations (blue).
opNode - : Dashed containers for grouping internal kernel logic.
kernelBox - : Dashed background containers for logical grouping of phases/stages.
group
- :用于数据流的矩形(绿色)。
dataNode - :用于存储/权重的圆柱体(橙色)。
memNode - :用于操作的矩形(蓝色)。
opNode - :用于分组内核内部逻辑的虚线容器。
kernelBox - :用于对阶段进行逻辑分组的虚线背景容器。
group
Template
模板
Use this template as your base:
latex
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{shapes.geometric, arrows.meta, positioning, fit, backgrounds, calc, shadows.blur, decorations.pathreplacing}
% --- Color Definitions ---
\definecolor{greenFill}{HTML}{E8F5E9}
\definecolor{greenStroke}{HTML}{43A047}
\definecolor{memFill}{HTML}{FFF3E0}
\definecolor{memStroke}{HTML}{FFB74D}
\definecolor{coreFill}{HTML}{E1F5FE}
\definecolor{coreStroke}{HTML}{0277BD}
\definecolor{optFill}{HTML}{FCE4EC}
\definecolor{optStroke}{HTML}{E91E63}
\definecolor{procFill}{HTML}{FFF9C4}
\definecolor{procStroke}{HTML}{FBC02D}
\begin{document}
\begin{tikzpicture}[
node distance=1.2cm and 1.8cm, % Vertical and Horizontal spacing
font=\sffamily\footnotesize,
>=Stealth,
% --- Styles ---
dataNode/.style={
rectangle, rounded corners=3pt,
draw=greenStroke, thick,
fill=greenFill,
minimum width=2.4cm, minimum height=1.2cm,
align=center,
drop shadow
},
memNode/.style={
cylinder, cylinder uses custom fill,
cylinder body fill=memFill, cylinder end fill=memFill!90!gray,
shape border rotate=90,
aspect=0.25,
draw=memStroke, thick,
minimum width=1.8cm, minimum height=1.3cm,
align=center
},
opNode/.style={
rectangle, rounded corners=3pt,
draw=coreStroke, thick,
fill=coreFill,
minimum width=2.6cm, minimum height=1.2cm,
align=center,
drop shadow
},
kernelBox/.style={
rectangle, rounded corners=8pt,
draw=coreStroke, thick, dashed,
fill=coreFill!20,
inner sep=12pt,
align=center
},
group/.style={
draw=gray!30, dashed, rounded corners=8pt, inner sep=12pt, fill=gray!5
},
edgeLabel/.style={
font=\scriptsize,
text=black!80,
align=center,
inner sep=1pt
}
]
% --- Nodes ---
% Example:
% \node[dataNode] (Input) {Input Data};
% \node[opNode, right=of Input] (Process) {Process};
% --- Layout Containers (Optional) ---
% \begin{scope}[on background layer]
% \node[group, fit=(Input)(Process)] (MainGroup) {};
% \end{scope}
% --- Connections ---
% \draw[->, thick, color=gray!80] (Input) -- (Process);
\end{tikzpicture}
\end{document}请以此模板为基础:
latex
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{shapes.geometric, arrows.meta, positioning, fit, backgrounds, calc, shadows.blur, decorations.pathreplacing}
% --- Color Definitions ---
\definecolor{greenFill}{HTML}{E8F5E9}
\definecolor{greenStroke}{HTML}{43A047}
\definecolor{memFill}{HTML}{FFF3E0}
\definecolor{memStroke}{HTML}{FFB74D}
\definecolor{coreFill}{HTML}{E1F5FE}
\definecolor{coreStroke}{HTML}{0277BD}
\definecolor{optFill}{HTML}{FCE4EC}
\definecolor{optStroke}{HTML}{E91E63}
\definecolor{procFill}{HTML}{FFF9C4}
\definecolor{procStroke}{HTML}{FBC02D}
\begin{document}
\begin{tikzpicture}[
node distance=1.2cm and 1.8cm, % Vertical and Horizontal spacing
font=\sffamily\footnotesize,
>=Stealth,
% --- Styles ---
dataNode/.style={
rectangle, rounded corners=3pt,
draw=greenStroke, thick,
fill=greenFill,
minimum width=2.4cm, minimum height=1.2cm,
align=center,
drop shadow
},
memNode/.style={
cylinder, cylinder uses custom fill,
cylinder body fill=memFill, cylinder end fill=memFill!90!gray,
shape border rotate=90,
aspect=0.25,
draw=memStroke, thick,
minimum width=1.8cm, minimum height=1.3cm,
align=center
},
opNode/.style={
rectangle, rounded corners=3pt,
draw=coreStroke, thick,
fill=coreFill,
minimum width=2.6cm, minimum height=1.2cm,
align=center,
drop shadow
},
kernelBox/.style={
rectangle, rounded corners=8pt,
draw=coreStroke, thick, dashed,
fill=coreFill!20,
inner sep=12pt,
align=center
},
group/.style={
draw=gray!30, dashed, rounded corners=8pt, inner sep=12pt, fill=gray!5
},
edgeLabel/.style={
font=\scriptsize,
text=black!80,
align=center,
inner sep=1pt
}
]
% --- Nodes ---
% Example:
% \node[dataNode] (Input) {Input Data};
% \node[opNode, right=of Input] (Process) {Process};
% --- Layout Containers (Optional) ---
% \begin{scope}[on background layer]
% \node[group, fit=(Input)(Process)] (MainGroup) {};
% \end{scope}
% --- Connections ---
% \draw[->, thick, color=gray!80] (Input) -- (Process);
\end{tikzpicture}
\end{document}Best Practices
最佳实践
- Relative Positioning: Use ,
right=of Nodefor layout stability. Adjust distances viabelow=of Nodein thenode distanceoptions.tikzpicture - Grouping: Use the library and
fitstyle to draw background boxes around related nodes. Always place these in agroupblock.\begin{scope}[on background layer] - Orthogonal Edges: Use and
-|path operations for clean, orthogonal lines (e.g.,|-).(A) -| (B) - Conciseness: Keep node text short. Use for line breaks and
\\for secondary details.\scriptsize
- 相对定位:使用、
right=of Node确保布局稳定。可通过below=of Node选项中的tikzpicture调整间距。node distance - 分组:使用库和
fit样式在相关节点周围绘制背景框。请务必将这些代码放在group块中。\begin{scope}[on background layer] - 正交连线:使用和
-|路径操作绘制整洁的正交线条(例如|-)。(A) -| (B) - 简洁性:保持节点文本简短。使用换行,使用
\\标注次要细节。\scriptsize