森林中的旋转盒子

森林中的旋转盒子

我正在用森林制作二叉树。我是 Latex 中绘图方面的新手。

这是我的代码:

\tikzset{
    block/.style={draw, fill=white!20, text width=1.6cm, text centered, rounded corners, minimum height=1cm},
      line/.style={draw, very thick, color=black!80, -Stealth},
    }

\begin{forest}
  arrow to/.style n args=2{%
    delay={%
      tikz+={%
        \draw [every edge, line] () -- (!#1) node [above, midway] {#2};
      },
    },
    !u.s sep+=30pt,
  },
  before typesetting nodes={%
    where n=1{%
      edge label/.wrap value={%
        node [left,pos=.75, anchor=mid east] {#1}
      },
    }{%
      edge label/.wrap value={%
        node [right,pos=.75, anchor=mid west] {#1}
      },
    },
  },
  for tree={%
    parent anchor=children,
    child anchor=parent,
    anchor=south,
    block,
    edge={line},
    l sep+=10pt,
    tier/.wrap pgfmath arg={tier #1}{level()},
    font=\footnotesize
  },
  forked edges,
    [Fehler Injektion
      [Hardware
        [Kontaktlose Injektion
          [Laser
          ]
          [Strahlungs basiert
            [Heavy-Ion
            ]
            [Neutron
            ]
            [EMI
            ]
          ]
        ]
        [Kontakt Injektion
          [Active Probing
          ]
          [Pin Level
          ]
          [TAP
          ]
        ]
      ]
      [Software
        [Kompilier zeit
        ]
        [Laufzeit
        ]
      ]
      [Emulation
        [FPGA 
        ]
        [LLVM
        ]
      ]
      [Simulation
        [VHDL
        ]
      ]
   ]
\end{forest}

我的问题是:我可以旋转单个盒子吗?它如何工作?

我希望它看起来像这样:

在此处输入图片描述

提前致谢。

答案1

像这样?

在此处输入图片描述

  • 请始终提供以 开头\documentclass{...}和结尾的完整但较小的文档\end{document}。猜测您使用什么文档类、您的页面布局是什么样的以及编译代码片段需要哪些包和库并不好玩……
  • 对于旋转节点,只需rotate=90在需要的节点中使用
  • 您的树的代码可以更简洁,节点的位置也可以更好,但暂时我没有时间这样做(这也不是一个问题)

\documentclass[margin=3mm]{standalone}
\usepackage{forest}
\useforestlibrary{edges}
\usetikzlibrary{arrows.meta}

\begin{document}
\tikzset{
    block/.style={draw, fill=white!20, text width=1.6cm, text centered, rounded corners, minimum height=1cm},
      line/.style={draw, very thick, color=black!80, -Stealth},
    }

\begin{forest}
  arrow to/.style n args=2{%
    delay={%
      tikz+={%
        \draw [every edge, line] () -- (!#1) node [above, midway] {#2};
      },
    },
    !u.s sep+=30pt,
  },
  before typesetting nodes={%
    where n=1{%
      edge label/.wrap value={%
        node [left,pos=.75, anchor=mid east] {#1}
      },
    }{%
      edge label/.wrap value={%
        node [right,pos=.75, anchor=mid west] {#1}
      },
    },
  },
  for tree={%
    parent anchor=children,
    child anchor=parent,
    anchor=south,
    block,
    edge={line},
    l sep+=10pt,
    tier/.wrap pgfmath arg={tier #1}{level()},
    font=\footnotesize
  },
  forked edges,
    [Fehler Injektion
      [Hardware
        [Kontaktlose Injektion
          [Laser
          ]
          [Strahlungs basiert
            [Heavy-Ion,rotate=90
            ]
            [Neutron,rotate=90
            ]
            [EMI,rotate=90
            ]
          ]
        ]
        [Kontakt Injektion
          [Active Probing,rotate=90
          ]
          [Pin Level,rotate=90
          ]
          [TAP,rotate=90
          ]
        ]
      ]
      [Software
        [Kompilier zeit,rotate=90
        ]
        [Laufzeit,rotate=90
        ]
      ]
      [Emulation
        [FPGA,rotate=90
        ]
        [LLVM,rotate=90
        ]
      ]
      [Simulation
        [VHDL
        ]
      ]
   ]
\end{forest}
\end{document}

相关内容