편집하다

편집하다

약 일주일 전에 @cfr은 이미 매우 괜찮은 솔루션을 제공했습니다.내 트리 다이어그램의 수직 공간 절약. 불행히도 내 초기 상황은 이제 바뀌었고 내 능력을 넘어서는 수평적 나무를 마주하게 되었습니다. 실제로 그것은 이전 질문과 동일한 트리입니다. 차이점은 세 가지 주요 가지 중 하나가 이제 나머지 두 가지 주요 가지의 일부라는 점입니다. 내가 시도한 것은 다음과 같습니다.

\documentclass[a4paper,11pt]{article}
\usepackage[edges]{forest}

%Defining tikz classes for tree diagrams
\tikzset{parent/.style={align=center,text width=3cm,rounded corners=3pt},
    child/.style={align=center,text width=3cm,rounded corners=3pt}
}

\colorlet{col1}{white}
\colorlet{col2}{gray!20}
\colorlet{col3}{gray!40}
\colorlet{col4}{gray!60}

\begin{document}
    \begin{center}
        \resizebox{\linewidth}{!}{%
        \begin{forest}
            forked edges,
            for tree={
                draw,
                rounded corners,
                node options={align=center,},
                text width=2.7cm,
                minimum height=1.5cm,
                parent anchor=children,
            }
            [LMS, fill=col4, parent, s sep=3cm
            [Funktionale \\Anforderungen, for tree={child, fill=col3}
            [Lerninhalte organisieren, tier=first]
            [Lerninhalte erstellen]
            [Lerninhalte abfragen]
            [Kommunikation]
            [Benutzerkonten\-führung]
            [Steuerungs\-funktionen]
            ]
            [Nicht-Funktionale Anforderungen, tier=first, for tree={child, fill=col2}
            [Zuverl{\"a}ssig\-keit]
            [Skalierbar\-keit und Effizienz]
            [Benutzer\-freundlich\-keit]
            [Portierbarkeit]
            [Datenschutz / Informationssicherheit]
            [Erweiterbar\-keit]
            [Anpassbarkeit]
            [Technische Rahmen\-bedinungen, for tree={child, calign=last, fill=col1}
            [System\-architektur]
            [Software\-kriterien]
            [Schnittstellen]
            [Wartung und Support
            [Support\-leistungen]
            [Software-Pflege]
            ]
            ]
            ]
            ]
        \end{forest}
    }
\end{center}
\end{document}

수평 트리

어떤 이유로 줄 바꿈이 있는 노드가 잘 정렬되지 않습니다. 누군가 이 문제를 해결할 수 있는 이유나 방법을 설명해 줄 수 있습니까?

그리고 한 수준의 한 노드만 분리하는 방법이 있나요? 예에서 "Technische Rahmenbedinungen" 노드는 오른쪽으로 2cm 분할되어야 합니다. s sep그냥 전체 레벨에 적용됩니다...

마지막으로, 여기에서 수평 공간을 조금이라도 더 절약할 수 있는 방법을 아는 사람이 있나요? 아직은 텍스트가 너무 작습니다.

나는 또한 이것을 했습니다. 물론 이것은 꽤 좋은 대안이지만 수평이 나를 괴롭힙니다.

    \documentclass[a4paper,11pt,ngerman]{article}
    \usepackage[edges]{forest}
    \usepackage{caption}

    %Defining tikz classes for tree diagrams
    \tikzset{parent/.style={align=center,text width=3cm,rounded corners=3pt},
        child/.style={align=center,text width=3cm,rounded corners=3pt}
    }

    \colorlet{col1}{white}
    \colorlet{col2}{gray!20}
    \colorlet{col3}{gray!40}
    \colorlet{col4}{gray!60}

    \begin{document}
        \begin{center}
            \resizebox*{.75\linewidth}{!}{%
                \begin{forest}
                    forked edges,
                    for tree={
                        grow'=east,
                        draw,
                        rounded corners,
                        text width=2.7cm,
                        node options={align=center},
                    }       
                    [LMS, fill=col4, parent, s sep=1cm
                    [Funktionale \\Anforderungen, for tree={child, fill=col3}
                    [Lerninhalte organisieren]
                    [Lerninhalte erstellen]
                    [Lerninhalte abfragen, calign with current]
                    [Kommunikation]
                    [Benutzerkonten\-führung]
                    [Steuerungs\-funktionen]
                    ]
                    [Nicht-Funktionale Anforderungen, for tree={child, fill=col2}
                    [Zuverl{\"a}ssig\-keit]
                    [Skalierbar\-keit und Effizienz]
                    [Benutzer\-freundlich\-keit]
                    [Portierbarkeit]
                    [Datenschutz/\\Informations-\\sicherheit, calign with current]
                    [Erweiterbar\-keit]
                    [Anpassbarkeit]
                    [Technische Rahmen\-bedinungen, calign=last, for tree={child, fill=col1}
                    [System\-architektur]
                    [Software\-kriterien]
                    [Schnittstellen]
                    [Wartung und Support
                    [Support\-leistungen]
                    [Software-Pflege]
                    ]
                    ]
                    ]
                    ]
                \end{forest}}
                \captionsetup{type=figure}
                \captionof{figure}{Gliederung des UKSH Lastenheft: Subgliederung LMS}
                \label{abb:GliederungUKSHLMS}
            \end{center}
\end{document}

수직 나무

도움을 주셔서 감사합니다!

답변1

첨가

anchor=parent,

트리의 경우 노드가 더 깔끔하게 정렬됩니다.

깔끔한 정렬

특정 노드를 이동하려면 다음을 추가할 수 있습니다.

before drawing tree={x'+=20mm}

문제의 노드에 대해. 예를 들어:

노드를 오른쪽으로 이동

노드의 자손에도 적용하려면 전체 하위 트리에 추가하면 됩니다. 예를 들어:

[Technische Rahmen\-bedinungen, for tree={child, calign=last, fill=col1, before drawing tree={x'+=20mm}}

하위 트리를 오른쪽으로 이동

물론 이것은 이미 다소 불편하게 퍼져 있는 것처럼 보이는 트리에서 더 많은 수평 공간을 사용하는 것입니다. (오른쪽으로 2cm 가야하나요? 이것이 무엇을 나타내든 다른 방식으로 표현할 수 있습니까?)

수평적 공간에 대해 무엇을 제안해야 할지 알기 어렵다. 가장 확실한 제안은 현재 하고 있는 일을 하지 말라는 것입니다.증가하다text width공간이 많이 필요하지 않은 노드에도 유니폼을 사용하는 등 수평 공간 . 그리고 설정을 s sep=3cm통해 수평 공간의 사용이 더욱 증가합니다.

이러한 제약 조건을 희생할 수 있다면 다음과 같이 할 수 있습니다.

재배치된 나무

\documentclass[tikz,multi,border=10pt]{standalone}
\usepackage[edges]{forest}
%Defining tikz classes for tree diagrams
\forestset{%
  parent/.style={text width=3cm,rounded corners=3pt},
  child/.style={rounded corners=3pt},
  my phantom/.style={inner xsep=0pt, draw=none, child anchor=children}
}
\colorlet{col1}{white}
\colorlet{col2}{gray!20}
\colorlet{col3}{gray!40}
\colorlet{col4}{gray!60}

\begin{document}
\begin{forest}
    forked edges,
    for tree={
        draw,
        rounded corners,
        align=center,
        text centered,
        minimum height=1.5cm,
        parent anchor=children,
        anchor=parent,
    },
    before typesetting nodes={%
      where n children=0{}{%
        if content={}{}{%
          text width=27mm
        },
      },
    },
    [LMS, fill=col4, parent
      [Funktionale\\Anforderungen, for tree={child, fill=col3}
        [Lerninhalte\\organisieren, tier=first]
        [Lerninhalte\\erstellen]
        [Lerninhalte\\abfragen]
        [Kommunikation]
        [Benutzerkonten-\\führung]
        [Steuerungs-\\funktionen]
      ]
      [, tier=first, my phantom
        [Nicht-Funktionale\\Anforderungen, tier=second, for tree={child, fill=col2}
          [Zuverl{\"a}ssig\-keit, tier=third]
          [Skalierbar\-keit\\und Effizienz]
          [Benutzer-\\freundlich\-keit]
          [Portierbarkeit]
          [Datenschutz\\/ Informa-\\tionssicherheit]
          [Erweiterbar\-keit]
          [Anpassbarkeit]
          [, my phantom, tier=third
            [Technische\\Rahmen-\\bedinungen, for tree={child, calign=last, fill=col1}
              [System\-architektur]
              [Software\-kriterien]
              [Schnittstellen]
              [Wartung\\und Support
                [Support\-leistungen]
                [Software-Pflege]
              ]
            ]
          ]
        ]
      ]
    ]
\end{forest}
\end{document}

편집하다

위의 내용은 내부적으로 잘 작동합니다 \resizebox....

\documentclass{article}
\usepackage[edges]{forest}
%Defining tikz classes for tree diagrams
\forestset{%
  parent/.style={text width=3cm,rounded corners=3pt},
  child/.style={rounded corners=3pt},
  my phantom/.style={inner xsep=0pt, draw=none, child anchor=children}
}
\colorlet{col1}{white}
\colorlet{col2}{gray!20}
\colorlet{col3}{gray!40}
\colorlet{col4}{gray!60}

\begin{document}
  \resizebox*{\linewidth}{!}{%
\begin{forest}
    forked edges,
    for tree={
        draw,
        rounded corners,
        align=center,
        text centered,
        minimum height=1.5cm,
        parent anchor=children,
        anchor=parent,
    },
    before typesetting nodes={%
      where n children=0{}{%
        if content={}{}{%
          text width=27mm
        },
      },
    },
    [LMS, fill=col4, parent
      [Funktionale\\Anforderungen, for tree={child, fill=col3}
        [Lerninhalte\\organisieren, tier=first]
        [Lerninhalte\\erstellen]
        [Lerninhalte\\abfragen]
        [Kommunikation]
        [Benutzerkonten-\\führung]
        [Steuerungs-\\funktionen]
      ]
      [, tier=first, my phantom
        [Nicht-Funktionale\\Anforderungen, tier=second, for tree={child, fill=col2}
          [Zuverl{\"a}ssig\-keit, tier=third]
          [Skalierbar\-keit\\und Effizienz]
          [Benutzer-\\freundlich\-keit]
          [Portierbarkeit]
          [Datenschutz\\/ Informa-\\tionssicherheit]
          [Erweiterbar\-keit]
          [Anpassbarkeit]
          [, my phantom, tier=third
            [Technische\\Rahmen-\\bedinungen, for tree={child, calign=last, fill=col1}
              [System\-architektur]
              [Software\-kriterien]
              [Schnittstellen]
              [Wartung\\und Support
                [Support\-leistungen]
                [Software-Pflege]
              ]
            ]
          ]
        ]
      ]
    ]
  \end{forest}}
\end{document}

크기가 조정됨

calign with current다음에 추가 Anpassbarkeit:

          [Anpassbarkeit, calign with current]

생산하다

재정렬

관련 정보