# more problems with longtable and multirow

in my previous question there were a couple of workarounds that solved my immediate issue. However, I have the feeling that those two packages do not work well together. Adding one more column and having multirows on different set of rows make the workarounds not working.

Here is the code:

\documentclass{article}

\usepackage{longtable}
\usepackage {multirow}
\usepackage{lipsum}

\begin{document}

\begin{center}
\begin{longtable}{p{.15\textwidth} p{.15\textwidth} p{0.32\textwidth} p{0.32\textwidth}}
\hline
1 & 1.1 & \multirow{2}{.32\textwidth} {\lipsum[1] } & some text \\ \cline{4-4}
& 1.2 & & \multirow{2}{.32\textwidth}{\lipsum[2]} \\ \cline{2-3}
& 1.3 & some other text  & \\ \hline
2 & 2.1 & some more text & \lipsum[3] \\ \hline
\end{longtable}
\end{center}

\end{document}


And the result is clearly not good. Any help in finding a generic solution to this problem would be very appreciated.

• It has nothing to do with longtable, you get the same result with tabular. You might have the wrong idea about what \multirow actually does. Let me ask another way: that exactly are you trying to achinve here? Aug 20, 2019 at 12:21
• This issue is discussed in Section 3.8 "Dealing with tall entries" of the multirow package documentation, mirrors.ctan.org/macros/latex/contrib/multirow/multirow.pdf where manual solutions are proposed. Aug 20, 2019 at 12:41
• In particular, read the manual section 3.8 item 2: 2. The second case is when the \multirow entry is taller than the surrounding normal rows. In that case the multirow text will stick out of its block. We must now enlarge the other rows, and that is something \multirow cannot do. Aug 20, 2019 at 13:13
• I don't understad what you're trying to achieve suing \multirow. You don't really have to use it, unless… Could you pst a small sketch of what you want to obtain? Aug 20, 2019 at 14:13
• Could you please add a sketch of what you want to achieve. Maybe a more "real life" example could also be helpful. Aug 20, 2019 at 17:53

The answer to your previous (almost the same) question solves your problem. If not, your question is not clear.

\documentclass{article}
\usepackage{makecell, longtable}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\begin{document}
\begin{longtable}{|p{\dimexpr0.07\textwidth-2\tabcolsep-1.25\arrayrulewidth}
|p{\dimexpr0.07\textwidth-2\tabcolsep-1.25\arrayrulewidth}
|p{\dimexpr0.43\textwidth-2\tabcolsep-1.25\arrayrulewidth}
|p{\dimexpr0.43\textwidth-2\tabcolsep-1.25\arrayrulewidth}
|}
\hline
1   & 1.1   & \lipsum[1]        & some text     \\ \cline{2-4}
& 1.2   &                   & \lipsum[2]    \\ \cline{2-4}
& 1.3   & some other text   &               \\
\hline
2   & 2.1   & some more text    & \lipsum[3]    \\
\hline
\end{longtable}
\end{document}


Note: \multirow[<number of rows>{...}{cell's contents} doesn't determine its height with number of rows (which it contain). It spans the given number of lines in adjacent column. If their height is smaller than height of the multirow cell, then its contents will spill out on the adjacent cells as you observe in your question.

Please, read the package documentation as @ebcontrol suggests in his comment.

Edit: The column width is nowcorrected and the width of the longtable is exactly \textwidth.

• @Sveinung, thank you for editing my answer. Unfortunately we doing this in the same time (beside misspelling of you name I notice some other errors in code and that my explanation wasn't uploaded. Aug 20, 2019 at 13:17

NB I have updated the code for example 2

I use shorter dummy texts so the examples are more readable. Look at the two enclosed examples and tell us (me) how they deviate from what you try to achieve. In particular, example 2 demands manual work:

Example 1

\documentclass{article}

\usepackage{longtable, booktabs, array}
\usepackage{lipsum}

\newcolumntype{O}{p{\dimexpr(0.15\linewidth-1.5\tabcolsep)}}
\newcolumntype{Q}{p{\dimexpr(0.35\linewidth-1.5\tabcolsep)}}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\newcommand{\mytexti}{This is a dummy text, however I have an issue using multirow and longtable. The content in the multirow cell is very large, and it goes well beyond the limit of the "non-multirowed" rows. LaTeX ignores that and starts the following row just behind those rows, therefore overwriting the content.}

\newcommand{\mytextii}{This is a shorter dummy text, LaTeX ignores me!}

\begin{document}

\begin{longtable}{@{}OOQQ@{}}
1 & 1.1 & \mytexti         & some text \\ \cmidrule{4-4}
& 1.2 &                  & \mytextii \\ \cmidrule{3-3}
& 1.3 & some other text  &           \\ \bottomrule \addlinespace[1ex]
2 & 2.1 & some more text   & \mytexti  \\ \bottomrule
\end{longtable}

\end{document}


Example 2

\documentclass{article}

\usepackage{longtable, booktabs, array, multirow, bigstrut}
\usepackage{lipsum}

\newcolumntype{O}{p{\dimexpr(0.15\linewidth-1.5\tabcolsep)}}
\newcolumntype{Q}{p{\dimexpr(0.35\linewidth-1.5\tabcolsep)}}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\newcommand{\mytexti}{This is a dummy text, however I have an issue using multirow and longtable. The content in the multirow cell is very large, and it goes well beyond the limit of the "non-multirowed" rows. LaTeX ignores that and starts the following row just behind those rows, therefore overwriting the content.}

\newcommand{\mytextii}{This is a shorter dummy text, LaTeX ignores me!}

\begin{document}

\begin{longtable}{@{}OOQQ@{}}