tikz-flowchart

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

TikZ 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 (
dataNode
,
opNode
, etc.) as needed for the specific content.
当在本项目中被要求「创建流程图」或「绘制图表」时,请以下方模板为起点。可根据具体内容调整样式(如
dataNode
opNode
等)。

Style Guide

样式指南

Colors

配色方案

The template uses a Google Material-like palette:
  • Green (
    greenFill
    /
    greenStroke
    )
    : Data, Inputs, Outputs, Tensors.
  • Orange/Memory (
    memFill
    /
    memStroke
    )
    : Memory, Weights, Checkpoints.
  • Blue/Core (
    coreFill
    /
    coreStroke
    )
    : Operations, Compute Kernels, Processes.
  • Pink/Optimization (
    optFill
    /
    optStroke
    )
    : Optimizations, Special Steps.
  • Yellow/Process (
    procFill
    /
    procStroke
    )
    : General Processing Steps.
本模板采用类Google Material配色方案:
  • 绿色(
    greenFill
    /
    greenStroke
    :数据、输入、输出、张量。
  • 橙色/内存(
    memFill
    /
    memStroke
    :内存、权重、检查点。
  • 蓝色/核心(
    coreFill
    /
    coreStroke
    :操作、计算内核、流程。
  • 粉色/优化(
    optFill
    /
    optStroke
    :优化、特殊步骤。
  • 黄色/流程(
    procFill
    /
    procStroke
    :通用处理步骤。

Standard Nodes

标准节点

  • dataNode
    : Rectangles for data flow (green).
  • memNode
    : Cylinders for storage/weights (orange).
  • opNode
    : Rectangles for operations (blue).
  • kernelBox
    : Dashed containers for grouping internal kernel logic.
  • group
    : Dashed background containers for logical grouping of phases/stages.
  • 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

最佳实践

  1. Relative Positioning: Use
    right=of Node
    ,
    below=of Node
    for layout stability. Adjust distances via
    node distance
    in the
    tikzpicture
    options.
  2. Grouping: Use the
    fit
    library and
    group
    style to draw background boxes around related nodes. Always place these in a
    \begin{scope}[on background layer]
    block.
  3. Orthogonal Edges: Use
    -|
    and
    |-
    path operations for clean, orthogonal lines (e.g.,
    (A) -| (B)
    ).
  4. Conciseness: Keep node text short. Use
    \\
    for line breaks and
    \scriptsize
    for secondary details.
  1. 相对定位:使用
    right=of Node
    below=of Node
    确保布局稳定。可通过
    tikzpicture
    选项中的
    node distance
    调整间距。
  2. 分组:使用
    fit
    库和
    group
    样式在相关节点周围绘制背景框。请务必将这些代码放在
    \begin{scope}[on background layer]
    块中。
  3. 正交连线:使用
    -|
    |-
    路径操作绘制整洁的正交线条(例如
    (A) -| (B)
    )。
  4. 简洁性:保持节点文本简短。使用
    \\
    换行,使用
    \scriptsize
    标注次要细节。