2

I have the following table which gives an overfull vbox because the multirow takes more vertical space than each of the rows it spans. Also, I would like the multirow to center vertically if possible.

\documentclass[a4paper]{article}

\usepackage{multirow,tabularx}
\usepackage[margin=1in]{geometry}

\begin{document}

\begin{table*}\begin{tabularx}{\linewidth}{l X X X} \hline

Surface & $K$ (courbure) & $\chi$ (caracteristique d'Euler) & Remarques \\ \hline

$S^2,R P^2$ & $K = +1$ \newline geometrie elliptique & $\chi>0$ &
$\pi_1$ fini, $\pi_2 \neq 0$ \\

$T^2, K^2$ (Klein) & $K = 0$ \newline geometrie euclidienne & $\chi=0$ & 
\multirow{2}{\hsize}{ce sont des $K(\pi,1)$ et le revetement universel est $R^2$} \\

genre $>1$ & $K = -1$ \newline geometrie hyperbolique & $\chi<0$ & \\ \hline

\end{tabularx}
\end{table*}

\end{document}

Is there a way to fix this without using nested tabulars? For this layout, I believe I would need three tabulars, one for each column, and I was looking for a neater solution. Even if I used three tabulars, it is not clear that the rows should line up, creating more problems.

1 Answer 1

3

Multirow is unnecessary here, because you're already in an X column.

I did not get any overfull \vboxes when running your MWE, but I did get underfull \hboxes caused by TeX attempting justification in the narrow column widths.

This can be prevented by inserting \raggedright into each X column to left-justify the content. In the code below, I achieved this with the tabularx preamble

l *3{>{\raggedright\arraybackslash}X}

which creates 3 X columns each set ragged right. The \arraybackslash is needed to restore \\ because one of the X columns is also the last column of the tabularx environment.

The vertical alignment of the X cells can be adjusted as described in the tabularx manual:

\renewcommand{\tabularxcolumn}[1]{m{#1}}

By default \tabularxcolumns are p columns, which align at the baseline of the first line of text in the cell. By changing them to m columns as I've done above, you can achieve the centered alignment.

In the code below, I've also added booktabs (highly recommended) for some additional enhancements to the table.

\documentclass[a4paper]{article}

\usepackage{booktabs,tabularx}
\usepackage[margin=1in]{geometry}
\renewcommand{\tabularxcolumn}[1]{m{#1}}

\begin{document}
\begin{table}
\begin{tabularx}{\linewidth}{l *3{>{\raggedright\arraybackslash}X}}
\toprule
Surface & $K$ (courbure) & $\chi$\newline (caracteristique d'Euler) & Remarques \\
\midrule
$S^2,R P^2$ & $K = +1$ \newline geometrie elliptique 
  & $\chi>0$ & $\pi_1$ fini, $\pi_2 \neq 0$ \\
$T^2, K^2$ (Klein) & $K = 0$ \newline geometrie euclidienne 
  & $\chi=0$ & ce sont des $K(\pi,1)$ et le revetement universel est $R^2$ \\
genre $>1$ & $K = -1$ \newline geometrie hyperbolique 
  & $\chi<0$ & \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

enter image description here

You must log in to answer this question.

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