[texhax] Vertical alignment in table containing text and figures
Henry Law
news at lawshouse.org
Mon Sep 21 15:18:48 CEST 2009
(I posted this to comp.text.tex yesterday; I hope there's not too much
overlap in the readership from there and here.)
As part of a reference book I need to format a series of pictures with
explanatory text. I plan to do it using a table of two columns: #1 has
the text, #2 the image and they divide the line 60:40.
I've used the "array" package for the table and a \parbox for the text.
I've almost cracked it, except for the vertical alignment. If the
explanatory text is deeper than the image, I want the image at the top
of the cell; similarly if the text is brief then I want it too at the
top of the cell; whereas everything I do comes out with the smaller of
the two _bottom_ aligned (as shown in
http://www.lawshouse.org/tex/Alignment.jpg).
Surely this should be easy to do? It's the default behaviour in WP
packages like OpenOffice and MS Wierd. Can someone help me fix my code,
or else suggest an alternative, sure-fire way of doing it?
My sample file is at http://www.lawshouse.org/tex/array.tex and the
images it uses are http://www.lawshouse.org/tex/mary-rose.jpg and
http://www.lawshouse.org/tex/007985029-1.jpg but here's the code (which
may be wrapped).
\documentclass[a4paper,12pt]{book}
\usepackage{graphicx}
\usepackage{array}
\begin{document}
\begin{tabular}{|>{\raggedright}b{0.6\textwidth}|>{\centering}b{0.4\textwidth}|}
\hline
\parbox{0.6\textwidth}{Lorem ipsum dolor sit amet, consect wisi enim
ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
lobortis nisl ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit
amet, consectetuer adipiscing veniam} \\
& \includegraphics[width=0.4\textwidth]{mary-rose.jpg} \tabularnewline
\hline
\parbox{0.6\textwidth}{Lorem ipsum dolor sit amet, consect wisi enim
ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
lobortis nisl ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit
amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod
tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad
minim veniam Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam
erat volutpat. Ut wisi enim ad minim veniam} \\
& \includegraphics[width=0.4\textwidth]{007985029-1.jpg} \tabularnewline
\hline
\end{tabular}
\end{document}
The images are Copyright © 2009 BBC; I scrounged them for testing.
--
Henry Law Manchester, England
More information about the texhax
mailing list