4

How can I put example tree (a) and example tree (b) next to each other on the page? At the moment, tree (b) appears below tree (a):

\documentclass[12pt,a4paper]{article}   
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\usepackage{ulem}

\begin{document}
\ex. \a. \begin{tikzpicture} \Tree [.DP [.N Pat ] ] \end{tikzpicture} 
\b.  \label{VP} \begin{tikzpicture}
\Tree [.VP  [.V saw ] [.DP [.N Kim ] ]]
\end{tikzpicture}

\end{document}
percusse
  • 157,807
user65526
  • 845
  • Your code contains a few errors (\ex, \a and \b should not have backslashes). After correcting this, the code compiles fine and the trees are put one next to the other. – Philipp Imhof Aug 05 '15 at 14:30
  • @PhilippImhof, those commands are from the linguex package, which should be loaded in the preamble. Then it compiles as the @user65526 describes. – Jason Zentz Aug 05 '15 at 14:42
  • @Jason: Oh, I see, thanks. And now I can see the problem. I would suggest to use multicols just like exposed in Gonzalo's answer. – Philipp Imhof Aug 05 '15 at 14:44

1 Answers1

4

You can use a multicols environment from multicol package.

The example below shows your original tikz-qtree code and a version using the powerful forest package; in both cases, alignment was improved using the baseline option:

enter image description here

The code:

\documentclass[12pt,a4paper]{article}   
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\usepackage{ulem}
\usepackage{linguex}
\usepackage{multicol}
\usepackage{forest}

\begin{document}
\begin{multicols}{2}

\ex. 
\a. \begin{tikzpicture}[baseline] \Tree [.DP [.N Pat ] ] \end{tikzpicture}
\b.  \label{VP} \begin{tikzpicture}[baseline]
\Tree [.VP  [.V saw ] [.DP [.N Kim ] ]]
\end{tikzpicture}

\end{multicols}

\begin{multicols}{2}

\ex. 
\a. 
\begin{forest}
baseline 
[DP 
  [N 
    [Pat]
  ]   
] 
\end{forest}
\b.  \label{VP} 
\begin{forest}
baseline
[VP  
  [V
    [saw] 
  ]
  [DP
    [N
      [Kim] 
    ]
  ]
]
\end{forest}

\end{multicols}

\end{document}
Gonzalo Medina
  • 505,128
  • 2
    Although everyone here is a big fan of forest (and I agree it's a great package) for most linguistic trees tikz-qtree does a fine job, and in fact produces nicer looking trees depending on the particular tree being drawn. For example in this question, Extending a tree the packing algorithm of forest produces a very hard to read and odd looking tree from a linguistics point of view. (Also the default edge path in forest is quite ugly and not used generally in linguistics.) – Alan Munn Aug 05 '15 at 14:43
  • @AlanMunn I changed the wording of my answer. Now I just present forest as another possibility without suggesting to switch to it. – Gonzalo Medina Aug 05 '15 at 14:49
  • 1
    You beat me to it, @AlanMunn. I actually did switch from tikz-qtree to forest (mostly because of this error and the occasional need for more compact trees), but I have to use several styles to get the forest trees to look appropriate for linguistics. And many times I find myself overriding the alignment issues you pointed out in Extending a tree using fit=band. I usually recommend tikz-qtree to students because it works out of the box, unlike forest. – Jason Zentz Aug 05 '15 at 14:50
  • 2
    @JasonZentz Thanks Jason. I've added a meta question to make the point more generally. Not seeing the forest for the trees – Alan Munn Aug 05 '15 at 14:58