如何指定节点的位置

如何指定节点的位置
\documentclass{article}
\usepackage{tikz}
\usepackage{ctex}
\usetikzlibrary{shapes.geometric,arrows}
\begin{document}

\tikzstyle{input}=[diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=red!70]
\tikzstyle{process}=[rectangle, rounded corners, draw=green, fill=purple!30, text centered]
\tikzstyle{output}=[diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black,fill = green!45]

\tikzstyle{arrow}=[thick,->,>=stealth]
\begin{tikzpicture}[node distance=3cm]
\node(sta)[input]{一对一雅思精品课程};
\node(pro1)[process, below of=sta]{雅思口语提高班};
\end{tikzpicture}
\end{document}

我知道如何使用 yshift 或 xshift,但我正在寻找更简单的方法,让我能够指定一个节点与另一个节点的关系中的位置。我记得在某个地方看到过它,还有类似“低于=15cm sta”的内容,但我找不到它。

答案1

继续上面 @Schrödinger's cat 的评论,下面复制了一个类似于您需要的流程图示例(可能),该流程图取自本网站,希望能澄清定位方面的问题——如果没有,请回复您的查询

在此处输入图片描述

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows,positioning}

\tikzset{ 
    process/.style={
        rectangle, 
        minimum width=2cm, 
        minimum height=1cm, 
        align=center, 
        text width=2cm,
        draw
    },
    connector/.style={
        circle, 
        minimum width=1cm, 
        minimum height=0.5cm, 
        align=center, 
        text width=1cm, 
        draw
    },
    arrow/.style={
        thick,
        ->,
        >=stealth
    }
}  

\begin{document}

    \begin{tikzpicture}[
    node distance=1cm and 2cm
    ]
    \node (p0) [] {foo(K)};
    \node (p1) [process, below = 0.2cm of p0, text width=3cm] {search for key K};
    \node (p2) [process, below =of p1, text width=3.5cm] {Create key K for insertion};
    \node (p3) [process, below =of p2,text width=3.5cm] {Attempt to insert};
    \node (retF) [process, right =of p1,, text width=1cm, minimum width=1cm] {return false};
    \node (p4) [process, below =of p3, text width=3cm] {check if flag set};
    \node (retT) [process, right =of p3,text width=1cm, minimum width=1cm] {return true};
    \node (h1) [connector, below =of p4] {bar()};

    \draw [arrow] (p1) -- node[anchor=west] {K not found} (p2);
    \draw [arrow] (p1) -- node[anchor=south] {K found} (retF);
    \draw [arrow] (p2) -- node {} (p3);
    \draw [arrow] (p3) -- node[anchor=east] {failed} (p4);
    \draw [arrow] (p3) -- node[anchor=south] {successful} (retT);
    \draw [arrow] (p4) -- node[anchor=west] {Yes} (h1);
    \draw [arrow] (p4.west) -- ++(-1,0) node[anchor=south,pos=0.5] {No} |- (p1.west);
    \draw [arrow] (h1.west) -- ++(-2.5,0) |- node[anchor=south] {} (p1.west);
    \end{tikzpicture}

\end{document}

相关内容