체인의 조합

체인의 조합

방금 체인 라이브러리를 사용하기 시작했습니다. 각 체인에 대해 3가지 수준의 이해도를 보여주고 싶습니다.

체인 1. 초기 필드 체인 2. 설명 체인 3. 이미지

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

내 문서의 특정 지점에서 , 그 다음, 마지막으로 . chain 1만 표시하고 싶습니다 .chain 1 & 2chain 1 & 3chain 3

체인을 정렬해야 했는데 문을 사용할 right of수 없습니다 if. 따라서 체인 조합을 갖기 위해 동일한 코드를 조건적으로 사용하려면 약간의 도움이 필요합니다.

여기는 MWE입니다

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\def\Couleur{orange}

\begin{document}


\begin{tikzpicture}[
        start chain=1 going below, 
        start chain=2 going right,
        start chain=3 going below,
        node distance=2mm,
    Champs/.style={
        on chain=1,
        rectangle,
        rounded corners,
        draw=blue!30, 
        very thick,
        text centered,
        text width=3cm,
        minimum height=12mm,
        fill=blue!20
        },
    desc/.style={
        on chain=2,
        rectangle,
        draw=blue!10, 
        very thick,
        text centered,
        text width=6cm,
        minimum height=12mm,
        fill=blue!5
        },
    symb/.style={Champs,
        on chain=3,
        text width=2.3cm,
        },
    every node/.append style = {
        on chain},
    ]

{[start chain=1]
   \node[Champs,]                       (Level1) {Field 1};
   \node[Champs,below=0.1cm of Level1]  (Level2) {Field 2};
   \node[Champs,below=0.1cm of Level2]  (Level3) {Field 3};
   \node[Champs,below=0.1cm of Level3,fill=\Couleur!50]     (Level4) {Field 4};
   \node[Champs,below=0.1cm of Level4]  (Level5) {Field 5};
   \node[Champs,below=0.1cm of Level5]  (Level6) {Field 6};
}

{[start chain=2]
   \node[desc,right=of Level1]      (Desc1) {Description a bit longer 1};
   \node[desc,below=0.1cm of Desc1]     (Desc2) {Description a bit longer 2};
   \node[desc,below=0.1cm of Desc2]     (Desc3) {Description a bit longer 3};
   \node[desc,below=0.1cm of Desc3,fill=\Couleur!10]    (Desc4) {Description a bit longer 4};
   \node[desc,below=0.1cm of Desc4]     (Desc5) {Description a bit longer 4};
   \node[desc,below=0.1cm of Desc5]     (Desc6) {Description a bit longer 6};
}
{
[start chain=3]
   \node[symb,right=of Desc1]           (Symb1) {\includegraphics[width=1cm]{example-image} };
   \node[symb,below=0.1cm of Symb1]     (Symb2) {\includegraphics[width=1cm]{example-image}}; 
   \node[symb,below=0.1cm of Symb2]     (Symb3) {\includegraphics[width=1cm]{example-image} };
   \node[symb,below=0.1cm of Symb3,fill=\Couleur!50] (Symb4) {\includegraphics[width=1cm]{example-image} };
   \node[symb,below=0.1cm of Symb4]     (Symb5) {\includegraphics[width=1cm]{example-image} };
   \node[symb,below=0.1cm of Symb5]     (Symb6) {\includegraphics[width=1cm]{example-image} };
}

\end{tikzpicture}

\end{document}

답변1

체인을 제대로 사용하지 않으신 것 같아요. below=0.1cm of ...이라는 체인을 사용하는 경우 더 이상 모든 를 추가할 필요가 없습니다 going below. 몇 가지 if를 추가했습니다.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\def\Couleur{orange}
\newif\ifChainTwo
\newif\ifChainThree
\begin{document}


\begin{tikzpicture}[
        start chain=1 going below, 
        start chain=2 going below,
        start chain=3 going below,
        node distance=2mm,
    Champs/.style={
        on chain=1,
        rectangle,
        rounded corners,
        draw=blue!30, 
        very thick,
        text centered,
        text width=3cm,
        minimum height=12mm,
        fill=blue!20
        },
    desc/.style={
        on chain=2,
        rectangle,
        draw=blue!10, 
        very thick,
        text centered,
        text width=6cm,
        minimum height=12mm,
        fill=blue!5
        },
    symb/.style={Champs,
        on chain=3,
        text width=2.3cm,
        },
    every node/.append style = {
        on chain},
    ]
