如何使用 tikz 集中流程图块?

如何使用 tikz 集中流程图块?

我正在尝试创建一个流程图,改编自流程图的 tikz 容器中的标题但区块并不集中(我无法上传图片)。

!(https://ibb.co/Dt8Q3L3

我使用的代码:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows.meta,calc,fit,backgrounds,shapes.multipart,positioning}
\tikzset{box/.style={draw, rectangle, rounded corners, thick, node 
distance=7em, 
text width=6em, text centered, minimum height=3.5em}}
\tikzset{every node/.style={font=\scriptsize}}

\PreviewEnvironment{tikzpicture}

\setlength\PreviewBorder{4pt}%

\begin{document}

\tikzset{block/.style={rectangle split, draw, rectangle split parts=2,
text width=14em, text centered, rounded corners, minimum height=4em},
grnblock/.style={rectangle, draw, fill=green!20, text width=10em, text centered, rounded corners, minimum height=4em}, 
whtblock/.style={rectangle, draw, fill=white!20, text width=10em, text centered, minimum height=4em},    
line/.style={draw, -{Latex[length=2mm,width=1mm]}},
cloud/.style={draw, ellipse,fill=white!20, node distance=3cm,    minimum height=4em},  
container/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded
corners,fill=yellow!20,minimum height=4cm}}

\begin{tikzpicture}[node distance = 1.25cm, auto]

  \node [whtblock,font=\fontsize{10}{0}\selectfont] (MicFEM) {Finite element mesh};   

\node [whtblock, below=of MicFEM, node distance=2.5cm,font=\fontsize{10}{0}\selectfont] (ROM) {Generate Reduced Order};

\node [grnblock, left=of MicFEM,,node distance=7cm,font=\fontsize{10}{0}\selectfont] (Morph) {Text text text text text};    

 \node [block, right=of MicFEM,node distance=7cm,rectangle split part fill={orange!20,blue!5},font=\fontsize{10}{0}\selectfont] (ConstElasProp) {Constituent
\nodepart[text width=7.5cm]{two} - Text text text text text;\\[0.3em]- Text text text text text;\\[0.3em]- Text text text text text;\\[0.3em]- Text text text text text.};

\node [whtblock, below=of ROM, node distance=2.5cm,font=\fontsize{9}{0}\selectfont] (CfTns) {Compute coefficient};

\node [whtblock, below=of CfTns, node distance=3.5cm,font=\fontsize{10}{0}\selectfont] (STAGE1) {First stage};

\node [whtblock, right=of STAGE1,font=\fontsize{10}{0}\selectfont] (STAGE2) {Second stage};

\node [whtblock, right=of STAGE2,font=\fontsize{10}{0}\selectfont] (STAGE3) {Third stage};

\node [whtblock, right=of STAGE3,font=\fontsize{10}{0}\selectfont] (STAGE4) {Fourth stage};

\node [whtblock, below=of STAGE4,font=\fontsize{10}{0}\selectfont] (STAGE5) {Fifth stage};

\node [whtblock, left=of STAGE5,font=\fontsize{10}{0}\selectfont] (STAGE6) {Sixth stage};

\node [whtblock, left=of STAGE6,font=\fontsize{10}{0}\selectfont] (STAGE7) {Seventh stage};

\node [block, below=of STAGE7, node distance=3cm,rectangle split part fill={blue!20,white},font=\fontsize{10}{0}\selectfont] (Output) {\textbf{Results}
\nodepart[text width=7cm]{two}Text text text text text\\Text text text text text};

\begin{scope}[on background layer]
  \coordinate (aux1) at ([yshift=3mm]MicFEM.north);
  \node [container,fit=(aux1) (ROM)(CfTns)] (MICRO) {};
  \node at (MICRO.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] {\textbf{Microscale}};
%-----------------------------------------------------------
  \coordinate (aux2) at ([yshift=3mm]STAGE1.north);
  \node[container, fit=(aux2) (STAGE1) (STAGE2) (STAGE3) (STAGE4) (STAGE5) (STAGE6) (STAGE7)] (MACRO) {};
  \node at (MACRO.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] 
  (MACRO-label) {\textbf{Implementation}};
\end{scope}

\path [line] (MicFEM) -- (ROM);
\path [line] (ROM) -- (CfTns);
\path [line] (STAGE1) -- (STAGE2);
\path [line] (STAGE2) -- (STAGE3);
\path [line] (STAGE3) -- (STAGE4);
\path [line] (STAGE4) -- (STAGE5);
\path [line] (STAGE5) -- (STAGE6);
\path [line] (STAGE6) -- (STAGE7);
\path [line] (MICRO) -- (MACRO-label);
\path [line] (Morph) -- (MicFEM);
\path [line] (ConstElasProp) -- (MicFEM);
\path [line] (MACRO) -- (Output);

