# Move cell with rowspan on next page

I use multirow package and ltablex package for multipage tables. I have a problem, when cell with rowspan breaks between pages. Then horizontal lines are not drawn http://web-engineering.com.ua/Main.pdf

As you can see there, hline on bottom of first page and hline on start of second page does not exists. I use \cline for drawing line. The problem is that I do not want to hardcode \hline in the last row ot the page, because when text before the table is changed, lines will be drawn over the merged cell http://web-engineering.com.ua/Main1.pdf

How can I force lines to be drawn at the beginning and ending of each page?

\begin{document}
\section{Section}

\setlength{\newtblsparewidth}{\linewidth-2\tabcolsep-2\tabcolsep-2\tabcolsep-2\tabcolsep-2\tabcolsep}
\setlength{\newtblstarfactor}{\newtblsparewidth / \real{4}}

\begin{tabularx}{\linewidth}{l|l|l|X|}\nobreakhline
\multicolumn{1}{|m{0.13\newtblsparewidth}}{\multirow{9}{0.13\newtblsparewidth}{\textbf{tt}}} &
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} &
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{zhim=<zpayw>[,<cckd>][,<ssr>]} &
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} &
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} &
\multicolumn{1}{|m{0.35\newtblsparewidth}}{kcep=<btgzqgb>[,<klmxacfq>]} &
\multicolumn{1}{|m{0.15\newtblsparewidth}}{Fit

FvlB

FbmH,hrr

FlvV,cnhg

FaoBH,llu

FjvBV,ijen
} & \multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} &
\multicolumn{1}{|m{0.35\newtblsparewidth}}{uvemlwsx=<gmjy>,<lfd>,<wc>,<id>} &
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & \multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} &
\multicolumn{1}{|m{0.35\newtblsparewidth}}{faxjuwoz=osuwwayo|xwgvd|zxnb} &
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} &
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{oarfeqjem=<gakx>} &
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} &
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} &
\multicolumn{1}{|m{0.35\newtblsparewidth}}{vajuwpzmk=<taur>} &
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} &
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{vajuwpzmk=<taur>} &
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} &
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} &
\multicolumn{1}{|m{0.35\newtblsparewidth}}{vajuwpzmk=<taur>} &
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} &
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{
Id sqpvuv\{hdu\}, jvet aoi eadthy xvy skwlefrhyix tcsb ag nlbreq\{ajt, uqsr, mqjwn, vat, mi, ru,\} flx. ayn aemygedw aem qyadippy zm lvmehv(1/72 wcai).

Oayvflulp xitky sanghd fhpq cc vkxrnxzowvt ah a qexom qy limrqp aw 100\% zyen. Tagi leaayban yw ggmaldb xua Ajdma Aubxsag/Rlatnt. Ie rudt uaqs, qx ydicegx aepaqqus nanzz gm slempx, Ahgpxad oablrfarpj hp ax:

V(kt)=V$$lysk\_fed$$$$aqi{}$$72.0/(qggx\_mwvpl)

Twb dbtsla{hmys\_fjqyu} wacaxmlnt sl fpgv ac wddqaw ‘Pprdbpwhznf/Patj Dirwuaf/Rpmqvcwqcz’ ngdadcsu (gukd bj Aqhdaap auw PDF-XCjazmw Vqhymy).
} \\ \hline

\end{tabularx}

\end{document}

-
The question (and certainly the answer so far) doesn't really involve moving cells or rowspan, but is about cline in multi-page tables. You might want to consider changing the title, to help the archives. –  David Carlisle Feb 17 '12 at 13:54

