노드 매트릭스에 여러 노드 수집

노드 매트릭스에 여러 노드 수집

최종 노드에 크기/정렬 문제가 있습니다. 여기에 이미지 설명을 입력하세요

실제로 저는 노드를 서투르게 인쇄한 다음 fit node를 사용하여 여러 하위 항목을 다루었습니다.

여기에 이미지 설명을 입력하세요

예쁘지 않아요. 더 똑똑하고 자연스러운 것이 있어야합니다.

MWE

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,shadows,fit,matrix}
\usepackage{duckuments}

\begin{document}

\def\myimageA{\includegraphics[width=2cm]{example-image-duck}}
\def\myimageB{\includegraphics[width=1cm]{example-image-duck}}
\def\d{\textbf{Selling group}}
\def\e{\textbf{Investors}}


\begin{tikzpicture}[
        font=\sffamily,
        level1/.style={
            rounded corners, 
            fill=#1,
            inner sep=5pt,
            text=black,
            text centered,
            opacity = 0.5,
            text opacity = 1,
        },
        level2/.style={
            rounded corners, 
            fill=#1,
            inner sep=7pt,
            text=black,
            text centered,
            opacity = 0.5,
            text opacity = 1,
        },
        rectnode/.style={
            rounded corners, 
            fill=#1,
            inner sep=7pt,
            text=black,
            text centered,
            text opacity = 1,
        },
        level4/.style={
            fill=#1,
            draw=gray,
            inner sep=5pt,
            text=black,
            text width=1.5cm, 
            text centered,
            font=\tiny,
            anchor=north,
            opacity = 0.5,
            text opacity = 1,
        },
        myline/.style={
            draw=gray,
            opacity=0.7,
            arrows = {-latex},
            line width=1pt,
        },
    ]
    \matrix[
        matrix of nodes, 
        column sep=0.5ex, 
        row sep=3ex, 
        row 1/.style={nodes={level1={gray}}},
        row 2/.style={nodes={level2={gray}}},
        row 3/.style={nodes={rectnode={gray}}},
        row 4/.style={nodes={level4={gray}}},
        row 5/.style={nodes={rectnode={gray}}},
    ] (m) {
    &       &       & {\myimageA}               \\
    &       &       & {\myimageB}                   \\
    & {\myimageB}   &       & {\myimageB}   &       & {\myimageB}   \\
{\d}& {\d}  & {\d}  & {\d}  & {\d}  & {\d}  \\
x   & x     & x     & x     & x     & {\e}  \\  % <- I clumsily put the nodes like this
    }; 
        
    % I certainly should use a \path but not confortable with its syntax.
    \draw[myline] (m-1-4.south) -- (m-2-4);
    \draw[myline] (m-2-4.west) -| (m-3-2);   
    \draw[myline] (m-2-4.east) -| (m-3-6);   
    \draw[myline] (m-2-4.190) -| (m-4-3);    
    \draw[myline] (m-2-4.south) -| (m-3-4);  
    \draw[myline] (m-3-2.west) -| (m-4-1);   
    \draw[myline] (m-3-2.south) -| (m-4-2);      
    \draw[myline] (m-3-4.south) -| (m-4-4);      
    \draw[myline] (m-3-4.east) -| (m-4-5);           
    \draw[myline] (m-3-6.south) -- (m-4-6);              
    \draw[myline] (m-3-6.south) -- (m-4-6);                  
    
    \draw[myline] (m-4-1.south) -- (m-5-1);                  
    \draw[myline] (m-4-2.south) -- (m-5-2);                  
    \draw[myline] (m-4-3.south) -- (m-5-3);                  
    \draw[myline] (m-4-4.south) -- (m-5-4);                  
    \draw[myline] (m-4-5.south) -- (m-5-5);                  
    \draw[myline] (m-4-6.south) -- (m-5-6);                  
    

    \node[align=center,rectnode={gray},inner sep=0pt,fit=(m-5-1)(m-5-2)] {\e};
    \node[align=center,rectnode={gray},inner sep=0pt,fit=(m-5-3)(m-5-5)] {\e};

\end{tikzpicture}
\end{document}

답변1

기존 노드에서 기존 노드의 북쪽 가장자리(북쪽 가장자리의 중심이 아님)까지 수직선을 그리는 구문은 다음과 같습니다.

\draw (node1) -- (node1.south|-node2.north)

따라서 매트릭스의 마지막 행을 제거하고 원하는 "투자자" 노드를 배치하십시오. 나는 그것들을 1.2cm행렬의 마지막 행 아래에 놓았습니다. 첫 번째는 m-4-2노드 아래에 있습니다. 두 번째는 의 중간점 아래에 있습니다 m-4-4.m-4-5 의 중간점 아래에 있습니다 .

그런 다음 명령

\draw[myline] (m-4-1.south) -- (m-4-1.south|-new1.north);

(m-4-1.south)직선에서 의 북쪽 가장자리까지 그립니다 (new1). 이것이 제가 첫 번째 "투자자" 노드라고 명명한 것입니다.

여기에 이미지 설명을 입력하세요

\matrix[
    matrix of nodes, 
    column sep=0.5ex, 
    row sep=3ex, 
    row 1/.style={nodes={level1={gray}}},
    row 2/.style={nodes={level2={gray}}},
    row 3/.style={nodes={rectnode={gray}}},
    row 4/.style={nodes={level4={gray}}},
    row 5/.style={nodes={rectnode={gray}}},
] (m) {
&       &       & {\myimageA}               \\
&       &       & {\myimageB}                   \\
& {\myimageB}   &       & {\myimageB}   &       & {\myimageB}   \\
{\d}& {\d}  & {\d}  & {\d}  & {\d}  & {\d}  \\
%x   & x     & x     & x     & x     & {\e}  \\  % <- I clumsily put the nodes like this
}; 
        
\draw[myline] (m-1-4.south) -- (m-2-4);
\draw[myline] (m-2-4.west) -| (m-3-2);   
\draw[myline] (m-2-4.east) -| (m-3-6);   
\draw[myline] (m-2-4.190) -| (m-4-3);    
\draw[myline] (m-2-4.south) -| (m-3-4);  
\draw[myline] (m-3-2.west) -| (m-4-1);   
\draw[myline] (m-3-2.south) -| (m-4-2);      
\draw[myline] (m-3-4.south) -| (m-4-4);      
\draw[myline] (m-3-4.east) -| (m-4-5);           
\draw[myline] (m-3-6.south) -- (m-4-6);              
\draw[myline] (m-3-6.south) -- (m-4-6);  

\node[align=center, rectnode={gray}, minimum width=5cm] at ([yshift=-1.2cm]m-4-2)(new1){\e}; 
\node[align=center, rectnode={gray}, minimum width=3.5cm]at ([yshift=-1.2cm]$.5*(m-4-4)+.5*(m-4-5)$)(new2){\e};
\node[align=center, rectnode={gray}]at ([yshift=-1.2cm]m-4-6)(new3){\e};

\draw[myline] (m-4-1.south) -- (m-4-1.south|-new1.north);                  
\draw[myline] (m-4-2.south) -- (new1);                  
\draw[myline] (m-4-3.south) -- (m-4-3.south|-new1.north);                  
\draw[myline] (m-4-4.south) -- (m-4-4.south|-new2.north);                  
\draw[myline] (m-4-5.south) -- (m-4-5.south|-new2.north);                  
\draw[myline] (m-4-6.south) -- (new3); 

관련 정보