[texhax] Centering within an arbitrary vbox

Aditya Mahajan adityam at umich.edu
Mon May 25 20:01:57 CEST 2009


On Mon, 25 May 2009, Philip G. Ratcliffe wrote:

>> 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.
>>
>> [snip]
>
> The tabular environment is probably th simplest solution:
>
> \line{\hfill\vbox{%
>  \tabcolsep=0pt % to keep things flush
>  \begin{tabular}{c}
>    Chapter\\8
>  \end{tabular}
> }}

Or, if you are using plain TeX, use \halign

\line{\hfill\vbox
   {\halign{\hfill#\hfill \cr
    Chapter \cr
    8 \cr}}}

Aditya


More information about the texhax mailing list