3

I m working on one table which has one row which spans over 3 rows but text in this row is very lengthy so it uses more than 3 lines so all text is not visible. How can i increase row height dynamically to fit this row.

\documentclass[crop]{standalone}
\usepackage{multirow}

\begin{document}

\Huge
\begin{tabular}{|c|c|c|}
 \hline
  \multirow{3}{*}{\parbox{8cm}{This is line1 ~\\ ~\\ This is line 2 ~\\ ~\\ This is line3 ~\\ ~\\ This is line 4}} & cell1 & cell2 \\ \cline{2-3}
& cell3 & cell4 \\ \cline{2-3}
& cell5 & cell6 \\ \hline
\end{tabular}

 \end{document}

line3 and line4 are not visible as it uses more than 3 row space.

As shown in the image:

enter image description here

How can i control it?

Regards

manish
  • 295
  • One of the easiest ways would be to change the size of the font of the 4 lines. \footnotesize should be sufficient to fit everything in there. However, it makes NO sense to allocate 3 rows as space and than attempt to fit 4 rows, with many white space rows, within that area. If you need 4 rows, why not use 4 rows? – Mythio Aug 21 '13 at 08:39
  • Mythio, What if I don't know how many rows I need in advance? I make a template. Variable then will be replaced by some value. Would it fit height or not - I don't know. – tolok Oct 07 '14 at 07:02

1 Answers1

1

Here is one approach, using a p column (from the array package) of the specified width (8 cm) to replace your \parbox and \multirow construction.

The rest of the cells to the side are placed in a nested tabular aligned to the [t]op, with the spacing around the outer column zeroed for consistent spacing through the table. Your question wasn't entirely clear about what you expect to happen with the rules, so you may need to make some adjustments to the \hline commands in the nested table.

After converting to a p column, use \newline instead of \\ (and drop the ties). If this whole cell is always intended to have double spacing, you may want to investigate the setspace package for a cleaner, automatic solution to the line spacing.

\documentclass[crop]{standalone}
\usepackage{array}
\newcommand{\dblnewline}{\newline \newline}

\begin{document}

\Huge
\begin{tabular}{|p{8cm}|@{}c@{}|}
  \hline
  This is line1 \dblnewline
  This is line 2 \dblnewline
  This is line3 \dblnewline
  This is line 4 \dblnewline
  This is line5 &
  \begin{tabular}[t]{c|c}
    cell1 & cell2 \\ \hline
    cell3 & cell4 \\ \hline
    cell5 & cell6 \\ \hline
  \end{tabular} \\
  \hline
\end{tabular}
\end{document}

enter image description here

Paul Gessler
  • 29,607