[OS X TeX] vertical positioning within a cell of a table

Ross Moore ross at ics.mq.edu.au
Wed Jun 14 06:10:47 CEST 2006

On 14/06/2006, at 12:45 AM, Alain Schremmer wrote:

> Here is a simple case
> Say I have a table with 1 row and 2 columns.
> In the first column I have a tall graphics and in the second column  
> I have text.
> The graphic and the text come out bottom-aligned.
> How do I get, say, at least a top-alignment or a center alignment?

For top-alignment, try the following:

Here's some text about the image at right:
}% end of \framebox

The \framebox bits are just so that you can see how the
alignment is working. In practice you don't need them.

This works because the alignment is on the *base-line*
of the top-most piece of vertical material in each cell.
The \null provides a blank line to align with the first
line of text in the other cell. Then the negative \vskip
moves up by the appropriate amount so that the box generated
by \includegraphics seems to start at the top of the whole
{tabular} environment.

You can do it without the \vskip as follows:

Here's some text about the image at right:
}% end of \framebox

so that there is alignment of the two \null s.
However, this gives extra space above the {tabular}.
(as is easily seen with the \framebox ).

For centre-alignment, there's a standard package:


Here's some text about the image at right:

> It works (by vmoving the graphic in the first column!) but seems to  
> me rather clunky.

That sort-of corresponds to my  \vskip-\baselineskip ,
but I don't have to guess by how much to move.

> Is that really all there is? (\vspace{xmm} after the text doesn't  
> have the effect I would have expected.)

I find the above methods easiest.
You do have to provide fixed widths for the cells.

In TeX terms, the cell contents are placed inside \vtop boxes
filled with vertical material; i.e. paragraphing.
These are provided by the cell declaration:

    p{<width>}   --- for top alignment

    m{<width>}   --- for middle alignment  ( array.sty )
    b{<width>}   --- for bottom alignment  ( array.sty )

If you just use simple cell declarations such as:  c l r
then you get TeX's alignment for a 1-line box (as if
it were an  \hbox ) for the cells.
This alignment is by their natural baseline, which is
usually at the bottom for \includegraphics .

> Regards
> --schremmer

Hope this helps,


Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114

------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/

More information about the macostex-archives mailing list