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 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?

share|improve this question
2  
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. –  David Carlisle Apr 16 '12 at 9:45
add comment

1 Answer 1

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%
  \advance\@multispan\m@ne
  \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
  \@multicnt#2%
  \advance\@multicnt-#1%
  \advance\@multispan\@ne
  \leaders\hrule\@height\arrayrulewidth\hfill
  \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:

enter image description here

share|improve this answer
    
Thank you very much. It seems to work fine now... this is really the end of a long nightmare! –  Gabriele Apr 16 '12 at 10:17
add comment

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.