![Создать множественный стиль пути от родителя к потомкам в TikZtree](https://rvso.com/image/391723/%D0%A1%D0%BE%D0%B7%D0%B4%D0%B0%D1%82%D1%8C%20%D0%BC%D0%BD%D0%BE%D0%B6%D0%B5%D1%81%D1%82%D0%B2%D0%B5%D0%BD%D0%BD%D1%8B%D0%B9%20%D1%81%D1%82%D0%B8%D0%BB%D1%8C%20%D0%BF%D1%83%D1%82%D0%B8%20%D0%BE%D1%82%20%D1%80%D0%BE%D0%B4%D0%B8%D1%82%D0%B5%D0%BB%D1%8F%20%D0%BA%20%D0%BF%D0%BE%D1%82%D0%BE%D0%BC%D0%BA%D0%B0%D0%BC%20%D0%B2%20TikZtree.png)
Теперь я знаю, как создать такую диаграмму:
После этого мне удалось создать путь от корня к его дочерним элементам, и теперь он выглядит так:
Теперь я пытаюсь сделать так, чтобы это выглядело так:
Я создал этот код:
\documentclass[utf8]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\tikzset{
basic/.style = {draw, text width=15em, drop shadow, rectangle},
root/.style = {basic, rounded corners=2pt, thin, align=center,
fill=green!30},
level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=green!60,
text width=8em},
level 3/.style = {basic, thin, align=left, fill=pink!60, text width=6.5em}
}
\begin{document}
\begin{tikzpicture}[
every node/.style={anchor=center, align=center},
level 1/.style={sibling distance=12em},
edge from parent path={(\tikzparentnode.south) |- (0em,2em) -| (\tikzchildnode.north)},
edge from parent/.style={->,draw},
>=latex]
% root of the the initial tree, level 1
\node[root] {Drawing diagrams}
% The first level, as children of the initial tree
child {node[level 2] (c1) {Defining node and arrow styles}}
child {node[level 2] (c2) {Positioning the nodes}}
child {node[level 2] (c3) {Drawing arrows between nodes}};
% The second level, relatively positioned nodes
\begin{scope}[every node/.style={level 3}]
\node [below of = c1, xshift=15pt] (c11) {Setting shape};
\node [below of = c11] (c12) {Choosing color};
\node [below of = c12] (c13) {Adding shading};
\node [below of = c2, xshift=15pt] (c21) {Using a Matrix};
\node [below of = c21] (c22) {Relatively};
\node [below of = c22] (c23) {Absolutely};
\node [below of = c23] (c24) {Using overlays};
\node [below of = c3, xshift=15pt] (c31) {Default arrows};
\node [below of = c31] (c32) {Arrow library};
\node [below of = c32] (c33) {Resizing tips};
\node [below of = c33] (c34) {Shortening};
\node [below of = c34] (c35) {Bending};
\end{scope}
% lines from each level 1 node to every one of its "children"
\foreach \value in {1,2,3}
\draw[->] (c1.west) -| (-1em,0em) |- (c1\value.west);
\foreach \value in {1,...,4}
\draw[->] (c2.west) -| (-1em,0em) |- (c2\value.west);
\foreach \value in {1,...,5}
\draw[->] (c3.west) -| (-1em,0em) |- (c3\value.west);
\end{tikzpicture}
\end{document}
Но это только создает такой беспорядок:
Где что-то пошло не так?
решение1
Вы почти у цели: просто добавьте 3 раза ++
в последних трех \draw
командах.
\documentclass[utf8]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\tikzset{
basic/.style = {draw, text width=15em, drop shadow, rectangle},
root/.style = {basic, rounded corners=2pt, thin, align=center,
fill=green!30},
level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=green!60,
text width=8em},
level 3/.style = {basic, thin, align=left, fill=pink!60, text width=6.5em}
}
\begin{document}
\begin{tikzpicture}[
every node/.style={anchor=center, align=center},
level 1/.style={sibling distance=12em},
edge from parent path={(\tikzparentnode.south) |- (0em,2em) -| (\tikzchildnode.north)},
edge from parent/.style={->,draw},
>=latex]
% root of the the initial tree, level 1
\node[root] {Drawing diagrams}
% The first level, as children of the initial tree
child {node[level 2] (c1) {Defining node and arrow styles}}
child {node[level 2] (c2) {Positioning the nodes}}
child {node[level 2] (c3) {Drawing arrows between nodes}};
% The second level, relatively positioned nodes
\begin{scope}[every node/.style={level 3}]
\node [below of = c1, xshift=15pt] (c11) {Setting shape};
\node [below of = c11] (c12) {Choosing color};
\node [below of = c12] (c13) {Adding shading};
\node [below of = c2, xshift=15pt] (c21) {Using a Matrix};
\node [below of = c21] (c22) {Relatively};
\node [below of = c22] (c23) {Absolutely};
\node [below of = c23] (c24) {Using overlays};
\node [below of = c3, xshift=15pt] (c31) {Default arrows};
\node [below of = c31] (c32) {Arrow library};
\node [below of = c32] (c33) {Resizing tips};
\node [below of = c33] (c34) {Shortening};
\node [below of = c34] (c35) {Bending};
\end{scope}
% lines from each level 1 node to every one of its "children"
\foreach \value in {1,2,3}
\draw[->] (c1.west) -| ++(-1em,0em) |- (c1\value.west);
\foreach \value in {1,...,4}
\draw[->] (c2.west) -| ++(-1em,0em) |- (c2\value.west);
\foreach \value in {1,...,5}
\draw[->] (c3.west) -| ++(-1em,0em) |- (c3\value.west);
\end{tikzpicture}
\end{document}
решение2
Так?
\documentclass[utf8]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\tikzset{
basic/.style = {draw, text width=15em, drop shadow, rectangle},
root/.style = {basic, rounded corners=2pt, thin, align=center,
fill=green!30},
level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=green!60,
text width=8em},
level 3/.style = {basic, thin, align=left, fill=pink!60, text width=6.5em}
}
\begin{document}
\begin{tikzpicture}[
every node/.style={anchor=center, align=center},
level 1/.style={sibling distance=12em},
edge from parent path={(\tikzparentnode.south) |- (0em,2em) -| (\tikzchildnode.north)},
edge from parent/.style={->,draw},
>=latex]
% root of the the initial tree, level 1
\node[root] {Drawing diagrams}
% The first level, as children of the initial tree
child {node[level 2] (c1) {Defining node and arrow styles}}
child {node[level 2] (c2) {Positioning the nodes}}
child {node[level 2] (c3) {Drawing arrows between nodes}};
% The second level, relatively positioned nodes
\begin{scope}[every node/.style={level 3}]
\node [below of = c1, xshift=15pt] (c11) {Setting shape};
\node [below of = c11] (c12) {Choosing color};
\node [below of = c12] (c13) {Adding shading};
\node [below of = c2, xshift=15pt] (c21) {Using a Matrix};
\node [below of = c21] (c22) {Relatively};
\node [below of = c22] (c23) {Absolutely};
\node [below of = c23] (c24) {Using overlays};
\node [below of = c3, xshift=15pt] (c31) {Default arrows};
\node [below of = c31] (c32) {Arrow library};
\node [below of = c32] (c33) {Resizing tips};
\node [below of = c33] (c34) {Shortening};
\node [below of = c34] (c35) {Bending};
\end{scope}
% lines from each level 1 node to every one of its "children"
\foreach \value in {1,2,3}
\draw[->] (c1.west)--([xshift=-5mm]c1.west) |- (c1\value.west);
\foreach \value in {1,...,4}
\draw[->] (c2.west)--([xshift=-5mm]c2.west) |- (c2\value.west);
\foreach \value in {1,...,5}
\draw[->] (c3.west)--([xshift=-5mm]c3.west) |- (c3\value.west);
\end{tikzpicture}
\end{document}