TransWikia.com

Why does supertabular put the page break early in all kinds of situations?

TeX - LaTeX Asked on March 10, 2021

In this MWE, supertabular breaks the page (or column, if one is using twocolumn) early. In fact, the first page holds only 5 lines, while the second holds 7.

documentclass[twocolumn]{article}
usepackage[paperheight=2in]{geometry}
usepackage{supertabular}
begin{document}
begin{supertabular}{p{3mm}}
    1 2(  3 4(  5
    1 2 3 4 5 6 7
end{supertabular}
end{document}

enter image description here

I thought his may have something to do with the presence of the parentheses, but I can reproduce a less severe issue (6 lines vs. 7) without them as well:

documentclass[twocolumn]{article}
usepackage[paperheight=2in]{geometry}
usepackage{supertabular}
begin{document}
begin{supertabular}{p{1.7mm}}
    1   2 3   4 5   6
    1 2 3 4 5 6 7
end{supertabular}
end{document}

enter image description here

In my document, I can even reproduce the issue without any parentheses or line breaks in cells. That is a bit harder to reproduce as an MWE, however.

I have tried the approach described in Prevent xtab breaking table too soon and Prevent supertabular* from breaking too early without success.

Edit: Here’s another example not involving line breaks in cells, but a line break in the tablehead:

documentclass[twocolumn]{article}
usepackage{lipsum}
usepackage{supertabular}
defheads{Head Head Head Head Head Head }
edefmycont{headsheadsheadsheadsheadsheadsheads}
tablehead{multicolumn{1}{p{dimexpr columnwidth - 12pt}}{mycont}}
begin{document}
lipsum[1-2]

begin{supertabular}{p{1cm}}
    123456789
    123456789
    123456789
    123456789
end{supertabular}
end{document}

enter image description here

Here’s one using tablefirsthead (in this case, it seems the second column is long, rather than the first too short – but they should have the same length anywy, and I don’t get a box warning, either):

documentclass[twocolumn]{article}
usepackage{supertabular}
tablefirsthead{}
tablehead{Continued}
begin{document}
begin{supertabular}{p{1cm}}
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
end{supertabular}
end{document}

enter image description here

And here’s one using tablecaption:

documentclass[twocolumn]{article}
usepackage{supertabular}
tablecaption{Caption}
begin{document}
begin{supertabular}{p{1cm}}
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
end{supertabular}
end{document}

enter image description here

Edit 2:
I also found Too large bottom margin with xtab (or supertabular) and Long tables (spanning multiple pages), put side by side and tried their solutions.

I need twocolumn, so longtable won’t work; and the best solution for the first link is even worse:

documentclass[twocolumn]{article}
usepackage{lipsum}
usepackage{xtab}
usepackage[nofoot]{geometry}
tablefirsthead{}
tablehead{H}
begin{document}
begin{xtabular}{p{1cm}}
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
end{xtabular}
end{document}

enter image description here

I think my summary question is: is this fixable at all, or should I refrain from using supertabular/xtab if I want my tables to break correctly?

One Answer

I got slightly better results by removing the wrong heuristic used by supertabular that adds 1pt for every line.

Of course this is not a magic wand that will work in every case.

documentclass[twocolumn]{article}
usepackage{lipsum}
usepackage{supertabular}
usepackage{showframe}

% https://www.guitex.org/home/forum/5-tex-e-latex/26889-supertabular-e-twocolumn-riempimento-parziale-altezza-testo?lang=it#26893
makeatletter
defmod@estimate@lineht{% 
  ST@lineht=arraystretch baslineskp
  %globaladvanceST@lineht by 1p@ 
  ST@stretchhtST@linehtadvanceST@stretchht-baslineskp
  ifdimST@stretchht<z@ST@stretchhtz@fi
  ST@tracetw@{Average line height: theST@lineht}% 
  ST@tracetw@{Stretched line height: theST@stretchht}% 
}
newenvironment{strictsupertabular}
  {letestimate@linehtmod@estimate@linehtsupertabular}
  {endsupertabular}
makeatother

begin{document}

tablefirsthead{}
tablehead{H}
begin{strictsupertabular}{p{1cm}}
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
    123456789
end{strictsupertabular}
end{document}

Answered by egreg on March 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP