# How to improve the spacing of branches in a tree?

I am trying to build a tree but the length of branches is of uneven size. Moreover, I might need to change the labels to strings of shorter/larger length. Do you have some suggestions to improve this tree?

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

• What are you trying to represent exactly? The abcde stuff is not labelling the nodes in the way I'm used to seeing trees done so I'm guessing this is a different kind of tree than the ones I've constructed and seen constructed. – cfr Jan 1 '14 at 4:06
• I am trying to build a semantic tableaux (for first-order logic formulas). The labels will represent any function (such as f(x) = a). This is my first attempt at building at tree using this package so my example might not even be a correct way to do it. – drgxfs Jan 1 '14 at 16:56
• Normally I'd put those actually at the nodes with the starting formulae at the root of the tree. I can post an example if you think that might help. I don't have any examples off-hand which include formulae, I don't think, but I've got some for first-order predicate calculus with identity. Let me know and I'll strip out the beamer-specific commands from one. – cfr Jan 1 '14 at 22:36
• Yes, that would be great. Any example is welcome. – drgxfs Jan 2 '14 at 12:49

Here's an example using the qtree package. Just the main tree would not require all the fiddling in the preamble. That was just to get the numbering of lines and the justifications entered on the right. The solution for that is far from perfect but if you just need the tree itself, you won't need those hacks at all. This is an example from an exercise which requires demonstrating the validity of arguments using trees.

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


Produces: