0

I have this issue with longtable and multirow. Any hint to prevent that? I'm not looking for a solution for this specific example. In my real problem, the LaTeX file is an automatic report generated by Sweave, and I cannot predict whether the table will break or not: if it breaks, I don't want this rendering.

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage[table]{xcolor}
\usepackage{multirow}
\begin{document}

a

b

c

d

e

f

g

\rowcolors{2}{white}{gray!6}

\begin{longtable}{>{\bfseries}cccccc}
\caption{\label{tab:Calibration-tableModelFit}Summary of Model Fitting.}\\
\hiderowcolors
\toprule
\vtop{\hbox{\strut }\hbox{\strut group}} & \vtop{\hbox{\strut }\hbox{\strut Day}} & \vtop{\hbox{\strut }\hbox{\strut Operator}} & \vtop{\hbox{\strut $R^2$ Adj}\hbox{\strut (Linear)}} & \vtop{\hbox{\strut $R^2$ Adj}\hbox{\strut (Quadratic)}} & \vtop{\hbox{\strut $p$-value of}\hbox{\strut quadratic term}}\\
\midrule
\endfirsthead
\caption[]{Summary of Model Fitting. \textit{(continued)}}\\
\toprule
\vtop{\hbox{\strut }\hbox{\strut group}} & \vtop{\hbox{\strut }\hbox{\strut Day}} & \vtop{\hbox{\strut }\hbox{\strut Operator}} & \vtop{\hbox{\strut $R^2$ Adj}\hbox{\strut (Linear)}} & \vtop{\hbox{\strut $R^2$ Adj}\hbox{\strut (Quadratic)}} & \vtop{\hbox{\strut $p$-value of}\hbox{\strut quadratic term}}\\
\midrule
\endhead
\showrowcolors
 & 1 & 1 & 0.999 & 0.999 & 0.245\\
\cmidrule{2-6}
 & 1 & 2 & 1.000 & 1.000 & 0.300\\
\cmidrule{2-6}
 & 1 & 3 & 0.999 & 0.999 & 0.641\\
\cmidrule{2-6}
 & 2 & 1 & 1.000 & 1.000 & 0.952\\
\cmidrule{2-6}
 & 2 & 2 & 0.999 & 0.999 & 0.905\\
\cmidrule{2-6}
 & 2 & 3 & 1.000 & 1.000 & 0.157\\
\cmidrule{2-6}
 & 3 & 1 & 1.000 & 1.000 & 0.355\\
\cmidrule{2-6}
 & 3 & 2 & 1.000 & 1.000 & 0.652\\
\cmidrule{2-6}
\multirow{-9}{*}{\centering\arraybackslash Ref sample:sample A cal} & 3 & 3 & 0.999 & 0.999 & 0.373\\
\cmidrule{1-6}
 & 1 & 1 & 1.000 & 1.000 & 0.199\\
\cmidrule{2-6}
 & 1 & 2 & 0.999 & 0.999 & 0.455\\
\cmidrule{2-6}
 & 1 & 3 & 1.000 & 0.999 & 0.727\\
\cmidrule{2-6}
 & 2 & 1 & 1.000 & 1.000 & 0.742\\
\cmidrule{2-6}
 & 2 & 2 & 1.000 & 1.000 & 0.450\\
\cmidrule{2-6}
 & 2 & 3 & 0.999 & 0.999 & 0.367\\
\cmidrule{2-6}
 & 3 & 1 & 0.999 & 0.999 & 0.567\\
\cmidrule{2-6}
 & 3 & 2 & 1.000 & 1.000 & 0.077\\
\cmidrule{2-6}
\multirow{-9}{*}{\centering\arraybackslash Ref sample:sample B cal} & 3 & 3 & 0.999 & 1.000 & 0.055\\
\cmidrule{1-6}
 & 1 & 1 & 1.000 & 1.000 & 0.581\\
\cmidrule{2-6}
 & 1 & 2 & 1.000 & 1.000 & 0.386\\
\cmidrule{2-6}
 & 1 & 3 & 1.000 & 1.000 & 0.685\\
\cmidrule{2-6}
 & 2 & 1 & 0.999 & 0.999 & 0.537\\
\cmidrule{2-6}
 & 2 & 2 & 0.999 & 0.999 & 0.687\\
\cmidrule{2-6}
 & 2 & 3 & 0.999 & 0.999 & 0.805\\
\cmidrule{2-6}
 & 3 & 1 & 0.999 & 1.000 & 0.025\\
\cmidrule{2-6}
 & 3 & 2 & 1.000 & 1.000 & 0.789\\
\cmidrule{2-6}
\multirow{-9}{*}{\centering\arraybackslash Ref sample:sample C cal} & 3 & 3 & 0.999 & 0.999 & 0.423\\*\bottomrule
\end{longtable}
\rowcolors{2}{white}{white}

\end{document}
9
  • i suggest you not use of \cmidrule in table. table will become more compact and readable and also your problem will disappear.
    – Zarko
    Aug 25, 2017 at 19:00
  • @Zarko Thanks. I agree the table is nice if I remove the \cmidrule{2-6}'s, but I prefer to keep the \cmidrule{1-6}'s. Aug 25, 2017 at 19:18
  • as you wish :), but then i'm afraid your problem is not solvable :(
    – Zarko
    Aug 25, 2017 at 19:32
  • just put a \pagebreak before the \multirow. Unrelated but why \vtop{\hbox{\strut }\hbox{\strut group}} which is far from being standard latex syntax? Aug 25, 2017 at 20:46
  • @DavidCarlisle A pagebreak breaks the table, I don't see what you mean. \vtop{\hbox{\strut }\hbox{\strut group}} to print "group" at the bottom. Aug 25, 2017 at 20:50

1 Answer 1

1

A possible solution is to remove the \cmidrule{2-6}'s and to add a * just after the previous \\:

 & 1 & 1 & 0.999 & 0.999 & 0.245\\*
%\cmidrule{2-6}
 & 1 & 2 & 1.000 & 1.000 & 0.300\\*
%\cmidrule{2-6}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .