Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a problem using multirow along with text wrapping when spanning cell contains a lot of text. Here is my code:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{longtable,array,booktabs,multirow}

\begin{document} 

\begin{longtable}{@{} m{3cm} m{3cm} m{3cm} @{}} \toprule[0.04cm]
Lorem & Lorem & Lorem \\ \midrule[0.04cm] 
Lorem ipsum & \multirow{2}{3cm}{Lorem ipsum dolor sit amet.} & Lorem ipsum \\ \cmidrule{1-1}\cmidrule{3-3}
Lorem ipsum & & Lorem ipsum \\ \midrule
Lorem ipsum & Lorem ipsum & Lorem ipsum \\ \bottomrule[0.04cm]
\end{longtable}

\begin{longtable}{@{} m{3cm} m{3cm} m{3cm} @{}} \toprule[0.04cm]
Lorem & Lorem & Lorem \\ \midrule[0.04cm] 
Lorem ipsum & \multirow{2}{3cm}{Lorem ipsum dolor sit amet, consectetur adipiscing elit.} & Lorem ipsum \\ \cmidrule{1-1}\cmidrule{3-3}
Lorem ipsum & & Lorem ipsum \\ \midrule
Lorem ipsum & Lorem ipsum & Lorem ipsum \\ \bottomrule[0.04cm]
\end{longtable}

\end{document}

The only difference between these tables is the text length in multirow cell. The first table looks fine, but the second has some overlap:

Wrapping text in parbox doesn't help. Is there any universal way to set a proper height and vertical alignment for that cell? That code is a part of automatic report-generator, so text length in the spanning cell may vary.

share|improve this question

1 Answer 1

It turns out, the best way to do that is to create a table inside a table cell instead of using rowspan, like this:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{longtable,array,booktabs}

\begin{document} 

\begin{longtable}{@{} m{3cm} m{3cm} m{3cm} @{}} \toprule[0.04cm]
Lorem & Lorem & Lorem \\ \midrule[0.04cm] 
\begin{tabular}{@{} m{3cm} @{}} Lorem ipsum \\ \cmidrule{1-1} Lorem ipsum \end{tabular} & 
Lorem ipsum dolor sit amet, consectetur adipiscing elit. & 
\begin{tabular}{@{} m{3cm} @{}} Lorem ipsum \\ \midrule Lorem ipsum \end{tabular} \\ \midrule
Lorem ipsum & Lorem ipsum & Lorem ipsum \\ \bottomrule[0.04cm]
\end{longtable}

\end{document}

example

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.