如何将用 TikZ 制作的树的完整树枝移动到树干的另一侧?

如何将用 TikZ 制作的树的完整树枝移动到树干的另一侧?

我是 LaTeX 的初学者,正在尝试使用 TikZ 制作我的第一个树形图。我借用了一个代码示例并对其进行了改编。但是我想将“自动格式化”分支移到主干的左侧,以降低图表的高度,但无法弄清楚如何调整参数。有人可以提出解决方案,以及可能改善图表外观(或清晰度和影响力......?)的任何其他更改吗?

\documentclass[11pt ]{article}
\usepackage{tikz}
\usetikzlibrary{trees}

\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west, fill=red!20, text width=14em, text centered,  minimum height=1.5em, inner sep=0pt, auto, rounded corners= .1 ex]
\centering
\begin{tikzpicture}[
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {Productivity}
child { node [fill=blue!20] {Full structuration}}
child { node  [fill=orange!20]{Automatic formatting}
child { node  [fill=orange!20]{Creation of tables and plots}}
child { node  [fill=orange!20]{Easy integration of pictures}}
child { node  [fill=orange!20]{Auto/easy native graphics}}
child { node [fill=orange!20]{Auto/easy changes}}
child { node  [fill=orange!20]{Sharing of libraries}}
child { node  [fill=orange!20]{Easy splitting of draft file}}
} %
child [missing] {}
child [missing] {}
child [missing] {}
child [missing] {}
child [missing] {}
child [missing] {}
child { node  [fill=green!20]{Simultaneous editing}}
child { node  [fill=green!20]{Short learning curve}}
child { node  [fill=green!20]{Training material}}
child { node  [fill=gray!20]{Stability of software}};
\end{tikzpicture}

\end{document}

答案1

有多种方法可以将节点及其子节点移到左侧。一种可能性是调整节点属性,例如:

\documentclass[11pt ]{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\usetikzlibrary{positioning}

\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west, fill=red!20, text width=14em, text centered,  minimum height=1.5em, inner sep=0pt, auto, rounded corners= .1 ex]
\centering
\begin{tikzpicture}[
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {Productivity}
child { node (A) [fill=blue!20] {Full structuration}}
child { node  [fill=green!20]{Simultaneous editing}}
child { node  [fill=green!20]{Short learning curve}}
child { node  [fill=green!20]{Training material}}
child { node  [fill=gray!20]{Stability of software}}
child[
   grow via three points={one child at (-0.5,-0.7) and
   two children at (-1.6,-0.7) and (-1.6,-1.4)},
   edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.east)}]
{ node  [left=of A,fill=orange!20]{Automatic formatting}
   child { node  [fill=orange!20,anchor=west]{Creation of tables and plots}}
   child { node  [fill=orange!20]{Easy integration of pictures}}
   child { node  [fill=orange!20]{Auto/easy native graphics}}
   child { node [fill=orange!20]{Auto/easy changes}}
   child { node  [fill=orange!20]{Sharing of libraries}}
   child { node  [fill=orange!20]{Easy splitting of draft file}}
};
\end{tikzpicture}

\end{document}

生成的树如下所示:

在此处输入图片描述

相关内容