# Text in multirow overlaps the next row

Suppose, I want to create a table like this:

I decided to use \multirow with \newline. But the \multirow cell is not stretched vertically:

Code:

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage{array}
\usepackage{multirow}
\usepackage{hhline}
\setlength{\parindent}{0cm}
\begin{document}
\begin{tabular}{|m{2cm}|m{2cm}|}
\hline
\multirow{2}{2cm}{line 1
\newline
line 2 line 2 line 2 line 2} &
1\\
\hhline{|~|-|}
& 2\\
\hline
text & text\\
\hline
\end{tabular}
\end{document}


How to fix?

• muiltirow does not know how long the contained text is. You simply need to give it another row -> 3. – Martin H May 11 '13 at 13:03
• @MartinH It works. But is it the only option? – user4035 May 11 '13 at 13:05
• I've yet to see a table using \multirow that can't be improved by removing \multirow. ;-) In any case, if you say your cell has to span two rows, but the text in it is longer than two rows, you have to arrange things so that there's no overlap. – egreg May 11 '13 at 14:20

It often works better to make the large entry a normal cell and then separately arrange the vertical stacking of the other material with a nested tabular or, here just as paragraphs.

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage{array}

\usepackage{hhline}
\setlength{\parindent}{0cm}
\begin{document}
\begin{tabular}{|m{2cm}|m{2cm}|}
\hline
line 1 line 1 line 2 line 2 line 2 line 2&
1
\medskip\hrule\medskip
2\\
\hline
text & text\\
\hline
\end{tabular}
\end{document}


You may need to adjust the vertical spacing to your needs. As suggested in chat, this produces a 2 closer to the line, and makes the line extend to touch the vertical rules.

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage{array}

\usepackage{hhline}
\setlength{\parindent}{0cm}
\begin{document}
\begin{tabular}{|p{2cm}|p{2cm}|}
\hline
line 1 line 1 line 2 line 2 line 2 line 2&
1
\par\medskip\nointerlineskip\hbox to \hsize{\kern-\tabcolsep\hrulefill\kern-\tabcolsep}
\vspace{-1mm}
2\\
\hline
text & text\\
\hline
\end{tabular}
\end{document}

• How to get rid of the padding between the vertical and horizontal lines: \medskip\hrule\medskip? – user4035 May 11 '13 at 17:01
• @user4035 several ways eg \par\medskip\nointerlineskip\hbox to \hsize{\kern-\tabcolsep\hrulefill\kern-\tabcolsep}\medskip – David Carlisle May 11 '13 at 17:09
• What instructions control the space between the line and 2? I removed the last \medskip - the gap became smaller. – user4035 May 11 '13 at 17:17
• it should be a normal baselineskip from the line to the baseline of the 2, plus any additional space (I used \medskip but you could use \vspace{1pt} or whatever you want – David Carlisle May 11 '13 at 17:20

The table you want to create doesn't require \multirow:

\documentclass{article}
\begin{document}
\begin{tabular}{|l|l|}
\hline
line 1 & 1\\
\cline{2-2}
line 2 line 2 & 2\\
line 2 line 2 &\\
\hline
text & text\\
\hline
\end{tabular}
\end{document}