如何改善樹上樹枝的間距?

如何改善樹上樹枝的間距?

我正在嘗試建造一棵樹,但樹枝的長度大小不均勻。此外,我可能需要將標籤更改為更短/更大長度的字串。您對改進這棵樹有什麼建議嗎?

\documentclass[tikz]{standalone}
\usepackage{tikz-qtree}
\begin{document}
\begin{tikzpicture}[level distance=50pt]
\Tree [ \edge node[auto=right]{abcdef}; 
[.$C$ ] \edge node[auto=left]{$\neg$abcdef}; 
[ \edge node[auto=right]{abcdef}; 
[.$C$ ] \edge node[auto=left]{$\neg$abcdef}; 
[\edge node[auto=right]{abcde}; 
[\edge node[auto=right]{abcdef}; 
[\edge node[auto=right]{abcdef}; 
[\edge node[auto=right]{abcdef};
[.$C$ ]\edge node[auto=left]{$\neg$abcdef}; 
[.$C$ ] ]\edge node[auto=left]{$\neg$abcdef}; 
[.$C$ ] ]\edge node[auto=left]{$\neg$abcdef}; 
[.$C$ ] ]\edge node[auto=left]{$\neg $abcde}; 
[.$C$ ] ] ] ]
\end{tikzpicture}
\end{document}

答案1

這是使用 qtree 套件的範例。僅主樹就不需要在序言中進行所有的修改。這只是為了獲得行的編號和在右側輸入的理由。解決方案遠非完美,但如果您只需要樹本身,則根本不需要這些技巧。這是一個練習中的例子,需要使用樹證明論證的有效性。

\documentclass{article}
\usepackage{qtree}
\usepackage{amssymb}
\newcommand*{\tnot}{\ensuremath{\mathord{\sim}}}
\makeatletter
  \newcommand{\nounibranches}[1]{% One-branching only
      \begin{picture}(0,1)
        \put(0,0){\line(0,1){0}}
      \end{picture}}%
  \newcommand{\nobibranches}[1]{% Two-branching only
      \begin{picture}(2,0.5)
        \put(0,0){\line(2,1){0}}
        \put(2,0){\line(-2,1){0}}
      \end{picture}}%
  \let\qdrawReal=\qdraw@branches
  \def\dimbr#1{\ifcase#1\relax % zero case is unused
    \or  % One-branching
      \let\qdraw@branches=\nounibranches
    \or % Two-branching
      \let\qdraw@branches=\nobibranches
    \else \typeout{error --- Can't handle #1-way branching}
    \fi}
  \newcommand\breto{\let\qdraw@branches=\qdrawReal}
\makeatother

\begin{document}
\hspace*{-\parindent}
{$(\exists x)(\forall y)(Py \equiv x = y) \vdash (\exists x)((\forall y)(Py \supset x = y) \,\&\, Px)$}\bigskip\\
\Tree
  [.{1\\2}
    [.3
      [.4
        [.{5\\[-.5em]\mbox{ }}
          [.{6\\7\\[-.25em]\mbox{ }}
            [.8
              [.9
                [.{10\\11}
                  [.12
                    [.{13\\14}
                      [.15
                        !{\dimbr1}
                      ]
                    ]
                  ]
                ]
              ]
            ]
          ]
        ]
      ]
    ]
  ] {\breto}
\Tree
  [.{$(\exists x)(\forall y)(Py \equiv x = y)\ \checkmark a$\\$\tnot (\exists x)((\forall y)(Py \supset x = y) \,\&\, Px)\ \backslash a$}
    [.{$(\forall y)(Py \equiv a = y)\ \backslash a,b$}
      [.{$\tnot ((\forall y)(Py \supset a = y) \,\&\, Pa)\ \checkmark$}
        [.{$Pa \equiv a = a\ \checkmark$}
          [.{$Pa$\\$a = a$}
            [.{$\tnot (\forall y)(Py \supset a = y)\ \checkmark b$}
              [.{$\tnot (Pb \supset a = b)\ \checkmark$}
                [.{$Pb$\\$a \neq b$}
                  [.{$Pb \equiv a = b\ \checkmark$}
                    [.{$Pb$\\$a = b$}
                      [.{$a \neq a$\\$\otimes$\\15}
                      ]
                    ]
                    [.{$\tnot Pb$\\$a \neq b$\\$\otimes$\\10,13}
                    ]
                  ]
                ]
              ]
            ]
            [.{$\tnot Pa$\\$\otimes$\\6,8}
            ]
            ]
          [.{$\tnot Pa$\\$a \neq a$\\$\otimes$\\7}
          ]
        ]
      ]
    ]
  ]
\Tree
  [.{Premise\\Conclusion negated}
    [.{From 1}
      [.{From 2}
        [.{From 3\\[-.5em]\mbox{ }}
          [.{From 5\\From 5\\[-.25em]\mbox{ }}
            [.{From 4}
              [.{From 8}
                [.{From 9\\From 9}
                  [.{From 3}
                    [.{From 12\\From 12}
                      [.{From 11,14}
                        !{\dimbr1}
                      ]
                    ]
                  ]
                ]
              ]
            ]
          ]
        ]
      ]
    ]
  ] {\breto}
\end{document}

生產:

在此輸入影像描述

相關內容