4

I'm trying to build a syntax tree in qtree, which has AVMs with their category above as nodes. The way I tried to do this is by using a multiline node label, with the category on the first line and the AVM on the second. The output, however, has more spacing than I'd like between the first and second lines, seen here:

enter image description here

The issue is the amount of space between S and the AVM below, NP and the AVM below, and the N and the AVM below. How can I reduce the space between these elements?

Following is the code I used to achieve the tree pictured above. I tried reducing the spacing of the AVM but it didn't resolve the issue.

\documentclass[a4paper, 11pt]{article}
\usepackage{qtree}
\usepackage{avm}
  \avmvskip{.1ex}\avmhskip{.5em} % reduce spacing in avms

\begin{document}

\Tree[.S\\\begin{avm}\[HEAD&\[AGR&\[PER&3rd\\NUM&sg\]\]\]\end{avm}
        [.NP\\\begin{avm}\[HEAD&\[AGR\]\]\end{avm}
            [.N\\\begin{avm}\[HEAD\]\end{avm} Alex ] ] ]

\end{document}
  • 1
    Welcome to TeX.SX! You can add some negative space, like that: [.S\\[-2ex]\begin{avm}... [.NP\\[-2ex]... [.N\\[-2ex]\begin{avm}....] ] ] – gernot Oct 6 '16 at 22:27
3

While you could add negative space manually, that might get rather tedious. Moreover, it will make it difficult to ensure consistency.

You can, however, do a little hacking to come up with a solution which allows you to leverage qtree's \qleafhook and \qlabelhook. The reason you need to also hack \qshow@text is because there is otherwise too little vertical space before the first line of the node and qtree doesn't seem to offer any straightforward way of adjusting this.

Do note, however, that qtree is now rather old and is much less flexible than current alternatives. It would be worth your while to switch to forest or tikz-qtree if you draw many trees. (And maybe even if you draw relatively few of them.)

\documentclass[a4paper, 11pt]{article}
\usepackage{qtree,avm,array}
\avmvskip{.1ex}\avmhskip{.5em}
\makeatletter
\renewcommand{\qshow@text}[3][c]{% from qtree.sty
  {%
    #2{%
      \begin{tabular}[t]
        {@{\hskip\qtreepadding}#1@{\hskip\qtreepadding}}%
        \\
        #3%
      \end{tabular}%
    }%
  }%
}
\newcommand\qlabelhook{\setlength\partopsep{10cm}\setlength\extrarowheight{-10pt}}
\newcommand\qleafhook{\setlength\extrarowheight{-10pt}}
\makeatother
\begin{document}
\Tree[.S\\\begin{avm}\[HEAD&\[AGR&\[PER&3rd\\NUM&sg\]\]\]\end{avm}
  [.NP\\\begin{avm}\[HEAD&\[AGR\]\]\end{avm}
    [.N\\\begin{avm}\[HEAD\]\end{avm} Alex
    ]
  ]
]
\end{document}

adjusted vertical spacing

EDIT

For example, here are three Forest versions. The first uses the default spacing. The second and third use a custom style, avm in different ways.

While the second just modifies the spacing, the third does away with the need to use the avm environment in every node by treating any content following a colon as material to wrap in that environment.

I'm not familiar with avm and don't have time to look into the details right now so the spacing is not quite right in terms of the sizes of the square brackets. If anybody knows how to correct this, please let me know! (Or post an answer, of course.)

\documentclass[border=10pt]{standalone}
\usepackage[linguistics]{forest}
\usepackage{avm,array}
\avmvskip{.1ex}\avmhskip{.5em}
\forestset{%
  avm/.style={%
    TeX={\setlength\extrarowheight{-10pt}},
    before typesetting nodes={%
      for tree={%
        split option={content}{:}{content,make avm},
      },
    },
  },
  make avm/.style={%
    content+={%
      \\\begin{avm}#1\end{avm}
    },
  },
}
\begin{document}
\begin{forest}
  [S\\\begin{avm}\[HEAD&\[AGR&\[PER&3rd\\NUM&sg\]\]\]\end{avm}
    [NP\\\begin{avm}\[HEAD&\[AGR\]\]\end{avm}
      [N\\\begin{avm}\[HEAD\]\end{avm}
        [Alex
        ]
      ]
    ]
  ]
\end{forest}
\begin{forest}
  avm
  [S\\\begin{avm}\[HEAD&\[AGR&\[PER&3rd\\NUM&sg\]\]\]\end{avm}
    [NP\\\begin{avm}\[HEAD&\[AGR\]\]\end{avm}
      [N\\\begin{avm}\[HEAD\]\end{avm}
        [Alex
        ]
      ]
    ]
  ]
\end{forest}
\begin{forest}
  avm
  [S:\[HEAD&\[AGR&\[PER&3rd\\NUM&sg\]\]\]
    [NP:\[HEAD&\[AGR\]\]
      [N:\[HEAD\]
        [Alex
        ]
      ]
    ]
  ]
\end{forest}
\end{document}

Here's a comparison of the output:

comparison of output

| improve this answer | |
  • This is fantastic, thank you so much! I think I will make the switch over to forest after seeing how simple it is. Also I'm not sure what you mean about the spacing with the square brackets in the AVMs--it looks good to me! – epsilon Oct 8 '16 at 2:31

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.