1

I have a \longtable with \multirow cells, as in the picture attached.

Here, if I try to break the line and there isn't enough space at the bottom of the page, the remaining part of the sentence goes outside of the table.

Same issue if I don't force any interruption but the sentence is quite long.

Do you think \pagebreak is the only solution?

Note:

  • I know that I'm giving a wrong number of lines to \multirow (i.e. \multirow[t]{5}{=}{item 1\newline pos. A} instead of \multirow[t]{8}{=}{item 1\newline pos. A} but I'm working with thousands of lines which will change in length in a future revision of the doc, so, for me, is easier to count the number of \square (anyway, this seems to not be the cause of my issue).
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{pdflscape}
\renewcommand{\baselinestretch}{1.5}
\begin{document}
\begin{landscape}
\begin{longtable}{|p{4cm}|p{10cm}|p{4cm}|p{4cm}|}
\hline
COMPONENT & CHECKS DESCRIPTION & CHECKED – NOTE & CHECKED – NOTE\\
\hline
\endfirsthead
\hline
COMPONENT & CHECKS DESCRIPTION & CHECKED – NOTE & CHECKED – NOTE\\
\hline
\endhead
\hline
\endfoot
\hline
\endlastfoot
\multirow[t]{5}{=}{item 1\newline pos. A} & check this doing that text text text text text text  & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
\hline
\multirow[t]{4}{=}{item 2\newline pos. B} & check this doing that text text text text text text  & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
\hline
\multirow[t]{5}{=}{item 3\newline pos. C} & check this doing that text text text text text text  & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
\hline
\multirow[t]{3}{=}{item 4\newline pos. D} & check this doing that text text text text text text  & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
\hline
\end{longtable}
\end{landscape}
\end{document}

issue with \multirow whitin \longtable

2
  • 1
    What exactly does the expected output look like? Do you want both "item 4" and "pos. D" to appear on the second page? If so, you could use \\* instead of \\ whenever you want to prevet a pagebreak between the teo table rows.
    – leandriis
    Apr 9, 2021 at 18:32
  • Thank you! It's perfect.
    – tormec
    Apr 9, 2021 at 18:53

1 Answer 1

1

As noted by @leandriis, you should use \\* where you don't want a page break. To be more precise: if you want to keep a 'block' of lines together, use \\* between them, but use \\ at the end to allow a page break there. In your example, the \hlines also allow a page break, so strictly speaking you could use \\* before it too, but I think it is cleaner not to do that.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{pdflscape}
\renewcommand{\baselinestretch}{1.5}
\begin{document}
\begin{landscape}
\begin{longtable}{|p{4cm}|p{10cm}|p{4cm}|p{4cm}|}
\hline
COMPONENT & CHECKS DESCRIPTION & CHECKED – NOTE & CHECKED – NOTE\\
\hline
\endfirsthead
\hline
COMPONENT & CHECKS DESCRIPTION & CHECKED – NOTE & CHECKED – NOTE\\
\hline
\endhead
\hline
\endfoot
\hline
\endlastfoot
\multirow[t]{5}{=}{item 1\newline pos. A} & check this doing that text text text text text text  & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
\hline
\multirow[t]{4}{=}{item 2\newline pos. B} & check this doing that text text text text text text  & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
\hline
\multirow[t]{5}{=}{item 3\newline pos. C} & check this doing that text text text text text text  & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
\hline
\multirow[t]{3}{=}{item 4\newline pos. D} & check this doing that text text text text text text  & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\*
& check this doing that text text text text text text text text text text text text text & $\square\ldots$ & $\square\ldots$\\
\hline
\end{longtable}
\end{landscape}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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