\end{tikzpicture}
\end{document}

此外,我想将“构成”块的图标对齐到左侧。

有人能帮助我进行这些更改吗?

答案1

这应该有帮助

在此处输入图片描述

所做的更改

        \coordinate (aux3) at (MACRO.south);
        \node [block, below=1cm of aux3, rectangle split part fill={blue!20,white},font=\fontsize{10}{0}\selectfont] (Output) {\textbf{Results}
        \nodepart[text width=7cm]{two}Text text text text text\\Text text text text text};
        \path [line] (aux3) -- (Output);    

        \path [line] (MICRO) -| (MACRO-label);  

平均能量损失

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows.meta,calc,fit,backgrounds,shapes.multipart,positioning}
\tikzset{box/.style={draw, rectangle, rounded corners, thick, node 
        distance=7em, 
        text width=6em, text centered, minimum height=3.5em}}
\tikzset{every node/.style={font=\scriptsize}}

\PreviewEnvironment{tikzpicture}

\setlength\PreviewBorder{4pt}%

\begin{document}
    
    \tikzset{block/.style={rectangle split, draw, rectangle split parts=2,
            text width=14em, text centered, rounded corners, minimum height=4em},
        grnblock/.style={rectangle, draw, fill=green!20, text width=10em, text centered, rounded corners, minimum height=4em}, 
        whtblock/.style={rectangle, draw, fill=white!20, text width=10em, text centered, minimum height=4em},    
        line/.style={draw, -{Latex[length=2mm,width=1mm]}},
        cloud/.style={draw, ellipse,fill=white!20, node distance=3cm,    minimum height=4em},  
        container/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded
            corners,fill=yellow!20,minimum height=4cm}}
    
    \begin{tikzpicture}[node distance = 1.25cm, auto]
        
        \node [whtblock,font=\fontsize{10}{0}\selectfont] (MicFEM) {Finite element mesh};   
        
        \node [whtblock, below=of MicFEM, node distance=2.5cm,font=\fontsize{10}{0}\selectfont] (ROM) {Generate Reduced Order};
        
        \node [grnblock, left=of MicFEM,,node distance=7cm,font=\fontsize{10}{0}\selectfont] (Morph) {Text text text text text};    
        
        \node [block, right=of MicFEM,node distance=7cm,rectangle split part fill={orange!20,blue!5},font=\fontsize{10}{0}\selectfont] (ConstElasProp) {Constituent
            \nodepart[text width=7.5cm]{two} - Text text text text text;\\[0.3em]- Text text text text text;\\[0.3em]- Text text text text text;\\[0.3em]- Text text text text text.};
        
        \node [whtblock, below=of ROM, node distance=2.5cm,font=\fontsize{9}{0}\selectfont] (CfTns) {Compute coefficient};
        
        \node [whtblock, below=of CfTns, node distance=3.5cm,font=\fontsize{10}{0}\selectfont] (STAGE1) {First stage};
        
        \node [whtblock, right=of STAGE1,font=\fontsize{10}{0}\selectfont] (STAGE2) {Second stage};
        
        \node [whtblock, right=of STAGE2,font=\fontsize{10}{0}\selectfont] (STAGE3) {Third stage};
        
        \node [whtblock, right=of STAGE3,font=\fontsize{10}{0}\selectfont] (STAGE4) {Fourth stage};
        
        \node [whtblock, below=of STAGE4,font=\fontsize{10}{0}\selectfont] (STAGE5) {Fifth stage};
        
        \node [whtblock, left=of STAGE5,font=\fontsize{10}{0}\selectfont] (STAGE6) {Sixth stage};
        
        \node [whtblock, left=of STAGE6,font=\fontsize{10}{0}\selectfont] (STAGE7) {Seventh stage};
        
        
        \begin{scope}[on background layer]
            \coordinate (aux1) at ([yshift=3mm]MicFEM.north);
            \node [container,fit=(aux1) (ROM)(CfTns)] (MICRO) {};
            \node at (MICRO.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] {\textbf{Microscale}};
            %-----------------------------------------------------------
            \coordinate (aux2) at ([yshift=3mm]STAGE1.north);
            \node[container, fit=(aux2) (STAGE1) (STAGE2) (STAGE3) (STAGE4) (STAGE5) (STAGE6) (STAGE7)] (MACRO) {};
            \node at (MACRO.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] 
            (MACRO-label) {\textbf{Implementation}};
            %%%%%%%%%
            \coordinate (aux3) at (MACRO.south);%..changed
            
        \end{scope}
        
        \path [line] (MicFEM) -- (ROM);
        \path [line] (ROM) -- (CfTns);
        \path [line] (STAGE1) -- (STAGE2);
        \path [line] (STAGE2) -- (STAGE3);
        \path [line] (STAGE3) -- (STAGE4);
        \path [line] (STAGE4) -- (STAGE5);
        \path [line] (STAGE5) -- (STAGE6);
        \path [line] (STAGE6) -- (STAGE7);
        \path [line] (MICRO) -| (MACRO-label);%..changed
        \path [line] (Morph) -- (MicFEM);
        \path [line] (ConstElasProp) -- (MicFEM);

