使用数学方法在森林节点中生成多条线

使用数学方法在森林节点中生成多条线

我正在尝试重现这张精彩的图片 在此处输入图片描述

但很快就出现了错误:

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 polynomy $P_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}

哪里错了? 是否可以像原始树一样进行左右对齐数学运算?

答案1

如果有人对正交多项式感兴趣的话,这里就是结果:)

\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 polynomy $P_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}

得出在此处输入图片描述

答案2

大部分内容与主题无关(作为对 op 答案的补充)...

  • tikzset对于边标签,在环境之外定义节点样式是合理的forest。这样代码会变得稍微短一些
  • 如果代码具有树的形状,则更容易理解和维护

\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 polynomy $P_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}

在此处输入图片描述

相关内容