I have simplified down to simply longtable as I know that better (and you didn't supply a MWE) but I believe the packages you are using build on LT.

Longtable doesn't mess with \cline the way it does with \hline as cline is a bit trickier, unlike \hline it does not add any vertical space, it adds negative space so that the line overprints the adjacent cells. It does this so that vertical lines do not show a gap, this isn't a problem for \hline as the line is full width so fills any gaps.

For longtable it would work best not to reverse space and overprint, and instead add small line fragments to fill in any vertical rules as they cross where parts where the cline is not drawing a horizontal rule. See the square vrule at the start of the example below.

Probably a reasonable interface to this requirement would be a version of \hhline from the hhline package that allowed page breaks, however the code below does this by hand,

UPDATE Positioning of vertical lines differs depending on whether the array package is loaded or not. the code below has been fixed to (only) work with the array package spacing, Otherwise you would get jagged lines.

\documentclass{article}

\usepackage{array,longtable}

\makeatletter

\def\mylinex{%
\omit
\vrule \@width \arrayrulewidth \@height \arrayrulewidth
\hfill
\vrule \@width \arrayrulewidth \@height \arrayrulewidth&%
\omit\span\omit

\def\myline{%
\noalign{\nobreak}%
\mylinex
\noalign{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
\mylinex
\noalign{\nobreak}%
}

\makeatother
\textheight5\baselineskip

\begin{document}

\begin{longtable}{|l|l|l}\hline
aaa&bb&cc\\
w aaa&bb&cc\\
\cline{2-3}
x aaa&bb&cc\\
\myline
y aaa&bb&cc\\
\myline
a aaa&bb&cc\\
b aaa&bb&cc\\
c aaa&bb&cc\\
aaa&bb&cc\\
aaa&bb&cc\\
aaa&bb&cc\\
aaa&bb&cc\\
\end{longtable}

\end{document}


UPDATE Same basic code but with a \hhline like interface (just use - : or ~)

\documentclass{article}

\usepackage{array,longtable,hhline}

\makeatletter

\def\LTHH@let#1{\futurelet\@tempb\LTHH@loop}

\def\LTHH@loop{%
\ifx\@tempb\edef\next##1{%
\the\toks@\cr
\noalign{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
\omit
\the\toks@\cr
\noalign{\nobreak}%
}\else\let\next\LTHH@let
\ifx\@tempb~\@tempswafalse
\ifx\@tempb-\@tempswafalse
\errortoken
\fi\fi\fi\fi
\next}

\def\ltcline#1{%
\noalign{\nobreak}%
\omit\@firstamptrue\@tempswafalse
\xdef\@tempc{\ifx\extrarowheight\HH@undef\hskip-.5\arrayrulewidth\fi}%
\HH@xexpast\relax#1*0x\@@\toks@{}%
\expandafter\LTHH@let\@tempa%
}

\makeatother

\arrayrulewidth2pt
\textheight5\baselineskip
\pdfpageheight4\textheight

\begin{document}

\begin{longtable}{|l|l|l|l|l|}
\hline
aaa&bb&cc&dd&ee\\
\ltcline{:~:--:~:-:}
w aaa&bb&cc&dd&ee\\
\cline{2-3}
x aaa&bb&cc&dd&ee\\
\ltcline{:~:--:~:-:}
y aaa&bb&cc&dd&ee\\
\ltcline{:~:--:~:-:}
a aaa&bb&cc&dd&ee\\
b aaa&bb&cc&dd&ee\\
c aaa&bb&cc&dd&ee\\
d aaa&bb&cc&dd&ee\\
e aaa&bb&cc&dd&ee\\
\hline
\end{longtable}

\end{document}


-
Thanks for quick response. When I try this example, I get line just over 2 cells, but in different cases, number of cells is different. Unfortunatelly, I am not so experinced in TeX, so can you modify your suggestion for arbitrary number of cells, or give me a possibility to set number of cells as in \cline Thanks. –  Andrew Feb 17 '12 at 10:21
I may try to work up a better interface but if you take it as written and change \omit\span\omit to \omit\span\omit\span\omit\span\omit\span\omit it will span 5 columns rather than 2, just add a span and omit for each column the line has to span. –  David Carlisle Feb 17 '12 at 12:06
oh you accepted it as it was:-) but I just did an hhline interface, see updated answer –  David Carlisle Feb 17 '12 at 13:40
–  Andrew Feb 17 '12 at 15:57
sorry I don't understand? –  David Carlisle Feb 17 '12 at 16:02