无空格流程图

无空格流程图

我正在使用以下流程图:

在此处输入图片描述

我用了这个代码:

\documentclass[12pt,a4paper,oneside]{book}  

\usepackage{tikz}  
\usepackage{changepage}  

 \usetikzlibrary{shapes.geometric, arrows,positioning}  
  \tikzstyle{decision} = [diamond, draw, fill=green!80,text width=3.5em, text centered, 
 nodedistance=3.1cm,]   
  \tikzstyle{document} = [rectangle, draw, fill=blue!30,text width=4.7em, text centered, node distance=2.5cm,]   
  \tikzstyle{block1} = [rectangle, draw, fill=green!50,text width=4.5em, text centered, rounded corners, node distance= 3cm, minimum height=3em]  
  \tikzstyle{block} = [rectangle, draw, fill=yellow!50,text width=4.5em, text centered, rounded corners, node distance=2.25cm, minimum height=4em]  
  \tikzstyle{line} = [draw, -latex']  
  \tikzstyle{cloud} = [draw, rectangle ,text centered, fill=red!50, node distance=2cm, minimum height=3em]  

  \tikzstyle{ioi} = [trapezium, draw, trapezium right angle=120,rounded corners, fill=blue!60, node distance=2.8cm, minimum height=2.7em]  
\tikzstyle{io} = [trapezium, draw, trapezium right angle=110,rounded corners, fill=red!20, node distance=1.9cm, minimum height=2.9em]  


\begin{document}


\begin{adjustwidth}{-0.2cm}{-0.2cm}  
\begin{tikzpicture}[node distance = 1.8cm, auto] 

    \node [cloud] (init) {\textbf{  $Star$}};  
    \node [decision, below of=init](A){$(u_{1},\pm v_{1})$ yes, $(\pm u_{0},v)$ not, };  
    \node [decision, left of = A, xshift=-1.5 cm](A1){$(\pm u_{0},v)$ yes, $(u_{1},\pm v_{1})$ not, Sec. \ref{ste12cas1}}; 
    \node [decision, right of = A, xshift=1cm](A2){$(u_{1},\pm v_{1})$ and $(\pm u_{0},v)$ yes}; 
    \node [document, below of=A1, xshift=-2cm, yshift=-1cm](B){Cases {\bf 1a.} to {\bf 1.f}, Prop. \ref{pro3ste12}, Prop. \ref{pro1ste4}};  
    \node [document, below of=A1, xshift=2cm, yshift=-1cm](B1){Cases {\bf 2a.} to {\bf 2.f}, Prop. \ref{pro3ste12}, Prop. \ref{pro1ste96b}}; 
    \node [decision, below of = B,xshift=-1cm, yshift=-0.5cm](C){$\varphi(p)$, 1 or 3 roots, Remark \ref{rem1ste6}};  
    \node [decision, below of = B1,xshift=1cm, yshift=-0.5cm](C1){$\varphi(p)$, 1 or 3 roots, Remark  \ref{rem1ste6}}; 
    \node [document, below of=C, xshift=-1.5cm](CC1){1 root, $p_{0}$};
    \node [document, below of=C, xshift=1.5cm](CC2){3 roots, $p_{0,1,2}$}; 
    \node [document, below of=C1, xshift=-1.5cm](C1C){1 root, $p_{0}$};
    \node [document, below of=C1, xshift=1.5cm](C2C){3 roots, $p_{0,1,2}$};
    \node [block, below of=CC1](CC11){Theo. \ref{the1ste91a}\\ Theo. \ref{the2ste91a}\\ Theo. \ref{the3ste91a}};
    \node [block, below of=CC2](CC21){Theo. \ref{the4ste91a}};
    \node [block, below of=C1C](C1C1){Theo. \ref{the1ste96b}\\ Theo. \ref{the2ste96b}\\ Theo. \ref{the3ste96b}};
    \node [block, below of=C2C](C1C2){Theo. \ref{the5ste91a}};
    
    \path [line] (init) -- (A);   
    \path [line] (init) -- (A1); 
    \path [line] (init) -- (A2); 
    \path [line] (A1) -- (B);   
    \path [line] (A1) -- (B1); 
    \path [line] (B) -- (C);  
    \path [line] (B1) -- (C1); 
    \path [line] (C) -- (CC1); 
    \path [line] (C) -- (CC2); 
    \path [line] (C1) -- (C1C); 
    \path [line] (C1) -- (C2C); 
    \path [line] (CC1) -- (CC11); 
    \path [line] (CC2) -- (CC21); 
    \path [line] (C1C) -- (C1C1); 
    \path [line] (C2C) -- (C1C2); 
    
\end{tikzpicture}  
    \end{adjustwidth}

\end{document}

我的问题是,我需要将其他决策置于 $Start$ 下方,并使其与左侧决策的结构类似,我该怎么做?我希望流程图看起来像这样

在此处输入图片描述

提前致谢!

答案1

在这里,我将详细阐述我在评论中提出的建议,重点关注绝对和相对坐标/位置。

职位

tikz可以使用以下与职位相关的语句:

  • \node (A) at (1,5) {}; % ABSOLUTE coordinate at (1,5)
  • \node[below=of A] (B) {}; % RELATIVE to (A), needs \usetikzlibrary{positioning}
  • \node (C) {}; % IMPLICITLY put at (0,0)

因此大多数时候您可能希望通过前两个来指定节点坐标。

转移到您的代码

以下代码:

  • 使用类standalone,这在开发此类图形时更有用
  • 中间决策(A)绝对at (0,0)
  • (init)对于(A) [above=of A]
  • 将另外两个决策(A1)置于(A2)不同的绝对坐标
  • 其余部分保持不变,但略微修剪
\begin{tikzpicture}[node distance = 1.8cm, auto] 
Let's demonstrate:

    % ~~~ new root node at (0,0), which is an absolute position ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    \node [decision]            (A) at (0,0)        {$(u_{1},\pm v_{1})$ yes, $(\pm u_{0},v)$ not, };  

    % ~~~ placing node (init) RELATIVE to (A), above a ~~~~~~~~~~~~~~~
    \node [cloud, above=of A]   (init)  {\textbf{  $Star$}};  
    
    % ~~~ placing the left decision (A1) at new ABSOLUTE coordinate (-10,0) ~~~~~~~~~~~
    \node [decision]    (A1) at (-10,0) {$(\pm u_{0},v)$ yes, $(u_{1},\pm v_{1})$ not, Sec. \ref{ste12cas1}}; 
    
    % ~~~ placing the right decision (A2) at new ABSOLUTE coordinate (15,0) ~~~~~~~~~~~
    \node [decision]    (A2) at (+15,0) {$(u_{1},\pm v_{1})$ and $(\pm u_{0},v)$ yes}; 
    
    % ~~~ rest, in fragments ... ~~~~~~~~~~~~~~~~
    \node [document, below of=A1, xshift=-2cm, yshift=-1cm](B){Cases {\bf 1a.} to {\bf 1.f}, Prop. \ref{pro3ste12}, Prop. \ref{pro1ste4}};  
    \node [document, below of=A1, xshift=2cm, yshift=-1cm](B1){Cases {\bf 2a.} to {\bf 2.f}, Prop. \ref{pro3ste12}, Prop. \ref{pro1ste96b}}; 
    \node [decision, below of = B,xshift=-1cm, yshift=-0.5cm](C){$\varphi(p)$, 1 or 3 roots, Remark \ref{rem1ste6}};  
    \node [decision, below of = B1,xshift=1cm, yshift=-0.5cm](C1){$\varphi(p)$, 1 or 3 roots, Remark  \ref{rem1ste6}}; 

    
    \path [line] (init) -- (A);   
    \path [line] (init) -- (A1); 
    \path [line] (init) -- (A2); 
    \path [line] (A1) -- (B);   
    \path [line] (A1) -- (B1); 
    \path [line] (B) -- (C);  
    \path [line] (B1) -- (C1); 
\end{tikzpicture} 

观察结果

对于类来说,book你的图表似乎太大了。我建议采用不同的方法,例如在 tex.stackexchange 上描述

结果和代码

第一张图显示了我上面的描述。第二张图显示了您的代码以供比较。

结果

%\documentclass[12pt,a4paper,oneside]{book}  
\documentclass[10pt,border=3mm,tikz]{standalone} % better during development of the flowchart

\usepackage{tikz}  
\usepackage{changepage}  

\usetikzlibrary{shapes.geometric, arrows,positioning}  

  \tikzstyle{decision} = [diamond, draw, fill=green!80,text width=3.5em,
                          text centered, node distance=3.1cm,]% <<< typo !!!
  \tikzstyle{document} = [rectangle, draw, fill=blue!30,text width=4.7em, 
                          text centered, node distance=2.5cm,]   
  \tikzstyle{block1}   = [rectangle, draw, fill=green!50,text width=4.5em, 
                          text centered, rounded corners, node distance= 3cm, minimum height=3em]  
  \tikzstyle{block}    = [rectangle, draw, fill=yellow!50,text width=4.5em,
                          text centered, rounded corners, node distance=2.25cm, minimum height=4em]  
  \tikzstyle{line}     = [draw, -latex']  
  \tikzstyle{cloud}    = [draw, rectangle ,text centered, fill=red!50, node distance=2cm, minimum height=3em]  

  \tikzstyle{ioi}      = [trapezium, draw, trapezium right angle=120,rounded corners, fill=blue!60, 
                          node distance=2.8cm, minimum height=2.7em]  
  \tikzstyle{io}       = [trapezium, draw, trapezium right angle=110,rounded corners, fill=red!20, 
                          node distance=1.9cm, minimum height=2.9em]  


\begin{document}

\begin{tikzpicture}[node distance = 1.8cm, auto] 
Let's demonstrate:

    % ~~~ new root node at (0,0), which is an absolute position ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    \node [decision]            (A) at (0,0)        {$(u_{1},\pm v_{1})$ yes, $(\pm u_{0},v)$ not, };  

    % ~~~ placing node (init) RELATIVE to (A), above a ~~~~~~~~~~~~~~~
    \node [cloud, above=of A]   (init)  {\textbf{  $Star$}};  
    
    % ~~~ placing the left decision (A1) at new ABSOLUTE coordinate (-10,0) ~~~~~~~~~~~
    \node [decision]    (A1) at (-10,0) {$(\pm u_{0},v)$ yes, $(u_{1},\pm v_{1})$ not, Sec. \ref{ste12cas1}}; 
    
    % ~~~ placing the right decision (A2) at new ABSOLUTE coordinate (15,0) ~~~~~~~~~~~
    \node [decision]    (A2) at (+15,0) {$(u_{1},\pm v_{1})$ and $(\pm u_{0},v)$ yes}; 
    
    % ~~~ rest, in fragments ... ~~~~~~~~~~~~~~~~
    \node [document, below of=A1, xshift=-2cm, yshift=-1cm](B){Cases {\bf 1a.} to {\bf 1.f}, Prop. \ref{pro3ste12}, Prop. \ref{pro1ste4}};  
    \node [document, below of=A1, xshift=2cm, yshift=-1cm](B1){Cases {\bf 2a.} to {\bf 2.f}, Prop. \ref{pro3ste12}, Prop. \ref{pro1ste96b}}; 
    \node [decision, below of = B,xshift=-1cm, yshift=-0.5cm](C){$\varphi(p)$, 1 or 3 roots, Remark \ref{rem1ste6}};  
    \node [decision, below of = B1,xshift=1cm, yshift=-0.5cm](C1){$\varphi(p)$, 1 or 3 roots, Remark  \ref{rem1ste6}}; 

    
    \path [line] (init) -- (A);   
    \path [line] (init) -- (A1); 
    \path [line] (init) -- (A2); 
    \path [line] (A1) -- (B);   
    \path [line] (A1) -- (B1); 
    \path [line] (B) -- (C);  
    \path [line] (B1) -- (C1); 
\end{tikzpicture} 


%\begin{adjustwidth}{-0.2cm}{-0.2cm}  
\begin{tikzpicture}[node distance = 1.8cm, auto] 
    \node [cloud] (init) {\textbf{  $Star$}};  
    \node [decision, below of=init](A){$(u_{1},\pm v_{1})$ yes, $(\pm u_{0},v)$ not, };  
    \node [decision, left of = A, xshift=-1.5 cm](A1){$(\pm u_{0},v)$ yes, $(u_{1},\pm v_{1})$ not, Sec. \ref{ste12cas1}}; 
    \node [decision, right of = A, xshift=1cm](A2){$(u_{1},\pm v_{1})$ and $(\pm u_{0},v)$ yes}; 
    \node [document, below of=A1, xshift=-2cm, yshift=-1cm](B){Cases {\bf 1a.} to {\bf 1.f}, Prop. \ref{pro3ste12}, Prop. \ref{pro1ste4}};  
    \node [document, below of=A1, xshift=2cm, yshift=-1cm](B1){Cases {\bf 2a.} to {\bf 2.f}, Prop. \ref{pro3ste12}, Prop. \ref{pro1ste96b}}; 
    \node [decision, below of = B,xshift=-1cm, yshift=-0.5cm](C){$\varphi(p)$, 1 or 3 roots, Remark \ref{rem1ste6}};  
    \node [decision, below of = B1,xshift=1cm, yshift=-0.5cm](C1){$\varphi(p)$, 1 or 3 roots, Remark  \ref{rem1ste6}}; 
    \node [document, below of=C, xshift=-1.5cm](CC1){1 root, $p_{0}$};
    \node [document, below of=C, xshift=1.5cm](CC2){3 roots, $p_{0,1,2}$}; 
    \node [document, below of=C1, xshift=-1.5cm](C1C){1 root, $p_{0}$};
    \node [document, below of=C1, xshift=1.5cm](C2C){3 roots, $p_{0,1,2}$};
    \node [block, below of=CC1](CC11){Theo. \ref{the1ste91a}\\ Theo. \ref{the2ste91a}\\ Theo. \ref{the3ste91a}};
    \node [block, below of=CC2](CC21){Theo. \ref{the4ste91a}};
    \node [block, below of=C1C](C1C1){Theo. \ref{the1ste96b}\\ Theo. \ref{the2ste96b}\\ Theo. \ref{the3ste96b}};
    \node [block, below of=C2C](C1C2){Theo. \ref{the5ste91a}};
    
    \path [line] (init) -- (A);   
    \path [line] (init) -- (A1); 
    \path [line] (init) -- (A2); 
    \path [line] (A1) -- (B);   
    \path [line] (A1) -- (B1); 
    \path [line] (B) -- (C);  
    \path [line] (B1) -- (C1); 
    \path [line] (C) -- (CC1); 
    \path [line] (C) -- (CC2); 
    \path [line] (C1) -- (C1C); 
    \path [line] (C1) -- (C2C); 
    \path [line] (CC1) -- (CC11); 
    \path [line] (CC2) -- (CC21); 
    \path [line] (C1C) -- (C1C1); 
    \path [line] (C2C) -- (C1C2);    
\end{tikzpicture}  
%    \end{adjustwidth}

\end{document}

相关内容