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 am trying to achieve an effect similar to this book in diagramming sentences.

Is there a package for achieving that? I can place all the brackets and subscripts manually, mixing math and text, but that quickly becomes ugly.

I also tried defining a macro:

\global\long\def\constituent#1#2{\left[_{\mbox{#2}}\mbox{\,}\mbox{#1}\right]}

and the something like

$\mbox{It is wrong\ensuremath{\constituent{\mbox{that 
\ensuremath{\constituent{\mbox{Bob insulted the president}}{IP}}}}{CP}}}$

gets rendered as

enter image description here

It's a workable solution, but sometimes I miss an mbox somewhere and get a compile error and it's a bit of a pain.

share|improve this question

1 Answer 1

up vote 12 down vote accepted

Both of the major linguistic example packages provide this functionality, although in different ways. I'm assuming you just want regular labelled bracketing as is normally done in articles in the literature (i.e., the brackets are all of a fixed size.)

gb4e

The gb4e package provides an \lb command for a labelled bracket:

\documentclass{article}
\usepackage{gb4e}
\primebars
\begin{document}
\begin{exe}
\ex{\lb{CP} \lb{DP} who_{i} ] \lb{C} did_{j} ] \lb{TP} \lb{DP} you ] \lb{\ibar{T}} t_{j} \lb{VP} see t_{i} ]]]]}
\end{exe}
\end{document}

output of code

Note that this package also allows _ and ^ to be used outside of mathmode. (This can sometimes cause problems, but is very useful for linguistic work.)

linguex

The linguex package provides a special example environment that automatically subscripts labelled brackets:

\documentclass{article}
\usepackage{linguex}
\begin{document}
\exi. [CP [DP who ] [C$'$ did [TP [DP you ] [T$'$ t [VP see t ]]]]]

\end{document}

output of code

share|improve this answer

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.