# Aligned columns in qtree?

I am currently taking a sentential logic class and we've just begun the chapter on truth-trees, so I've been looking into how to generate truth-trees with the qtree package. I think I've been able to get the syntax down for the tree itself, but was wondering if there was a way to put columns with aligned captions for each branch on either side of the tree.

Here's an idea of what I'm trying to accomplish:

Edit 1: The above image isn't actually the tree I created. Mine actually looks more like

Here's my source code, from Lyx.

\documentclass[english]{article}
\usepackage[OT1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{qtree}

\makeatother

\usepackage{babel}
\begin{document}
$\mbox{\Tree[.A\&\ensuremath{\sim}B [.C [.\ensuremath{\sim}A\ensuremath{\vee\sim}C [.A [.\ensuremath{\sim}B [.\ensuremath{\sim}A \ensuremath{\otimes} ] [.\ensuremath{\sim}C \ensuremath{\otimes} ] ] ] ] ] ]}$
\end{document}


Edit 2: I've managed to get a little bit closer to what I want by using three trees in an eqnarray environment. The question I guess I'm asking now is whether or not there's a way to make branches in qtree invisible.

\documentclass[english]{article}
\usepackage[OT1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{qtree}

\makeatother

\usepackage{babel}
\begin{document}

\begin{eqnarray*}
\mbox{\Tree[.1.\\2.\\3.\\4.\\5. [.6. ] ]} &
\mbox{\Tree[.A\&\ensuremath{\sim}B\\C\\\ensuremath{\sim}A\ensuremath{\vee\sim}C\\A\\\ensuremath{\sim}B [.\ensuremath{\sim}A\\\ensuremath{\otimes} ] [.\ensuremath{\sim}C\\\ensuremath{\otimes} ] ]} &
\mbox{\Tree[.SM\\SM\\SM\\1,\&D\\1,\&D [.3,\ensuremath{\vee}D ] ]}
\end{eqnarray*}
\end{document}

-
Can you show how you created your tree? – Alan Munn May 12 '12 at 3:47
If anybody finds this question because they are currently trying to do something like this, please reply to this comment by putting @cfr in the comment to ping me. I have a package for this which automates alignment and numbering, and allows the justifications to be specified more intuitively. It does mean a slight change of syntax as it is a wrapper for forest rather than qtree but it is much, much, much easier than doing it with qtree. – cfr Dec 12 '15 at 0:03

Although I'm not totally happy with this way of doing these trees, you can patch qtree so that the single branch tree produces no line. As long as you don't also need single branches, this will do what you want. I've made some other adjustments to your code: replacing \ensuremath{} with $...$ and just putting the trees into a simple tabular.

\documentclass{article}
\usepackage{etoolbox}
\usepackage{qtree}
\makeatletter
\patchcmd{\qdraw@branches}{(0,1)}{(0,.75)}{}{}
\patchcmd{\qdraw@branches}{\line(0,1){1}}{}{}{}
\makeatother
\begin{document}
\begin{tabular}{ccc}
\Tree[.{1.\\2.\\3.\\4.\\5.} [.6. ] ] &
\Tree[.A\&$\sim$B\\C\\$\sim$A$\vee\sim$C\\A\\$\sim$B {$\sim$A\\$\otimes$} $\sim$C\\$\otimes$  ] &
\Tree[.SM\\SM\\SM\\1,\&D\\1,\&D [.3,$\vee$D ] ]
\end{tabular}
\end{document}


-
Will that still work when you get multiple branchings? I remember having to do a lot of manual intervention when drawing these trees. (I used qtree.) And it wasn't only because I needed incremental overlays - it was partly just the alignments. – cfr Dec 12 '15 at 0:06
@cfr i have no idea. I don't ever have need for this sort of stuff, so I've never actually used this code. – Alan Munn Dec 12 '15 at 13:42

Here's a demonstration using the experimental wrapper prooftrees for forest. It means switching from the qtree syntax, but is much more flexible and does not require manual adjustments to align the line numbers and justifications with the levels of the tree.

This requires version 0.09. Please ask if you would like a copy to play with.

\documentclass[tikz,border=10pt]{standalone}
\usepackage{prooftrees}% version 0.09


By default \sim is defined with the spacing of a relation but it should be an ordinal here, so we define \tnot with the correct spacing.

\newcommand*{\tnot}{\ensuremath{\mathord{\sim}}}


Similarly, \& will not give the correct spacing for a maths relation, so we efine \aand for the & and symbol with the appropriate spacing.

\DeclareMathSymbol{\aand}{\mathbin}{operators}{38}
\begin{document}


prooftrees provides the environment prooftree which takes one mandatory argument. It is OK if the argument is empty, but it must be there. If any special configuration is desired for the tree, it is set up in this first argument. The tree itself goes in the environment proper, of course.

\begin{prooftree}
{


Using a key from forest we apply a couple of customisation options to the whole tree.

    for tree={


First, we set all node content in maths mode by default, using the forest key math content.

      math content,


Second, we want to alter the closure symbol becausre prooftrees uses \otimes rather than \times by default. (If you prefer \otimes, just omit this line.)

      close with={$\times$},
},
}


That's the end of the customisation. Now for the tree itself.

The first node gets contents A \aand \tnot B. It should have a justification SM on the right. To achieve this, we add the key just=SM to the node. This node also needs a check mark, so we add the key checked as well.

  [A \aand \tnot B, just=SM, checked


Continuing with the next line, we add a node with just C as contents and another just=SM.

    [C, just=SM


We continue to add nodes in the same way.

      [\tnot A \lor \tnot C, just=SM, checked
[A, just=1 $\aand$D
[\tnot B, just=1 $\aand$D


The final level of the tree has a branch. This means the square bracket pattern involves closing the first before starting the second. These nodes also need the closure symbol, so we add the key close to each branch.

            [\tnot A, just=3 $\lor$D, close]
[\tnot B, close]


We could have added just=3 $\lor$D to the second branch rather than the first - it makes no difference as prooftrees will put it in the same place either way.

Now we close out the various levels of the tree with matching square brackets.

          ]
]
]
]
]


And we are done.

\end{prooftree}
\end{document}


Complete code:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{prooftrees}% version 0.09
% by default \sim is defined with the spacing of a relation but it should be an ordinal here, so we define \tnot with the correct spacing
\newcommand*{\tnot}{\ensuremath{\mathord{\sim}}}
% define \aand for the & and symbol with the appropriate spacing
\DeclareMathSymbol{\aand}{\mathbin}{operators}{38}
\begin{document}
\begin{prooftree}
{
for tree={
math content,
close with={$\times$},
},
}
[A \aand \tnot B, just=SM, checked
[C, just=SM
[\tnot A \lor \tnot C, just=SM, checked
[A, just=1 $\aand$D
[\tnot B, just=1 $\aand$D
[\tnot A, just=3 $\lor$D, close]
[\tnot B, close]
]
]
]
]
]
\end{prooftree}
\end{document}

-

Here is another way to achieve the same result.

\documentclass[12pt]{article}
\usepackage{tikz} % for trees
\usepackage{tikz-qtree}

\begin{document}

\begin{tikzpicture}[sibling distance=.5cm]
\begin{scope}[xshift=-1.5in] %Column #1 For Numbering
\tikzset{level distance=3.5em}
\tikzset{edge from parent/.style={edge from parent path={(\tikzparentnode\tikzparentanchor) -- (\tikzchildnode\tikzchildanchor)}},every tree node/.style={text width=5em,align=center,anchor=south}}
\Tree [.1\\2\\3\\4\\5 [.6 ] ]
\end{scope}

\begin{scope} %Column #2 For Tree
\tikzset{level distance=5em}
\tikzset{every tree node/.style={align=center,anchor=south}}
\Tree
[.A\&$\sim$B\\C\\$\sim$A$\vee\sim$C\\A\\$\sim$B $\sim$A\\$\otimes$ $\sim$C\\$\otimes$  ]
\end{scope}

\begin{scope}[xshift=1.5in] %Column #3 For Justification
\tikzset{level distance=3.5em}
\tikzset{edge from parent/.style={edge from parent path={(\tikzparentnode\tikzparentanchor) -- (\tikzchildnode\tikzchildanchor)}},every tree node/.style={text width=5em,align=center,anchor=south}}
\Tree [.SM\\SM\\SM\\1,\&D\\1,\&D
[.3,$\vee$D
] ]
\end{scope}

\end{tikzpicture}
\end{document}


The problem I have with this is that it doesn't generalize since the level distances need to be specified and coordinated.

-
(Very belated) welcome! On the off chance that you still need this, let me know. I used qtree for this for a semester and it is a pain, but I would now do it with a wrapper I wrote for forest which makes it much, much easier and, also, works better with Beamer's overlays if you need incremental uncovering for teaching purposes. – cfr Dec 12 '15 at 0:08