Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to create a figure with two small figures; I want it to be a box that is split into two, with a syntax tree located in each side. The MWE below shows what I'm trying and failing with:

\documentclass{article}
\usepackage{tikz-qtree}
\usepackage{ textcomp }
\newcommand\TR[1]{\textlangle#1\textrangle}
\begin{document}
\begin{figure}[ht]
    \fbox{
        \begin{minipage}[b]{0.5\linewidth}
            \centering
            \begin{tikzpicture}
                \tikzset{every tree node/.style={align=center,anchor=north}}
                \Tree [ .NP [ .vP[DE] { } [ .v' v\\dai [ .VP { } [ .V' V\\\TR{dai} yanjing ] ] ] ] NP\\nanhai ]
                \end{tikzpicture}
                \caption{default}
            \label{fig:figure1}
        \end{minipage}
    }
    \hspace{0.5cm}
    \fbox{
        \begin{minipage}[b]{0.5\linewidth}
            \centering
            \begin{tikzpicture}
                \tikzset{every tree node/.style={align=center,anchor=north}}
                \Tree [ .NP [ .vP[DE] { } [ .v' v\\dai [ .VP { } [ .V' V\\\TR{dai} yanjing ] ] ] ] NP\\nanhai ]
            \end{tikzpicture}
            \caption{default}
            \label{fig:figure2}
        \end{minipage}
    }
\end{figure}
\end{document}

This code creates two separate boxes, which is not what I want.

share|improve this question

2 Answers 2

up vote 7 down vote accepted

You could use a tabular environment with lines such a splitted box:

\documentclass{article}
\usepackage{tikz-qtree}
\usepackage{ textcomp}
\usepackage{array}
\newcommand\TR[1]{\textlangle#1\textrangle}
\begin{document}
\begin{figure}[ht]
    \begin{tabular}{|*2{>{\centering\arraybackslash}p{0.5\linewidth}|}}
            \hline
            \begin{tikzpicture}
                \tikzset{every tree node/.style={align=center,anchor=north}}
                \Tree [ .NP [ .vP[DE] { } [ .v' v\\dai [ .VP { } [ .V' V\\\TR{dai} yanjing ] ] ] ] NP\\nanhai ]
            \end{tikzpicture}
            & \begin{tikzpicture}
                \tikzset{every tree node/.style={align=center,anchor=north}}
                \Tree [ .NP [ .vP[DE] { } [ .v' v\\dai [ .VP { } [ .V' V\\\TR{dai} yanjing ] ] ] ] NP\\nanhai ]
            \end{tikzpicture}\\\hline
    \end{tabular}
\end{figure}
\end{document}

trees in a table

If you need a caption for each tree, you could use the subcaption package.

Alternatively, you could use a split rectangular node with TikZ.

share|improve this answer

You could modify the space you are putting between the two boxes so that the borders overlap. By default the width of a rule is .4pt. So you would get:

\documentclass{article}
\usepackage{tikz-qtree}
\usepackage{ textcomp }
\newcommand\TR[1]{\textlangle#1\textrangle}
\begin{document}
\begin{figure}[ht]
    \fbox{
        \begin{minipage}[b]{0.5\linewidth}
            \centering
            \begin{tikzpicture}
                \tikzset{every tree node/.style={align=center,anchor=north}}
                \Tree [ .NP [ .vP[DE] { } [ .v' v\\dai [ .VP { } [ .V' V\\\TR{dai} yanjing ] ] ] ] NP\\nanhai ]
                \end{tikzpicture}
                \caption{default}
            \label{fig:figure1}
        \end{minipage}
    }%
    \hspace{-.4pt}%
    \fbox{
        \begin{minipage}[b]{0.5\linewidth}
            \centering
            \begin{tikzpicture}
                \tikzset{every tree node/.style={align=center,anchor=north}}
                \Tree [ .NP [ .vP[DE] { } [ .v' v\\dai [ .VP { } [ .V' V\\\TR{dai} yanjing ] ] ] ] NP\\nanhai ]
            \end{tikzpicture}
            \caption{default}
            \label{fig:figure2}
        \end{minipage}
    }
\end{figure}
\end{document}

Trees in split box

share|improve this answer
    
I've heard that fighting LaTex with negative space is bad, but I like not having to load a separate package to have captions. –  Nate Glenn Dec 6 '11 at 16:06
    
@NateGlenn: Well, you are already using TikZ, so you could just use that to draw a box like Stefan suggests. Although that is not as straightforward as it seems. Leaving captioning + labelling working will (I believe) require a separate tikz picture overlay. Assuming you still don't want extra packages. –  Roelof Spijker Dec 6 '11 at 16:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.