1

I have the following figure as part of a slideshow I'm writing with beamer. If it is relevant, I've used pst-jtree (which is essentially a bunch of macros over pstricks) to produce the tree branches.

enter image description here

The code that produces the right-hand node is:

{multiline Sluicing Elicitation \cr $\underbracket{\textrm{Protocol}}_{typology}$ \endmultiline}

Note how the underbracket typology only goes the width of Protocol, which is visually unpleasant. Ideally, I'd like it to be width of the upper line Sluicing Elicitation. The following figure is what I'm aiming at (I've produced this figure by adding an mbox to either side of textrm{Protocol} in the line above and then manually adjusting the width of both mboxes until it looked good; clearly a very inefficient method).

enter image description here

I've tried to do this with hphantom{}, which should be the horizontal counterpart of vphantom{} ---i.e., it produces a box of zero height and the width of whatever is inside the brackets, and doesn't disturb the actual text. But if I write this

{multiline Sluicing Elicitation \cr $\underbracket{\hphantom{Sluicing Elicitation}\textrm{Protocol}}_{typology}$ \endmultiline}

I get this

enter image description here

which is effectively the equivalent of adding an mbox with the width of Sluicing Elicitation. The question I have is: am I using hphantom{} in the wrong way? And if not (i.e., if it is producing the result it is meant to produce), how can I get the result I want?

Because I've been in SE long enough to know that someone will say this: I guess I can get the result I want by putting the multiline text in a minipage and then underbracketing the minipage itself, or whatever. I'm asking this question despite knowing that this type of solutions exist because I don't just want to get this particular result; I also want to understand why I'm not getting there with hphantom.

  • 2
    With package calc you can do \makebox[\widthof{Ellipsis Consortium}]{Protocol} – egreg Mar 26 '15 at 13:29
  • 1
    \hphantom{#1} does exactly what it should: adds as much horizontal space as is the width of #1. – yo' Mar 26 '15 at 13:42
  • 3
    You are in horizontal mode so the \hphantom and the following text are side by side. You get something similar with \vphantom if you are in vertical mode. – Ulrike Fischer Mar 26 '15 at 13:45
  • what you want to do is overlay "Protocol" centered on the width of the phantom box, not add the two widths. so @egregs suggestion is the best approach. and if you want the two underbrackets at the same depth, you should add a \strut` after "Protocol", since it doesn't have a descender, whereas "Ellipsis" does. – barbara beeton Mar 26 '15 at 16:44
3

Add \usepackage{calc} to your document preamble and use

\makebox[\widthof{Ellipsis Consortium}]{Protocol}

when you want the phantom. This makes a box as wide as “Ellipsis Consortium”, with “Protocol” centered in the available space.

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.