Featured Book

LaTeX Beginners Guide

Who is online

In total there are 16 users online :: 1 registered, 0 hidden and 15 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Google [Bot] and 15 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

tikz-qtree | Several Lines per Node Topic is solved

Add tags Information and discussion about graphics, figures & tables in LaTeX documents.

tikz-qtree | Several Lines per Node

Postby 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: 106
Joined: Wed Feb 11th, 2009

Re: tikz-qtree | Several Lines per Node

Postby 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
User avatar
Stefan_K
Site Admin
 
Posts: 6320
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: tikz-qtree | Several Lines per Node

Postby Laurentius on Wed Apr 18th, 2012

It seems impossible to change the level distance for individual nodes inside the tree.
Laurentius
 
Posts: 106
Joined: Wed Feb 11th, 2009

Re: tikz-qtree | Several Lines per Node

Postby 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: 106
Joined: Wed Feb 11th, 2009

Re: tikz-qtree | Several Lines per Node

Postby 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: 106
Joined: Wed Feb 11th, 2009

Re: tikz-qtree | Several Lines per Node  Topic is solved

Postby 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:

tree.png
TikZ qtree
tree.png (13.75 KiB) Viewed 2209 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
User avatar
Stefan_K
Site Admin
 
Posts: 6320
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: tikz-qtree | Several Lines per Node

Postby Laurentius on Sat Apr 28th, 2012

Wunderbar! Besten Dank!

L.
Laurentius
 
Posts: 106
Joined: Wed Feb 11th, 2009


Return to Graphics, Figures & Tables

Who is online

Users browsing this forum: Google [Bot] and 15 guests