Text Formattingtikz-qtree | Label midway between Nodes

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

tikz-qtree | Label midway between Nodes

Post by Laurentius »

Is it possible to label an arrow from one node to another, so that text appears midway?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

tikz-qtree | Label midway between Nodes

Post by Stefan Kottwitz »

Generally, I would use an edge with a node which contains the text. How it could be made, depends on your code. Perhaps post a Infominimal working example.

Stefan
LaTeX.org admin
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

tikz-qtree | Label midway between Nodes

Post by Laurentius »

Isn't it difficult to get o n e curved line with your solution?

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\begin{document}

\noindent\makebox[\textwidth]{
\begin{tikzpicture}
%\tikzset{every tree node/.style={align=center,anchor=north}}
\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}}}
\tikzset{every tree node/.style={font=\greekfont,align=center,anchor=north}}
\tikzset{level distance=45pt}%,sibling distance=0pt}
\XeTeXinterchartokenstate=0
\baselineskip=0pt
\Tree [ .{ψυχή} [ .{ἄλογον} {θρεπτικόν,\\φυτικόν} [ .{(ἔχον (2))\\ὀρεκτικόν} [ .{παρά} {ἐπιθυμητικόν} {θυμητικόν} ] [ .{ἔχον (2)\\\scil ἀκουστικόν} {βουλητικόν} \node(pr){προαιρεκτικόν}; ] ] ] [ .{ἔχον} \node(lgst){λογιστικόν,\\βουλευτικόν}; {ἐπιστημονικόν} ] ]
\draw[<-] (pr)..controls +(south east:3) and +(south:1) .. (lgst);
\end{tikzpicture}}
\end{document}
Attachments
example.jpg
example.jpg (22.46 KiB) Viewed 7236 times
Last edited by Stefan Kottwitz on Mon Apr 16, 2012 8:27 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

tikz-qtree | Label midway between Nodes

Post by Stefan Kottwitz »

Laurentius wrote:Isn't it difficult to get o n e curved line with your solution?
What do you mean? I don't understand.

Regarding labels, you could explicitly place an edge command in your tree, such as

Code: Select all

\edge node[auto=right]{1}; text
I would have shown it with your example, but the code is not compilable for me. It uses a greek font which is not commonly available, at least it's used without a specified font encoding. Perhaps you use XeLaTeX, which does UTF-8 by default, but I don't see any greek font settings here. So it brings errors in any way and doesn't compile.

Stefan
LaTeX.org admin
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

tikz-qtree | Label midway between Nodes

Post by Laurentius »

Sorry! here is a more minimal example:

Code: Select all

\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} [ .{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}
Last edited by Stefan Kottwitz on Tue Apr 17, 2012 12:04 am, edited 1 time in total.
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

Re: tikz-qtree | Label midway between Nodes

Post by Laurentius »

What I mean is that I want text by the edge of the drawn, curved line from node to node.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

tikz-qtree | Label midway between Nodes

Post by Stefan Kottwitz »

Just insert a node in the path:

Code: Select all

\draw[<-] (pr)..controls +(east:1) and +(south:1) .. (lgst)
   node[midway,right] {\scriptsize here};
path.png
path.png (4 KiB) Viewed 7214 times
Stefan
LaTeX.org admin
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

Re: tikz-qtree | Label midway between Nodes

Post by Laurentius »

Danke, Stefan!
Post Reply