%\ChainTwotrue
%\ChainThreetrue
{[start chain=1]
   \node[Champs,alias=Desc1]                       (Level1) {Field 1};
   \node[Champs]  (Level2) {Field 2};
   \node[Champs]  (Level3) {Field 3};
   \node[Champs,fill=\Couleur!50]     (Level4) {Field 4};
   \node[Champs]  (Level5) {Field 5};
   \node[Champs]  (Level6) {Field 6};
}
\ifChainTwo
{[start chain=2]
   \node[desc,right=of Level1]      (Desc1) {Description a bit longer 1};
   \node[desc]     (Desc2) {Description a bit longer 2};
   \node[desc]     (Desc3) {Description a bit longer 3};
   \node[desc,fill=\Couleur!10]    (Desc4) {Description a bit longer 4};
   \node[desc]     (Desc5) {Description a bit longer 4};
   \node[desc]     (Desc6) {Description a bit longer 6};
}
\fi
\ifChainThree
{
[start chain=3]
   \node[symb,right=of Desc1]           (Symb1) {\includegraphics[width=1cm]{example-image} };
   \node[symb]     (Symb2) {\includegraphics[width=1cm]{example-image}}; 
   \node[symb]     (Symb3) {\includegraphics[width=1cm]{example-image} };
   \node[symb,fill=\Couleur!50] (Symb4) {\includegraphics[width=1cm]{example-image} };
   \node[symb]     (Symb5) {\includegraphics[width=1cm]{example-image} };
   \node[symb]     (Symb6) {\includegraphics[width=1cm]{example-image} };
}
\fi
\end{tikzpicture}

\end{document}

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

\ChainTwotrue주석을 해제 하면

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

\ChainThreetrue주석을 해제 하면

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

그리고 둘 다 주석을 제거하면 다음과 같은 결과가 나타납니다.

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

주황색 색상을 좀 더 자동으로 만들 수도 있습니다.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\def\Couleur{orange}
\newif\ifChainTwo
\newif\ifChainThree
\begin{document}


\begin{tikzpicture}[
        start chain=1 going below, 
        start chain=2 going below,
        start chain=3 going below,
        node distance=2mm,
    Champs/.style={
        on chain=1,
        rectangle,
        rounded corners,
        draw=blue!30, 
        very thick,
        text centered,
        text width=3cm,
        minimum height=12mm,
        fill=blue!20,
        cond={4}{fill=\Couleur!50}
        },
    desc/.style={
        on chain=2,
        rectangle,
        draw=blue!10, 
        very thick,
        text centered,
        text width=6cm,
        minimum height=12mm,
        fill=blue!5,
        cond={4}{fill=\Couleur!10}
        },
    symb/.style={Champs,
        on chain=3,
        text width=2.3cm,
        cond={4}{fill=\Couleur!50}
        },
    every node/.append style = {
        on chain},
    cond/.code 2 args={\ifnum\tikzchaincount=#1
     \tikzset{#2}
    \fi}    
    ]
\ChainTwotrue
\ChainThreetrue
{[start chain=1,nodes=Champs]
   \node[Champs,alias=Desc1]                       (Level1) {Field 1};
   \node[Champs]  (Level2) {Field 2};
   \node[Champs]  (Level3) {Field 3};
   \node[Champs]  (Level4) {Field 4};
   \node[Champs]  (Level5) {Field 5};
   \node[Champs]  (Level6) {Field 6};
}
\ifChainTwo
{[start chain=2]
   \node[desc,right=of Level1]      (Desc1) {Description a bit longer 1};
   \node[desc]     (Desc2) {Description a bit longer 2};
   \node[desc]     (Desc3) {Description a bit longer 3};
   \node[desc]    (Desc4) {Description a bit longer 4};
   \node[desc]     (Desc5) {Description a bit longer 4};
   \node[desc]     (Desc6) {Description a bit longer 6};
}
\fi
\ifChainThree
{
[start chain=3]
   \node[symb,right=of Desc1]           (Symb1) {\includegraphics[width=1cm]{example-image} };
   \node[symb]     (Symb2) {\includegraphics[width=1cm]{example-image}}; 
   \node[symb]     (Symb3) {\includegraphics[width=1cm]{example-image} };
   \node[symb] (Symb4) {\includegraphics[width=1cm]{example-image} };
   \node[symb]     (Symb5) {\includegraphics[width=1cm]{example-image} };
   \node[symb]     (Symb6) {\includegraphics[width=1cm]{example-image} };
}
\fi
\end{tikzpicture}

\end{document}

관련 정보