1

I have the following qtree

\begin{center}                                      

\Tree[.{\tiny \ttfamily \itseries educated at}{\tiny \ttfamily ( Bush, University of Texas at Austin)}  [. [. \textit{\tiny 193938.xml} ]
    [. \textit{\tiny sentence 2} ]]
    [. [. [. [. \textit{\tiny Q Value} \textit{\tiny University of Texas at Austin} ]
    [. [.\textit{\tiny Q Value} ]\textit{\tiny Bush} ] ] ][. [. [. [. \textit{\tiny P26} \textit{\tiny educated at} ]]]]]]

\end{center}  

The alignment is really messing up my paper.

Right now it looks like this:

enter image description here

as you can see, it just sort of trails off into the margin there.

How can I fix that?

I guess it could be easily done if I could just move the center branch furthur up so that the one on the right didn't jut out as far.

This is the complete project

UPDATE

\begin{forest}
[{\tiny \ttfamily \itseries educated at}{\tiny \ttfamily ( Bush, University of Texas at Austin)}, qtree edges,s sep=1cm [[\ts{.}] [[[$\epsilon$]]

[$\epsilon$]]][[$\epsilon$]]] \end{forest}

:/ How to use forest?

I hope it can look like this:

enter image description here

  • 1
    By the way, don't just provide a code snippet, but a MWE, possibly complete with text (even Lipsum would be fine) so we can test it without having to write the whole code from scratch. – Alenanno Apr 29 '15 at 12:48
  • sort of, but it's a document with two collumns of text, like this one, so i was hoping to fit it into a single collum, d'you know I mean? – smatthewenglish Apr 29 '15 at 13:13
  • 1
    The code you provided in the comments doesn't have a two-column layout. That's why I asked for a MWE in your question: I'm spending more time figuring out your code than the problem. :) – Alenanno Apr 29 '15 at 13:15
2

Use the forest package. It's much better than qtree. And it's meant to deal precisely with proper alignment.

  • I'm not very familiar with latex. please forgive me but is it possible that you might show me how it could be adapted to the tree I created with qtree? – smatthewenglish Apr 29 '15 at 12:48
  • It is possible but give it a go first for your education. Run texdoc forest and take a quick look at page 5. Example number 3 is quite similar to yours. – n.r. Apr 29 '15 at 13:06
  • i tried to give it a shot, but it's kind of confusing. i put my failed attempt up there in the OP under update as well as a drawing of what I'm trying to get at. – smatthewenglish Apr 29 '15 at 13:12
2

Here's a forest solution to get you started.

If you run into a divide by 0 error, you will need to tweak the value of outer ysep in the definition of the nice trees style; this is a workaround from the comments on this question about a bug that causes this error.

\documentclass{article}

\usepackage{forest}
\forestset{
    nice trees/.style={
    for tree={
      parent anchor=south,
      child anchor=north,
      align=center,
      base=top,
      inner sep=1pt,
      l-=4ex,
      before typesetting nodes={
          if content={}{
            for parent={
              for children={anchor=north},
              calign=fixed edge angles,
              calign angle=60,              
            },
            inner sep=0pt,
            outer ysep=-0.49pt,
            calign=fixed edge angles,
            calign angle=60,       
          }{},
      },
    },
  },
}

\begin{document}

\begin{forest}
nice trees
[\textsc{Data Representation}\\{\textit{educated at}(Bush, UT Austin)}
    [
        [filename]      
        [sentence \# ]
    ]
    [
        [
            [
                [$Q$ value]
                [English]
            ]
            [
                [$Q$ value]
                [English]
            ]
        ]
        [
            [$P$ value]
            [English]
        ]
    ]
]  
\end{forest}

\end{document}

enter image description here

If the tree still doesn't fit horizontally after implementing forest, here are some questions/answers that give several ideas of ways to make it fit: Margins and positioning with tikz-dependency, How to format a language tree?, Reducing forest tree width without squashing.

I don't know if you actually want "Data Representation" as part of the top node of the tree, but at least it shows you how you can use \\ to split nodes into multiple lines (this is allowed because of align=center in the nice trees style).

  • ah! amazing! I made the text to \tiny and theres a small bit of protrusion into the margin, but, i'll check out those resources and try to get it all lined up. – smatthewenglish Apr 29 '15 at 13:47
  • @S.Matthew_English, the first things you should try would be to split long nodes onto multiple lines and to scale the whole tree down using \scalebox. See the links I provided at the end of the answer for further explanation. You might want to reduce the font size to \footnotesize, but there's rarely need to take it all the way down to \tiny. – Jason Zentz Apr 29 '15 at 13:57
  • I just \begin{center}ed it and that did the trick :) – smatthewenglish Apr 29 '15 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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