8

I'm trying to create a multi-page table with all cells having the same height (as well as certain fixed widths) so that certain manual cut-and-paste operations are a lot easier. One issue is that one column in particular is text-heavy and should line-break within the cell. As I don't want it justified, I looked into alternatives such as Fixed column-width table with text left-aligned in cells. This is doing exactly what I want for horizontal alignment.

For vertical alignment, I've looked at How to specify a fixed height for all rows in a table? and the \vphantom method detailed in the above link doesn't seem to be working.

Here's what I'm currently working with:

\documentclass[11pt]{article}
\usepackage{array}

\newcolumntype{P}[1]{>{\raggedright\hspace{0pt}\arraybackslash}p{#1}}
\def\Z{\vphantom{\parbox[c]{1.7in}{\Huge Something Long}}}

\begin{document}
\begin{tabular}{| c || P{0.5in} || P{0.5in} || P{5in} |}\hline

1.  \Z &&& Long long long long long long long long long
            long long long long long long long text  \\\hline
2.  \Z &&& More long long long long long long long long
            long long long long long long long text  \\\hline
\end{tabular}

When I compile, the cells do not have a uniform height, and none of them are as large as 1.7 inches vertically. So this suggests that somehow the \vphantom method is failing.

Does anybody know of a relatively straightforward solution to this problem?

2
  • 1
    The problem here is that \parbox[<position>]{<width>}{<text>} specifies the <width>, not the <height> of <text>. Herbert's suggestion to use >{\rule{0pt}{<height>}} for the first column puts a zero-width rule of height <height> in each row, effectively making them all the same height.
    – Werner
    Aug 2, 2011 at 15:56
  • Werner: alright, that makes sense. For some reason I thought the argument to \parbox was the height of the resulting \vphantom. Thanks for clearing that up.
    – dvitek
    Aug 2, 2011 at 18:07

1 Answer 1

9

In this example each cell has a height of 3cm:

enter image description here

\documentclass[11pt]{article}
\usepackage{array,ragged2e}

\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}

\begin{document}
\begin{tabular}{| >{\rule{0pt}{3cm}}c || P{0.5in} || P{0.5in} || P{3in} |}\hline

1. &&& Long long long long long long long long long
            long long long long long long long text  \\\hline
2. &&& More long long long long long long long long
            long long long long long long long text  \\\hline
\end{tabular}
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .