# How to adjust multi-lined cell entry with multirow

When I try this code:

\documentclass{article}
\usepackage{multirow, }

\begin{document}

\begin{table}[htb]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
& \multirow{2}{*}
{\begin{tabular}{@{}c@{}} 1, 2, 3, 4, 5,\\ 6, 7, 8, 9, 10, \\ 11, 12, 13, 14, 15, \\16, 17, 18, 19, 20,\\ 21, 63, 64, 65, 66,\\ 72, 75, 76, 78, 79 \end{tabular}} & &  &  & \\ \cline{3-6}
&  &  &  & &  \\
\hline
\end{tabular}
\end{table}

\end{document}


it produces this:

and

Overfull \vbox (48.0pt too high) detected


Removing \multirow{2}{*} causes the cell vertically mis-aligned. How to fix this?

There are probably many ways to "fix" this. One way would be to (a) change \multirow{2}{*} to \multirow{6}{*} and (b) add four more rows of

    &  &  &  &  &  \\ \cline{3-6}


to the outer tabular environment. (The directives \cline{3-6} are needed only if you need to add partial horizontal lines.)

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}[htb]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
& \multirow{2}{*}
{\begin{tabular}{@{}c@{}}
1, 2, 3, 4, 5,\\ 6, 7, 8, 9, 10, \\ 11, 12, 13, 14, 15, \\
16, 17, 18, 19, 20,\\ 21, 63, 64, 65, 66,\\ 72, 75, 76, 78, 79
\end{tabular}}
&  &  &  &  \\ \cline{3-6}
&  &  &  &  &  \\ \cline{3-6}
&  &  &  &  &  \\ \cline{3-6}
&  &  &  &  &  \\ \cline{3-6}
&  &  &  &  &  \\ \cline{3-6}
&  &  &  &  &  \\ \hline
\end{tabular}
\end{table}
\end{document}


Addendum: You've indicated in a comment that it is "not possible" (permissible?) to add extra rows. I assume you're referring to the first column and to columns 3 thru 6, as the 2 column has six rows by construction. To create a structure in which columns 1 and 3 thru 6 have exactly two rows, one can place three separate tabular structures side by side and use the [t] location specifier to top-align the smaller tabulars. With such a setup, it's not even necessary to load the multirow package.

\documentclass{article}
\begin{document}

\begin{table}[ht!]
\centering
\begin{tabular}[t]{|c} % 1 column, 2 rows
\hline
\\
\\ \hline
\end{tabular}%
\begin{tabular}[t]{|c|}% 1 column, 6 rows
\hline
1, 2, 3, 4, 5,\\ 6, 7, 8, 9, 10, \\
11, 12, 13, 14, 15, \\ 16, 17, 18, 19, 20,\\
21, 63, 64, 65, 66, \\ 72, 75, 76, 78, 79 \\ \hline
\end{tabular}%
\begin{tabular}[t]{c|c|c|c|} % 4 columns, 2 rows
\hline
& & & \\ \hline
& & & \\ \hline
\end{tabular}
\end{table}
\end{document}

• Adding more rows will not be possible (my data is for 2 rows, I have to leave blank rows if I add more). – hola Aug 11 '14 at 7:13
• @pushpen.paul - I've provided an addendum to my answer to show how tabulars might be placed side by side. I hope this is what you're looking for; I must confess that I'm not sure I understand your requirements. – Mico Aug 11 '14 at 8:49

You can also do it with just two rows. Add some suitable space after each row.

\documentclass{article}
\usepackage{multirow, }

\begin{document}

\begin{table}[htb]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
& \multirow{2}{*}
{\begin{tabular}{@{}c@{}}
1, 2, 3, 4, 5,  \\
6, 7, 8, 9, 10, \\
11, 12, 13, 14, 15, \\
16, 17, 18, 19, 20,\\
21, 63, 64, 65, 66,\\
72, 75, 76, 78, 79
\end{tabular}}
&  &  &  & \\[5.5ex] \cline{3-6}
&  &  &  & &  \\[5.5ex]
\hline
\end{tabular}
\end{table}

\end{document}


I have used 5.5ex for each row.

• Rather than choosing 5.5ex, it may be more straightforward to choose 24pt: If the main document font size is 10pt, then the vertical distance between baselines will be 12pt, and since we need to add the equivalent of 2 rows, one needs exactly 24pt of extra vertical skip... – Mico Aug 17 '14 at 10:54
• @Mico Good calculation and point. I agree. Thanks for noting. :-) – user11232 Aug 17 '14 at 12:13

Actually, I figured out myself:

\documentclass{article}
\usepackage{multirow, }

\begin{document}

\begin{table}[htb]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
& \multirow{2}{*}
{\begin{tabular}{@{}c@{}} 1, 2, 3, 4, 5,\\ 6, 7, 8, 9, 10, \\ 11, 12, 13, 14, 15, \\16, 17, 18, 19, 20,\\ 21, 63, 64, 65, 66,\\ 72, 75, 76, 78, 79 \end{tabular}}
& &  &  & \\ &  &  &  & &  \\ &  &  &  & &  \\ \cline{3-6}
&  &  &  & &  \\ &  &  &  & &  \\ &  &  &  & &  \\
\hline
\end{tabular}
\end{table}

\end{document}


Credit goes to Mico for the suggestion that we should increase number of rows.

• You should use \multirow{6}{*}... Note 6 instead of 2. – user11232 Aug 16 '14 at 23:50