0
\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}

I know how to use yshift or xshift, but I am looking for something easier that allow me to specify the position of a node in its relaionship with another node. I remember seeing it somewhere and something along the line of"below of=15cm sta" but I cannot find it.

jxhyc
  • 1,121
  • 1
    You are looking for the positioning library, as e.g. described in section 3.8 Placing Nodes Using Relative Placement of pgfmanual v3.1.5. With this library you can position nodes via \node[below=2cm of A](B){...}; provided you have a node A. Note also that \tikzstyle is deprecated. –  May 28 '20 at 03:19
  • 2
    I mean https://tex.stackexchange.com/q/52372 –  May 28 '20 at 03:45

1 Answers1

1

In continuation of the comments by @Schrödinger's cat above an example of a flow chart similar to what you require (probably) taken from this site is reproduced belo and will clarify the positioning aspects hopefully-- in case not, please revert with your query

enter image description here

\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}
js bibra
  • 21,280
  • 2
    This is an example in which actually other tools like chains or matrix may be superior to plain positioning. Plus this example seems to be literally copied from here. –  May 28 '20 at 03:46