%changed code here
        \node [block, below=1cm of aux3, rectangle split part fill={blue!20,white},font=\fontsize{10}{0}\selectfont] (Output) {\textbf{Results}
            \nodepart[text width=7cm]{two}Text text text text text\\Text text text text text};
                \path [line] (aux3) -- (Output);        
    \end{tikzpicture}
\end{document}

编辑1

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows.meta,calc,fit,backgrounds,shapes.multipart,positioning}
%\tikzset{box/.style={draw, rectangle, rounded corners, thick, node     distance=7em, 
%       text width=6em, text centered, minimum height=3.5em}}
%\tikzset{every node/.style={font=\scriptsize}}

\PreviewEnvironment{tikzpicture}

\setlength\PreviewBorder{4pt}%

\begin{document}
    
    \tikzset{block/.style={rectangle split, draw, rectangle split parts=2,
            text width=14em, text centered, rounded corners, minimum height=4em},
        grnblock/.style={rectangle, draw, fill=green!20, text width=10em, text centered, rounded corners, minimum height=4em}, 
        whtblock/.style={rectangle, draw, fill=white!20, text width=10em, text centered, minimum height=4em},    
        line/.style={draw, -{Latex[length=2mm,width=1mm]}},
        cloud/.style={draw, ellipse,fill=white!20, node distance=3cm,    minimum height=4em},  
        container/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded
            corners,fill=yellow!20,minimum height=4cm}}
    
    \begin{tikzpicture}[node distance = 1.25cm, auto]
        
        \node [whtblock,] (MicFEM) {Finite element mesh};   
        \node [whtblock, below=of MicFEM,] (ROM) {Generate Reduced Order};
        \node [grnblock, left=of MicFEM,,] (Morph) {Text text text text text};    
        \node [block, right=of MicFEM,rectangle split part fill={orange!20,blue!5},] (ConstElasProp) {Constituent
        \nodepart[text width=5cm]{two} - Text text text text text;\\- Text text text text text;\\- Text text text text text;\\- Text text text text text.};
        \node [whtblock, below=of ROM, ] (CfTns) {Compute coefficient};
        \node [whtblock, below=of CfTns, ] (STAGE1) {First stage};
        \node [whtblock, right=of STAGE1,] (STAGE2) {Second stage};
        \node [whtblock, right=of STAGE2] (STAGE3) {Third stage};
        \node [whtblock, right=of STAGE3] (STAGE4) {Fourth stage};
        \node [whtblock, below=of STAGE4] (STAGE5) {Fifth stage};
        \node [whtblock, left=of STAGE5] (STAGE6) {Sixth stage};
        \node [whtblock, left=of STAGE6] (STAGE7) {Seventh stage};
        
        \begin{scope}[on background layer]
        \coordinate (aux1) at ([yshift=3mm]MicFEM.north);
        \node [container,fit=(aux1) (ROM)(CfTns)] (MICRO) {};
        \node at (MICRO.north) [fill=white,draw,] {\textbf{Microscale}};
            %-----------------------------------------------------------
        \coordinate (aux2) at ([yshift=3mm]STAGE1.north);
        \node[container, fit=(aux2) (STAGE1) (STAGE2) (STAGE3) (STAGE4) (STAGE5) (STAGE6) (STAGE7)] (MACRO) {};
        \node at (MACRO.north) [fill=white,draw] (MACRO-label) {\textbf{Implementation}};
            %%%%%%%%%
        \coordinate (aux3) at (MACRO.south);
        \node [block, below=1cm of aux3, rectangle split part fill={blue!20,white},font=\fontsize{10}{0}\selectfont] (Output) {\textbf{Results}
        \nodepart[text width=7cm]{two}Text text text text text\\Text text text text text};
        \end{scope}
        
        \path [line] (MicFEM) -- (ROM);
        \path [line] (ROM) -- (CfTns);
        \path [line] (STAGE1) -- (STAGE2);
        \path [line] (STAGE2) -- (STAGE3);
        \path [line] (STAGE3) -- (STAGE4);
        \path [line] (STAGE4) -- (STAGE5);
        \path [line] (STAGE5) -- (STAGE6);
        \path [line] (STAGE6) -- (STAGE7);
        \path [line] (MICRO) -| (MACRO-label);
        \path [line] (Morph) -- (MicFEM);
        \path [line] (ConstElasProp) -- (MicFEM);
        \path [line] (aux3) -- (Output);        
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容