解决方案 1(修改示例)

解决方案 1(修改示例)

你好,我希望有人能帮助我。我想在最后两个框“Prinzip”和“Verstellbarkeit”中添加箭头,就像其他框中的箭头一样。这是我的 Tex-Code:

\documentclass{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{10pt}%
%%%>


\renewcommand{\familydefault}{\sfdefault} % Schrit auf Helvetica (serifenlos)
\usepackage[scaled]{helvet}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[ngerman]{babel}
\usepackage{color}


\usetikzlibrary{arrows,shapes,positioning,shadows,trees}

\tikzset{
  basic/.style  = {draw, text width=4cm, drop shadow, font=\sffamily, rectangle},
  root/.style   = {basic, rounded corners=2pt, thin, align=center,
                   fill=red!70},
  level 2/.style = {basic, rounded corners=2pt, thin,align=center, fill=red!50,
                   text width=8em},
  level 3/.style = {basic, rounded corners=2pt, thin, align=left, fill=green!50,
                    text width=6.5em},
   level 4/.style = {basic, rounded corners=2pt, thin, align=left, fill=green!30,
                    text width=6.5em},
}

\begin{document}
\Large
\begin{tikzpicture}[
  level 1/.style={sibling distance=45mm},
  edge from parent/.style={->,draw},
  >=latex]

% root of the the initial tree, level 1
\node[root] {$ $ \\ \textbf{Fassadenrinne} \\ $ $}
% The first level, as children of the initial tree
  child {node[level 2, below = 6cm, text width=3.8cm] (c1) {H\"ohenverstellung}}
  child {node[level 2, below = 6cm, text width=3.8cm] (c2) {Anpassung der Rinnen-Nennweite}}
  child {node[level 2, below = 6cm, text width=3.8cm] (c3) {Anpassung der Rinnen-Baulänge / Eckverbindungen}}
  child {node[level 2, below = 6cm, text width=3.8cm] (c4) {statische Last (nach DIN EN 1253)}}
  child {node[level 2, below = 6cm, text width=3.8cm] (c5) {Axiale Last}}
  child {node[level 2, below = 6cm, text width=3.8cm] (c6) {Stichkanal-Anschluss}}
  child {node[level 2, below = 6cm, text width=3.8cm] (c7) {Rinnenk\"orper-Verbindung}}
  child {node[level 2, below = 6cm, text width=3.8cm] (c8) {Stirnwand}};

% THE SECOND LVL, relatively positioned nodes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%1.
\begin{scope}[every node/.style={level 3}]
\node [below of = c1, node distance=60pt, xshift=22pt, below = 0.1cm, text width=3.3cm] (c11) {Typ};
\node [below of = c11, node distance=30pt, text width=3.3cm] (c12) {Bedienung};
\node [below of = c12, node distance=39pt, text width=3.3cm] (c13) {Positionierung \\ (allgemein)};
\node [below of = c13, node distance=65pt, text width=3.3cm] (c14) {Positionierung (entlang Rinnen-L\"angs\-achse};
%---------------------------------------------------------------------------------
%2.
%---------------------------------------------------------------------------------
%3.
%---------------------------------------------------------------------------------
%4.
\node [below of = c4, node distance=41pt, xshift=13pt, below = 0.1cm, text width=3.3cm] (c41) {Aufweiten des Rinnenk\"orpers};
\node [below of = c41, text width=3.3cm, node distance=48pt] (c42) {Biegebelastung der Zarge};
%---------------------------------------------------------------------------------
%5.
\node [below of = c5, node distance=60pt, xshift=13pt, below = 0.1cm, text width=3.3cm] (c51) {Querkraft auf H\"ohenverstell\-ung};
\node [below of = c51, node distance=57pt, text width=3.3cm] (c52) {Anbindung: \\ Zarge-Rost};
\node [below of = c52, node distance=57pt, text width=3.3cm] (c53) {Anbindung: \\ Zarge-Rinnen\"orper};
%---------------------------------------------------------------------------------
%6.
\node [below of = c6, node distance=51pt, xshift=13pt, below = 0.1cm, text width=3.3cm] (c61) {Typ};
\node [below of = c61, node distance=30pt, text width=3.3cm] (c62) {Anbindung};
%---------------------------------------------------------------------------------
%8.
\node [below of = c8, node distance=60pt, xshift=13pt, below = 0.1cm, text width=3.3cm] (c81) {H\"ohenverstellung};
\node [below of = c81, node distance=30pt, text width=3.3cm] (c82) {Anbindung};
%---------------------------------------------------------------------------------
\end{scope}

% THE THIRD LVL, relatively positioned nodes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{scope}[every node/.style={level 4}]
\node [below of = c14, node distance=50pt, xshift=22pt, below = 0.1cm, text width=3.3cm] (c111) {Prinzip};
\node [below of = c111, node distance=29pt, text width=3.3cm] (c112) {Verstellbarkeit};
\end{scope}

% lines from each level 1 node to every one of its "children"
\foreach \value in {1,2,3,4}
  \draw[->] (c1.194pt) |- (c1\value.west);

%\foreach \value in {1,...,4}
  %\draw[->] (c2.195) |- (c2\value.west);

%\foreach \value in {1,...,4}
  %\draw[->] (c3.195) |- (c3\value.west);

\foreach \value in {1,2}
  \draw[->] (c4.208) |- (c4\value.west);

\foreach \value in {1,2,3}
  \draw[->] (c5.190) |- (c5\value.west);

\foreach \value in {1,2}
  \draw[->] (c6.199) |- (c6\value.west);

\foreach \value in {1,2}
  \draw[->] (c8.190) |- (c8\value.west);



\end{tikzpicture}
\end{document}

答案1

这个答案包含 2 个解决方案。第一个是请求的修改。第二个演示了如何使用强大的forest包绘制树,这也是我自己可能会做的事情。

解决方案 1(修改示例)

这是一个简单的修改,仅添加了我认为您想要的 2 个箭头:

\documentclass[tikz,border=10pt]{standalone}

\renewcommand{\familydefault}{\sfdefault} % Schrit auf Helvetica (serifenlos)
\usepackage[scaled]{helvet}
\usepackage[ngerman]{babel}

\usetikzlibrary{arrows,shapes,positioning,shadows,trees}

\tikzset{
  basic/.style  = {draw, text width=4cm, drop shadow, font=\sffamily, rectangle},
  root/.style   = {basic, rounded corners=2pt, thin, align=center,
    fill=red!70},
  level 2/.style = {basic, rounded corners=2pt, thin,align=center, fill=red!50,
    text width=8em},
  level 3/.style = {basic, rounded corners=2pt, thin, align=left, fill=green!50,
    text width=6.5em},
  level 4/.style = {basic, rounded corners=2pt, thin, align=left, fill=green!30,
    text width=6.5em},
}

\begin{document}
  \Large
  \begin{tikzpicture}[
    level 1/.style={sibling distance=45mm},
    edge from parent/.style={->,draw},
    >=latex]

    % root of the the initial tree, level 1
    \node[root] {$ $ \\ \textbf{Fassadenrinne} \\ $ $}
    % The first level, as children of the initial tree
    child {node[level 2, below = 6cm, text width=3.8cm] (c1) {H\"ohenverstellung}}
    child {node[level 2, below = 6cm, text width=3.8cm] (c2) {Anpassung der Rinnen-Nennweite}}
    child {node[level 2, below = 6cm, text width=3.8cm] (c3) {Anpassung der Rinnen-Baulänge / Eckverbindungen}}
    child {node[level 2, below = 6cm, text width=3.8cm] (c4) {statische Last (nach DIN EN 1253)}}
    child {node[level 2, below = 6cm, text width=3.8cm] (c5) {Axiale Last}}
    child {node[level 2, below = 6cm, text width=3.8cm] (c6) {Stichkanal-Anschluss}}
    child {node[level 2, below = 6cm, text width=3.8cm] (c7) {Rinnenk\"orper-Verbindung}}
    child {node[level 2, below = 6cm, text width=3.8cm] (c8) {Stirnwand}};

    % THE SECOND LVL, relatively positioned nodes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %1.
    \begin{scope}[every node/.style={level 3}]
      \node [below of = c1, node distance=60pt, xshift=22pt, below = 0.1cm, text width=3.3cm] (c11) {Typ};
      \node [below of = c11, node distance=30pt, text width=3.3cm] (c12) {Bedienung};
      \node [below of = c12, node distance=39pt, text width=3.3cm] (c13) {Positionierung \\ (allgemein)};
      \node [below of = c13, node distance=65pt, text width=3.3cm] (c14) {Positionierung (entlang Rinnen-L\"angs\-achse};
      %---------------------------------------------------------------------------------
      %2.
      %---------------------------------------------------------------------------------
      %3.
      %---------------------------------------------------------------------------------
      %4.
      \node [below of = c4, node distance=41pt, xshift=13pt, below = 0.1cm, text width=3.3cm] (c41) {Aufweiten des Rinnenk\"orpers};
      \node [below of = c41, text width=3.3cm, node distance=48pt] (c42) {Biegebelastung der Zarge};
      %---------------------------------------------------------------------------------
      %5.
      \node [below of = c5, node distance=60pt, xshift=13pt, below = 0.1cm, text width=3.3cm] (c51) {Querkraft auf H\"ohenverstell\-ung};
      \node [below of = c51, node distance=57pt, text width=3.3cm] (c52) {Anbindung: \\ Zarge-Rost};
      \node [below of = c52, node distance=57pt, text width=3.3cm] (c53) {Anbindung: \\ Zarge-Rinnen\"orper};
      %---------------------------------------------------------------------------------
      %6.
      \node [below of = c6, node distance=51pt, xshift=13pt, below = 0.1cm, text width=3.3cm] (c61) {Typ};
      \node [below of = c61, node distance=30pt, text width=3.3cm] (c62) {Anbindung};
      %---------------------------------------------------------------------------------
      %8.
      \node [below of = c8, node distance=60pt, xshift=13pt, below = 0.1cm, text width=3.3cm] (c81) {H\"ohenverstellung};
      \node [below of = c81, node distance=30pt, text width=3.3cm] (c82) {Anbindung};
      %---------------------------------------------------------------------------------
    \end{scope}

    % THE THIRD LVL, relatively positioned nodes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \begin{scope}[every node/.style={level 4}]
      \node [below of = c14, node distance=50pt, xshift=22pt, below = 0.1cm, text width=3.3cm] (c111) {Prinzip};
      \node [below of = c111, node distance=29pt, text width=3.3cm] (c112) {Verstellbarkeit};
    \end{scope}

    % lines from each level 1 node to every one of its "children"
    \foreach \value in {1,2,3,4}
    \draw[->] (c1.194pt) |- (c1\value.west);

    %\foreach \value in {1,...,4}
    %\draw[->] (c2.195) |- (c2\value.west);

    %\foreach \value in {1,...,4}
    %\draw[->] (c3.195) |- (c3\value.west);

    \foreach \value in {1,2}
    \draw[->] (c4.208) |- (c4\value.west);

    \foreach \value in {1,2,3}
    \draw[->] (c5.190) |- (c5\value.west);

    \foreach \value in {1,2}
    \draw[->] (c6.199) |- (c6\value.west);

    \foreach \value in {1,2}
    \draw[->] (c8.190) |- (c8\value.west);

    \foreach \value in {1,2}
    \draw [->] (c14.south west) +(5pt,0) |- (c11\value.west);

  \end{tikzpicture}
\end{document}

更多箭头

解决方案 2(forest

这是一个使用的解决方案forest

\documentclass[tikz,border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[scaled]{helvet}
\usepackage[ngerman]{babel}
\usepackage{forest}
\standaloneenv{forest}
\usetikzlibrary{shadows}

\forestset{
  my tier/.style={% align all nodes on a given level
    tier/.wrap pgfmath arg={level##1}{level()},
  },
  my shift/.style={
    before computing xy={
      s={s()+10pt},
    },
  },
  paler green offspring/.style={
    tier=this tier,
    for descendants={
      fill=green!30,
      edge path={
        \noexpand\path [draw, ->, \forestoption{edge}] (!to tier=this tier.parent anchor) +(5pt,0) |- (.child anchor)\forestoption{edge label};
      },
    },
  }
}
\begin{document}
  \Large
  \begin{forest}
    for tree={
      draw,
      drop shadow,
      rectangle,
      rounded corners=2pt,
      thin,
      if level=0{
        font=\bfseries\sffamily,
        fill=red!70,
        align=center,
        l sep+=20pt,
      }{
        font=\sffamily,
        if level=1{
          fill=red!50,
          align=center,
          anchor=north,
          child anchor=north,
          parent anchor=south west,
          edge={->},
          my tier,
          text centered,
          text width=40mm,
        }{
          if level=2{
            my tier,
            my shift,
          }{},
          edge path={
            \noexpand\path [draw, ->, \forestoption{edge}] (!to tier=level1.parent anchor) +(5pt,0) |- (.child anchor)\forestoption{edge label};
          },
          parent anchor=south west,
          child anchor=west,
          align=left,
          anchor=north,
          text width=33mm,
          fill=green!50,
        },
      },
    }
    [Fassadenrinne, name=root
      [Höhenverstellung
        [Typ
          [Bedienung
            [Positionierung\\(allgemein)
              [Positionierung\\(entlang\\Rinnen-Langs-\\ächse, paler green offspring
                [Prinzip, my shift
                  [Verstellbarkeit
                  ]
                ]
              ]
            ]
          ]
        ]
      ]
      [Anpassung\\der Rinnen-\\Nennweite
      ]
      [Anpassung\\der Rinnen-\\Baulänge /\\Eckverbindungen
      ]
      [statische Last\\(nach DIN\\EN 1253)
        [Aufweiten des\\Rinnenkörpers
          [Biegebelastung\\der Zarge
          ]
        ]
      ]
      [Axiale Last
        [Querkraft auf\\Höhenverstell-\\ung
          [Anbindung:\\Zarge-Rost
            [Anbindung:\\Zarge-\\Rinnenörper
            ]
          ]
        ]
      ]
      [Stichkanal-\\Anschluss
        [Typ
          [Anbindung
          ]
        ]
      ]
      [Rinnenkörper-\\Verbindung
      ]
      [Stirnwand
        [Höhenverstell-\\ung
          [Anbindung
          ]
        ]
      ]
    ]
  \end{forest}

\end{document}

替代解决方案

相关内容