流程图绘制问题

流程图绘制问题

我正在尝试绘制流程图。但节点重叠了。这是代码:

\documentclass[12pt]{article}
\usepackage{cite}
\usepackage{graphicx}
\usepackage[a4paper, margin=1 in]{geometry}
\hfuzz=20pt
\vfuzz=20pt
\hbadness=2000
\vbadness=\maxdimen
\setlength{\arrayrulewidth}{0.5mm}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=white!30 ]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, text width=6cm, draw=black, fill=white!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=6cm, draw=black, fill=white!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, text width=6cm, draw=black, fill=white!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\nocite{*}
\begin{tikzpicture}[node distance=2cm]
\node (start) [startstop] {Start};
\node (in1) [io, below of=start] {Enter A and B and B`(A contains the bigger string)};
\draw [arrow] (start) -- (in1);
\node (pro1) [process, below of=in1] {big sentence: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa};
\draw [arrow] (in1) -- (pro1);
\node (dec1) [decision, below of=pro1] {any condition statement .................};
\draw [arrow] (pro1) -- (dec1);
\node (dec2) [decision, below of=dec1] {again a condition............................................................................};
\draw [arrow] (dec1) -- (dec2);
\node (dec3) [decision, below of=dec1] {Another one.................................................................................};
\draw [arrow] (dec1) -- (dec3);
\end{tikzpicture}
\end{document}

节点不是按顺序排列的,而是重叠的

答案1

您应该使用该库positioning和语法below = of ...

您对节点放置的引用存在一些错误。

该图不适合放在一页上,但您可以在这里找到:

% arara: pdflatex

\documentclass[12pt]{article}
\usepackage[a4paper, margin=1 in]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, positioning}
\tikzset{%
    ,startstop/.style={rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=white!30}
    ,io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, text width=6cm, draw=black, fill=white!30}
    ,process/.style={rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=6cm, draw=black, fill=white!30}
    ,decision/.style={diamond, minimum width=3cm, minimum height=1cm, text centered, text width=6cm, draw=black, fill=white!30}
    ,arrow/.style={thick,->,>=stealth}
    }

\begin{document}
    \begin{tikzpicture}[node distance=.7cm]
    \node (start) [startstop] {Start};
    \node (in1) [io, below = of start] {Enter A and B and B`(A contains the bigger string)};
    \draw [arrow] (start) -- (in1);
    \node (pro1) [process, below = of in1] {big sentence: aaaaaaaaaaaaaaaaaaaaaaaaa\-aaaaaaaaaaaaaaaaaaaaaaaaaaa\-aaaaaaaaaaaaaaaaaaaaaaaa\-aaaaaaaaaaaaaaaaaaaaaaaa\-aaaaaaaaaaaaaaaaaaaaaaaaaa};
    \draw [arrow] (in1) -- (pro1);
    \node (dec1) [decision, below = of pro1] {any condition statement .................};
    \draw [arrow] (pro1) -- (dec1);
    \node (dec2) [decision, below = of dec1] {again a condition...............................\-.............................................};
    \draw [arrow] (dec1) -- (dec2);
    \node (dec3) [decision, below = of dec2] {Another one......................\-.............................\-..............................};
    \draw [arrow] (dec2) -- (dec3);
    \end{tikzpicture}
\end{document}

答案2

根据@LaRiFaRi答案,但有细微的差别(显示另一种可能的代码):

  1. 我搬进tikzsettikzpicture
  2. 我收集的节点的共同特征every node/.style
  3. 而不是white!30我使用的填充颜色white(顺便问一下,是什么颜色white!30?)
  4. 我将节点距离减小到 1cm
  5. 我添加了aspect菱形选项以降低其高度
  6. 并将 brock “长单词”(aaa ...,....)转换为较短的单词,这样 TeX 将能够形成更多行的文本。

    代码:

\documentclass[12pt]{article}
    \usepackage[a4paper, margin=1 in]{geometry}
    \usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.geometric}

\begin{document}
    \begin{tikzpicture}[
node distance=1cm,
every node/.style = {draw, fill=white, align=center, minimum height=1cm},
%
 startstop/.style = {rectangle, rounded corners, minimum width=3cm},
        io/.style = {trapezium, trapezium left angle=70, trapezium right angle=110,
                     text width=6cm},
   process/.style = {rectangle, text width=6cm},
  decision/.style = {diamond, aspect=1.2, text width=6cm},
     arrow/.style = {thick,-stealth}
                        ]
\node (start) [startstop] {Start};
\node (in1) [io,below=of start] {Enter A and B and B`(A contains the bigger string)};
\draw [arrow] (start) -- (in1);
\node (pro1) [process,below=of in1] {big sentence: aaaaaa aaaaa aaaaaa aaaaa aaaaaaa aaaa aaaaaa aaaaaaaaa aaaaaaaa aaaaaaa aaaaa aaaaaaa aaaaaaaaa aaaaaaa aaaaaaaa aaaaaaa a aaa aaaaa aaaaaa aaaaa};
\draw [arrow] (in1) -- (pro1);
\node (dec1) [decision,below=of pro1] {any condition statement .................};
\draw [arrow] (pro1) -- (dec1);
\node (dec2) [decision,below=of dec1] {again a condition ...... ........ ......... ......... .. ..... ..... .. ... ..... ... .... .... .... .... ...};
\draw [arrow] (dec1) -- (dec2);
\node (dec3) [decision,below=of dec1] {Another one... ..... ..... .... ... .... ..... .... ... .... .... ...... ... .... ..... .. ...... ...... .....};
\draw [arrow] (dec1) -- (dec3);
\end{tikzpicture}
\end{document}

相关内容