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'm having an issue with a table that spans multiple pages and breaks across columns that span several rows. my code is listed below. the problem is that on page 1, row 1 shows up with foo1, bar1 and yikes1 with no problem. row 2 and foo2 also shows up on page 1 and then the page breaks, with bar2 and yikes2 ending up on page 2. i want it to break so that all of row 2 end up on the second page. the table will grow and shrink, so i'm hoping for a dynamic solution.

    \begin {supertabular}{|p{1.0in}|p{3.0in}|m{1.10in}|m{1.25in}|}
\hline
col 1
& col 2
& col 3
& col 4
\\\hline
\multirow{4}{*} 
row 1
& foo1
& bar1
& yikes1
\\\cline{2-4}
& foo1
& bar1
& yikes1
\\\cline{2-4}
& foo1
& bar1
& yikes1
\\\cline{2-4}
& foo1
& bar1
& yikes1
\\\cline{2-4}
\\\hline
\multirow{4}{*} 
row 2
& foo2
& bar2
& yikes2
\\\cline{2-4}
& foo2
& bar2
& yikes2
\\\cline{2-4}
& foo2
& bar2
& yikes2
\\\cline{2-4}
& foo2
& bar2
& yikes2
\\\cline{2-4}
\\\hline
\end {supertabular}
share|improve this question
2  
Can you also add the preamble of your document? I can't compile it when I copy/paste and I don't know the required packages. –  percusse Apr 17 '12 at 22:31
    
A full MWE is especially important when you're complaining about improper page breaks. –  rdhs Apr 18 '12 at 0:01
add comment

1 Answer

This is very very similar to the question longtable multirow problem with cline and nopagebreak. You could also look there how to make a proper MWE ;-)

Compared to this, your code is lacking the following things:

  1. You seem to have \multirow syntax wrong: \multirow{4}{*}{row 1}looks better here.
  2. You need to protect your lines from breaking inside the span of \multirow. Using \\* is a first step.
  3. Still it seems possible for a line to break at a \cline. David gave a patch for this.

With these things in mind, I made the following MWE:

\documentclass{article}

\usepackage{array,supertabular,multirow}

\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}

\vspace*{15cm}

\begin {supertabular}{|p{1.0in}|p{1.0in}|m{1.10in}|m{1.25in}|}
\hline
col 1
& col 2
& col 3
& col 4
\\\hline
\multirow{4}{*}{row 1}
& foo1
& bar1
& yikes1
\\*\cline{2-4}
& foo1
& bar1
& yikes1
\\\cline{2-4}
& foo1
& bar1
& yikes1
\\*\cline{2-4}
& foo1
& bar1
& yikes1
\\*\cline{2-4}
\\\hline
\multirow{4}{*}{row 2}
& foo2
& bar2
& yikes2
\\*\cline{2-4}
& foo2
& bar2
& yikes2
\\*\cline{2-4}
& foo2
& bar2
& yikes2
\\*\cline{2-4}
& foo2
& bar2
& yikes2
\\*\cline{2-4}
\\\hline
\end {supertabular}

\end{document}

But still I'm getting page breaks :-(

This seems to be a supertabular issue. On a first glance at supertabulars code, I couldn't find an obvious reason for this.

After replacing supertabular by longtable everywhere, it works ;-)

share|improve this answer
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.