[Tex/LaTex] Setting single row height with multirow

formattinglyxmultirowtables

I have a table in LyX document. And I'm using multirow to span text across multiple rows. For example I might want the text to span across 2 rows, the problem occurs when it doesn't fit, then it just goes over the cell border (to third cell).
Is there a way to set row height manually for single row?
Or even better could is there a way to update multirow such that it will automatically enlarge cells when text inside them is too big?

This is the Lyx source for it:

\begin{tabular}{|c|c|}
\hline 
a & b\tabularnewline
\hline 
\hline 
\multirow{2}{2cm}{Text spanning over two fields} & \tabularnewline
\cline{2-2} 
 & \tabularnewline
\hline 
\end{tabular}

Best Answer

You have to make sure, that there is enough room for the multirow. In the following example I increase the height of the second colums with a strut (sr). The code will be:

\documentclass{article}
\usepackage{multirow}

\newcommand{\sr}{\rule[-0.45cm]{0pt}{0.9cm}}
\begin{document}

\begin{tabular}{|c|c|}
\hline 
a & b\tabularnewline
\hline 
\hline 
\multirow{2}{2cm}[0.1cm]{Text spanning over two fields} &\sr one\tabularnewline
\cline{2-2} 
 & \sr two\tabularnewline
\hline 
\end{tabular}


\end{document}

I gave the \rule a depth to make the items of the second column vertically centered.

Related Question