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

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.

