# Multiple line in forest node using math

I am trying to reproduce this excellent picture

but I ended quite soon with errors:

 C:\Program Files (x86)\MiKTeX 2.9\tex\latex\pgfplots\pgfplots.sty:48: Package pgfkeys Error: I do not know the key '/tikz/$w(x)', to which you passed '(b - x)^{\alpha }(x - a)^{\beta }$', and I am going to ignore it. Perhaps you misspelled it. [\end{forest}] C:\Program Files (x86)\MiKTeX 2.9\tex\latex\pgfplots\pgfplots.sty:48: Missing inserted. [\end{forest}] \documentclass[]{standalone} \usepackage[utf8]{inputenc} \usepackage[czech]{babel} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage{float} \usepackage{forest} \usepackage{tikz} \usepackage{pgfplots} \forestset{qtree/.style={for tree={parent anchor=south, child anchor=north,align=center,inner sep=0pt}}} \begin{document} \begin{forest}baseline, qtree [Obecné Jakobiho polynomyP_n^{(\alpha,\beta)}$\\$X = (b - x)(x - a)$,$w(x) = (b - x)^{\alpha}(x - a)^{\beta}[DP] [V’ [V[sent]] [DP[Mary]] [DP[D[a]][NP[letter]]] ] ] \end{forest} \end{document}  What is wrong? Is it possible to make left and right aligned math as in the original tree? • Everything after the comma following a node label is interpreted as TikZ options passed to forest. Enclose the second line of the math in {} to solve that. That's the source of the error. But it's very unclear to me why you would format the image you show with a tree. I would use a matrix structure instead. – Alan Munn Mar 14 '18 at 15:24 • Ok, it worked. I will put the rest of the code for the future public use :) – Jan Filip Mar 14 '18 at 15:57 • It would be more usual to ask @AlanMunn to post an answer, rather than taking the credit by posting his solution as your own. [But I also agree that a tree structure seems a rather awkward choice in this case.] – cfr Mar 15 '18 at 4:16 • Ok, I am going to delete question – Jan Filip Mar 15 '18 at 7:18 ## 2 Answers mostly off-topic (as supplement to op answer) ... • for edge labels is sensible define node style with use tikzset out of forest environment. with this code will become slightly shorter • code of the tree is easier to understand and maintain if it has the shape of a tree \documentclass[margin=3mm]{standalone} \usepackage[utf8]{inputenc} \usepackage[czech]{babel} \usepackage{forest} \tikzset{EL/.style={%Edge Labels midway, #1,% <--- position: left or right inner xsep=6pt, font=\small, align=center, } } \forestset{qtree/.style={ for tree={align=center, inner sep=0pt, % edge = {draw, semithick, -stealth}, l sep=4em, s sep=3em }} } \begin{document} \begin{forest}qtree [obecné Jakobiho polynomyP_n^{(\alpha,\beta)}$\\ {$X = (b - x)(x - a)$,\qquad$w(x) = (b - x)^{\alpha}(x - a)^{\beta}$} \\ {$\alpha > -1$,$\beta> 1$} [zjednodušené Jakobiho polynomy$P_n^{(\alpha,\beta)}$\\ {$X = 1 - x^2$,$w(x) = (1 - x)^{\alpha}(1 + x)^{\beta}$}, edge label={node[EL=right] {omezení na$-1 \leq x \leq +1$\\$a = -1$,$b = +1$}} [ultrasférické polynomy (Gegenbauerovy)$F_n^{(\lambda)}$\\ {$X = 1 - x^2$,$w(x) = (1 - x^2)$}, edge label={node[EL=right] {omezení na$\alpha = \beta = \lambda$}} [Legendrovy polynomy$L_n(x)$\\ {$X = 1 - x^2$,$w(x) = 1$}, edge label={node[EL=left] {$\lambda = 0$\quad}}] [Čebyševovy polynomy I. druhu$T_n(x)$\\ {$X = 1 - x^2$,$w(x) = (1 - x^2)^{-1/2}$}, edge label={node[EL=right] {$\lambda = -\frac{1}{2}$}} [Čebyševovy polynomy II. druhu$U_n(x)$\\ {$X = 1 - x^2$,$w(x) = (1 - x^2)^{+1/2}$}, edge label={node[EL=right] {$\lambda = +\frac{1}{3}}}] ] ] ] ] \end{forest} \end{document}  • Are you sure that qtree is reserved in TikZ? Can you point to a reference or the code which defines it? At most, I would think this might be defined by tikz-qtree, but even that doesn't define it, as far as I can tell. It is, however, a recipe for confusion if the OP also uses qtree or tikz-qtree, though there is no particular evidence of that. – cfr Mar 15 '18 at 4:14 • @cfr, since i'm not sure i remove my suspicion and change name back to original used. – Zarko Mar 15 '18 at 5:21 Here is the result if someone interested in ortogonal polynomials :) \documentclass[]{standalone} \usepackage[utf8]{inputenc} \usepackage[czech]{babel} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage{float} \usepackage{forest} \forestset{qtree/.style={for tree={parent anchor=south, child anchor=north,align=center,inner sep=0pt,l sep=4em, s sep=8em}}} \begin{document} \begin{forest}baseline, qtree [obecné Jakobiho polynomyP_n^{(\alpha,\beta)}$\\ {$X = (b - x)(x - a)$,\qquad$w(x) = (b - x)^{\alpha}(x - a)^{\beta}$} \\ {$\alpha > -1$,$\beta> 1$} [zjednodušené Jakobiho polynomy$P_n^{(\alpha,\beta)}$\\ {$X = 1 - x^2$,$w(x) = (1 - x)^{\alpha}(1 + x)^{\beta}}, edge label={node[midway,right, align=left]{omezení na-1 \leq x \leq +1$\\$a = -1$,$b = +1$}} [ultrasférické polynomy (Gegenbauerovy)$F_n^{(\lambda)}$\\ {$X = 1 - x^2$,$w(x) = (1 - x^2)}, edge label={node[midway,right, align=left]{omezení na\alpha = \beta = \lambda$}} [Legendrovy polynomy$L_n(x)$\\ {$X = 1 - x^2$,$w(x) = 1},edge label={node[midway,left, align=left]{\lambda = 0$\quad}}] [Čebyševovy polynomy I. druhu$T_n(x)$\\ {$X = 1 - x^2$,$w(x) = (1 - x^2)^{-1/2}},edge label={node[midway,right, align=left]{\quad\lambda = -\frac{1}{2}$}} [Čebyševovy polynomy II. druhu$U_n(x)$\\ {$X = 1 - x^2$,$w(x) = (1 - x^2)^{+1/2}},edge label={node[midway,right, align=left]{\quad\lambda = +\frac{1}{2}\$}}]
]
]
]
]
\end{forest}
\end{document}


which yields

• it will be nice if you in your answer provide complete document with necessary packages loaded in preamble. – Zarko Mar 14 '18 at 16:17
• Ok, done. The last thing remains, I can't manage how to use arrows instead of lines. If anyone can easily do it, please share – Jan Filip Mar 14 '18 at 16:43
• to qtree style add line edge = {draw, semithick, -stealth},. be so kind and format your code, that already in editor we can see tree structure. – Zarko Mar 14 '18 at 16:48