Add tags
Information and discussion about graphics, figures & tables in LaTeX documents.
by Laurentius on Wed Apr 18th, 2012
- Code: Select all • Open in writeLaTeX
\documentclass{article} \usepackage{tikz} \usepackage{tikz-qtree} \begin{document} \noindent\makebox[\textwidth]{ \begin{tikzpicture} \tikzset{edge from parent/.style= {draw, edge from parent path={(\tikzparentnode.south) -- +(0,-8pt) -| (\tikzchildnode)}}} \tikzset{every tree node/.style={align=center,anchor=north}} \tikzset{level distance=40pt}%,sibling distance=0pt} \baselineskip=0pt \Tree [ .{a} [ .{x} {b,\\c} [ .{d\\f\\g\\h} [ .{d} {d} {f} ] [ .{g} {d} \node(pr){gs}; ] ] ] [ .{dsfg} \node(lgst){asdf}; {sdg} ] ] \draw[<-] (pr)..controls +(east:1) and +(south:1) .. (lgst); \end{tikzpicture}} \end{document}
Here, several lines per node is allowed by \tikzset{style={align=center,anchor=north}} but this messes up the tree (the length of the branches). Can this be remedied?
-
Laurentius
-
- Posts: 69
- Joined: Wed Feb 11th, 2009
by Stefan_K on Wed Apr 18th, 2012
You could apply the style locally, where needed. I would define a multi-line style, so it's easier to adjust and better readable in the tree code: - Code: Select all • Open in writeLaTeX
\tikzset{multiline/.style={align=center,anchor=north}}
In the tree, you can write the node with this style, where needed, such as - Code: Select all • Open in writeLaTeX
... [ .\node [multiline] {d\\f\\g\\h}; [ ...
Furthermore, you probably need to adjust the level distance, because multi-line nodes are higher. Stefan
LaTeX Community Administrator
-

Stefan_K
- Site Admin
-
- Posts: 6140
- Joined: Mon Mar 10th, 2008
- Location: Hamburg, Germany
-
by Laurentius on Wed Apr 18th, 2012
It seems impossible to change the level distance for individual nodes inside the tree.
-
Laurentius
-
- Posts: 69
- Joined: Wed Feb 11th, 2009
by Laurentius on Wed Apr 18th, 2012
It seems impossible to change the level distance for individual nodes inside the tree. Here is a better example: - Code: Select all • Open in writeLaTeX
\documentclass{article} \usepackage{tikz} \usepackage{tikz-qtree} \begin{document} \noindent\makebox[\textwidth]{ \begin{tikzpicture} \tikzset{edge from parent/.style= {draw, edge from parent path={(\tikzparentnode.south) -- +(0,-8pt) -| (\tikzchildnode) } } } \tikzset{align=center,level distance=45} \Tree [ .{psyche} [ .{alogon} {threptikon,\\phytikon} [ .{(echon pos)\\orektikon} [ .{para} {epithymetikon} {thymetikon} ] [ .{echon pos,\\akoustikon} {bouleutikon} \node(pr){proairektikon,\\hegemonikon}; ] ] ] [ .{echon} \node(lgst){logistikon,\\bouleutikon}; {epistemonikon} ] ] \draw[<-] (pr)..controls +(south east:3) and +(south:1) .. (lgst) node[midway,right]{bouleuton,\\proaireton\\(pros ta tele)}; \end{tikzpicture}} \end{document}
-
Laurentius
-
- Posts: 69
- Joined: Wed Feb 11th, 2009
by Laurentius on Thu Apr 19th, 2012
Perhaps the problem could be solved if the new lines could be added below the first instead of above it, but I don't know if this is possible -- ?
-
Laurentius
-
- Posts: 69
- Joined: Wed Feb 11th, 2009
by Stefan_K on Wed Apr 25th, 2012
David Chiang and Andrew Stacey have improved the tikz-qtree package. Now it's possible to define level based styles, such as level distance and sibling distance. You can try if you add to your code: - Code: Select all • Open in writeLaTeX
\tikzset{level 1/.style={level distance=30pt}} \tikzset{level 2/.style={level distance=40pt, sibling distance=20pt}} \tikzset{level 3+/.style={level distance=40pt, sibling distance=10pt}}
Here you can see the result with different distances:

- TikZ qtree
- tree.png (13.75 KiB) Viewed 1412 times
You just need to update your package. The new features are documented in the up-to-date tikz-qtree manual, in 3.3 Node placement styles. Stefan
LaTeX Community Administrator
-

Stefan_K
- Site Admin
-
- Posts: 6140
- Joined: Mon Mar 10th, 2008
- Location: Hamburg, Germany
-
by Laurentius on Sat Apr 28th, 2012
Wunderbar! Besten Dank!
L.
-
Laurentius
-
- Posts: 69
- Joined: Wed Feb 11th, 2009
Return to Graphics, Figures & Tables
Users browsing this forum: No registered users and 6 guests
|