如何在 tikzpicture 的两个块之间添加水平空间

如何在 tikzpicture 的两个块之间添加水平空间

我需要 (block6) 和 (block7) 之间的水平空间。有两个单独的块,但都被覆盖了。以下是代码:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}[font=\small,thick, node distance = 0.5cm, column sep=2cm]
\node[draw,
    rounded rectangle,
    minimum width=2.0cm,
    minimum height=0.7cm](block1){Start};

\node[draw,
    trapezium,
    trapezium left angle = 65,
    trapezium right angle = 115,
    trapezium stretches,
    below=of block1,
    minimum width=2cm,
    minimum height=0.7cm] (block2) { ABC };

\node[draw,
    below=of block2,
    minimum width=2cm,
    minimum height=0.7cm] (block3) {Xyz};

\node[draw,
    rectangle,
    below=of block3,
    minimum width=2cm,
    minimum height=0.7cm] (block4) { xxxxxxuu};

\node[draw,
    rectangle,
    below=of block4,
    minimum width=3cm,
    minimum height=0.7cm] (block5) {yshsh};

\node[draw,
    trapezium,
    trapezium left angle = 65,
    trapezium right angle = 115,
    trapezium stretches,
    node distance=0.5cm,
    below left=of block5,
    minimum width=2cm,
    minimum height=0.7cm] (block6) { ahahshsaaaaakakskadksadjasjasjffjasjfasj};

\node[draw,
    trapezium,
    trapezium left angle = 65,
    trapezium right angle = 115,
    trapezium stretches,
    node distance=0.5cm,
    below right=of block5,
    minimum width=2cm,
    minimum height=0.7cm] (block7) {hasdasdashdasdjasdaskdka};

\node[draw,
    rectangle,
    node distance=1.5cm,
    below= of block5,
    minimum width=2cm,
    minimum height=0.7cm] (block8) { chshacasdasmdmasd};

\node[draw,
    rectangle,
    below=of block8,
    minimum width=2cm,
    minimum height=0.7cm] (block9) { kdkaskdakskdaskdkasd};

\node[draw,
    rectangle,
    below=of block9,
    minimum width=2cm,
    minimum height=0.7cm] (block10) { cksaskfasfasjfjasfjasfasv };

\draw[-latex] (block1) edge (block2)
    (block2) edge (block3)
    (block3) edge (block4);
\draw[-latex] (block4) edge (block5);
\draw[-latex] (block8) edge (block9);
\draw[-latex] (block9) edge (block10);
\draw[-latex] (block5) -| (block6)
node[pos=0.5,inner sep=2pt, above right]{Partially Known};
\draw[-latex] (block5) -| (block7)
node[pos=0.3,inner sep=2pt, above left]{Unknown};
\draw[-latex] (block5) -- (block8)
node[pos=0.5,inner sep=2pt, left]{Known};
\draw[-latex] (block6) |- (block8)
node[pos=0.5,inner sep=0]{};
\draw[-latex] (block7) |- (block8)
node[pos=0.5,inner sep=0]{};
\end{tikzpicture}
\end{figure}
\end{document}

答案1

你的意思是这样的:

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes,positioning,calc}

\begin{document}
    \begin{tikzpicture}[font=\small,thick, node distance = 0.5cm, column sep=2cm,]
        \begin{scope}[every node/.style={draw,minimum width=3.5cm,minimum height=0.7cm},
            trap/.style={trapezium,trapezium left angle = 65,trapezium right angle = 115,trapezium stretches,text width=2.8cm,align=center}]
            \node[rounded rectangle,](block1){Start};
            \node[trap,below=of block1] (block2) {ABC};
            \node[below=of block2] (block3) {Xyz};
            \node[below=of block3] (block4) {xxxxxxuu};
            \node[below=of block4] (block5) {yshsh};
            \node[trap,below left=of block5,xshift=-1.5cm] (block6) {ahahshsa aaaakaksk adksadjas jasjffjasjfasj};
            \node[trap,below right=of block5,xshift=1.5cm] (block7) {hasdasdashd asdjasdaskdka};
            \node[below = of block5,yshift=-2cm] (block8) { chshacasdasmdmasd};
            \node[below=of block8] (block9) { kdkaskdakskdaskdkasd};
            \node[below=of block9] (block10) {cksaskfasfasjfjasfjasfasv};
        \end{scope}
        
        \draw[-latex] (block1) edge (block2)
        (block2) edge (block3)
        (block3) edge (block4);
        \draw[-latex] (block4) edge (block5);
        \draw[-latex] (block8) edge (block9);
        \draw[-latex] (block9) edge (block10);
        \draw[-latex] (block5) -| (block6);
        \path (block5) -- (block5 -| block6) node[inner sep=2pt,anchor=south,midway]{Partially Known};
        \draw[-latex] (block5) -| (block7);
        \path (block5) -- (block5 -| block7) node[inner sep=2pt,anchor=south,midway] {Unknown};
        \draw[-latex] (block5) -- (block8) node[pos=0.5,inner sep=2pt, anchor=east]{Known};
        \draw[-latex] (block6) |- (block8);
        \draw[-latex] (block7) |- (block8);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容