如何改善树枝的间距?

如何改善树枝的间距?

我正在尝试构建一棵树,但树枝的长度不均匀。此外,我可能需要将标签更改为更短/更长的字符串。您有什么建议可以改进这棵树吗?

\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}

生成:

在此处输入图片描述

相关内容