# longtable multirow problem with cline and nopagebreak

I have a problem using with the package lontable and multirow together.

It seems that the \* is not avoiding the page breack, if I'm using \cline{i-j} just afterwards.

Here the original code for test.pdf:

\documentclass{article}
\usepackage{longtable}
\usepackage{multirow}
\begin{document}
\begin{longtable}{|c|p{1cm}|p{2cm}|p{5cm}|}
\hline
{} & {\bf ID} & {\bf name} & {\bf short Description} \\ \hline
\multirow{2}{*}{\bf 1} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
....
\multirow{2}{*}{\bf 21} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 22} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 23} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
....
\multirow{2}{*}{\bf 35} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\end{longtable}
\end{document}


Each record of this table is composed by 2 lines.

The results of this code is to break the record 22 in two pages: first line in page 1 and second line in page 2. That means that \* is not working properly.

\* seems to work correct if I remove \cline{2-4] corresponding to the record 22. This is the source code:

\documentclass{article}
\usepackage{longtable}
\usepackage{multirow}
\textheight=5\baselineskip
\begin{document}
\begin{longtable}{|c|p{1cm}|p{2cm}|p{5cm}|}
\hline
{} & {\bf ID} & {\bf name} & {\bf short Description} \\ \hline
\multirow{2}{*}{\bf 1} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 21} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 22} & \multirow{2}{*}{test1} & {name}& {short descrition} \\*
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 23} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 35} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\end{longtable}
\end{document}


The record 22 is not divided in two pages anymore, but it there is no cline.

How can I maintain the partial horizontal line, and at the same time avoid the pagebreack?

• Welcome to tex.sx! This would be easier to debug if your MWE showed the problem (ie the cline occurred at the page break) If you add \textheight=5\baselineskip to your preamble you can have short pages so do not need a bigger. I have updated your MWE this time. Also there is no need to sign your name as the system adds your identifier to the end of the post. Apr 16, 2012 at 9:45

longtable doesn't do anything special with \cline Perhaps it should. This inserts a \nobreak in the right place:

\documentclass{article}
\usepackage{longtable}
\usepackage{multirow}
\textheight=5\baselineskip
\makeatletter
\def\@cline#1-#2\@nil{%
\omit
\@multicnt#1%
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#2%
\cr
\noalign{\nobreak\vskip-\arrayrulewidth}}
\makeatother
\begin{document}
\begin{longtable}{|c|p{1cm}|p{2cm}|p{5cm}|}
\hline
{} & {\bf ID} & {\bf name} & {\bf short Description} \\ \hline
\multirow{2}{*}{\bf 1} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 21} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 22} & \multirow{2}{*}{test1} & {name}& {short descrition} \\*
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 23} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\multirow{2}{*}{\bf 35} & \multirow{2}{*}{test1} & {name}& {short descrition} \\* \cline{3-4}
& & \multicolumn{2}{c|}{detailed description} \\ \hline
\end{longtable}
\end{document}


So that the breaks happen at \hline only:

• Thank you very much. It seems to work fine now... this is really the end of a long nightmare! Apr 16, 2012 at 10:17
• I'm trying to adarpt your solution to booktab's \midrule and \cmidrule(lr){a-b}. My attempt doesn't work, unfortunately, so I may have to start a new question: \makeatletter \def\@cmidrule[#1-#2]#3#4\@nil{% \omit \@multicnt#3% \advance\@multispan\m@ne \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi \@multicnt#4% \advance\@multicnt-#4% \advance\@multispan\@ne \leaders\midrule\@height\arrayrulewidth\hfill \cr \noalign{\nobreak\vskip-\arrayrulewidth}} \makeatother Mar 16 at 22:04
• @Lucas looking at bookabs.sty looks like you intnded to redefine \@@@cmidrule with thre @ not one. also you are omiting most of the booktabs definiion Mar 16 at 22:15