[texhax] Centering within an arbitrary vbox

Peter Seibel peter at gigamonkeys.com
Mon May 25 01:36:34 CEST 2009


I have this bit of TeX code:

   \line{\hfill\vbox{\hbox{Chapter}\hbox{8}}}

Which renders something like this (pardon my ASCII art):


|                                     Chapter|
|                                     8           |

What I want is for the "8" to be centered under the "Chapter" but with
the combined vbox flush right.

I've tried putting hfill's in the hbox containing the "8" but that
doesn't seem to do anything. I assume that that's because the width of
the hbox is still just big enough to hold the text--i.e. the hfill
doesn't cause the size of the enclosing box to expand. Is that about
right? And if so, is there an easy way to get the effect I want.
(Basically I want to force the bottom hbox to be the same width as the
top one but I don't want to specify some specific value for the widths
of the two hboxes.

Am I missing something obvious?

-Peter


-- 
Peter Seibel
http://www.codersatwork.com/
http://www.gigamonkeys.com/blog/


More information about the texhax mailing list