0

For this MWE, the table caption and header are printed without any rows from the table body.So, how can I make sure that the table breaks if at least one row is printed?

\documentclass{article}
\usepackage{xtab,booktabs,multirow,lipsum,showframe}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}

\lipsum[1-3]
newline\\
newline\\
newline\\
newline\\
newline\\

\begin{center}
\tablecaption{this is table caption}
\tablefirsthead{\toprule First&\multicolumn{1}{c}{Name} \\ \midrule}
%
\tablehead{%
\multicolumn{2}{c}%
{{\bfseries  Continued from previous column}} \\
\toprule
First&\multicolumn{1}{c}{Name}\\ \midrule}
%
\tabletail{\\ \midrule}
\tablelasttail{%
\\\midrule
\multicolumn{2}{r}{{Concluded}} \\ \bottomrule}
\begin{xtabular}{ll}
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text comes\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text comes here too \\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text
\end{xtabular}%
\end{center}
\end{document}

enter image description here

Diaa
  • 9,599
  • you could use the needspace package and put something like \needspace{5\baselineskip} before the table – David Carlisle Jan 23 '18 at 21:07
  • @DavidCarlisle So do you mean that there is no general fix to this problem? – Diaa Jan 23 '18 at 21:09
  • isn't that a general fix? – David Carlisle Jan 23 '18 at 21:10
  • @DavidCarlisle I loaded needspace and wrote \needspace{5\baselineskip} just before the table and the result is the same when I deleted some dummy line breaks before the table. – Diaa Jan 23 '18 at 21:13
  • the amount was just a guess looking at the imge: \Needspace{15\baselineskip}\begin{center} works – David Carlisle Jan 23 '18 at 21:18
  • @DavidCarlisle I am afraid I don't understand something. When I put that line before the table, it moved to the next page leaving large white space at the end of the previous page. Is it possible to make this environment float in order to make the trailing text fill this space? Please take a look at the output of this MWE to know what I mean. – Diaa Jan 23 '18 at 21:29
  • 2
    In general that is the only thing you can do if there is not space on the page, floating a multi-page construct is tricky, although you could put the whole thing in \afterpage there are probably examples on this site – David Carlisle Jan 23 '18 at 21:33

0 Answers0