TransWikia.com

Theorem box extending over footnote causing page split

TeX - LaTeX Asked by Isaac van Bakel on May 3, 2021

I have a document where I’m using amsthm and thmtools (particularly thmbox) for formatting some definitions. The document also contains some footnotes, which are reasonably-sized (i.e. not more than ~1/4th of the page).

The problem

If a definition stretches over a page, it overflows onto the next, which is not a problem. However, if the definition stretches “over” a footnote (i.e. it goes over a pagebreak where the page ends in with a footnote), there’s a weird rendering issue where the start of the definition gets pushed onto its own, otherwise empty, page.

Example

documentclass{report}


usepackage{amsthm}
usepackage{thmtools}

declaretheorem[thmbox=M, style=definition, name=Definition]{defn}

begin{document}

Long paragraph pushing the definition over the page.
footnotemark


footnotetext{This long footnote means that the beginning of the definition cannot stay on page 1. (BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH )}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}


begin{defn}
    Long definition spanning across two pages
    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}

    begin{center}
    begin{tabular}{c}
        a 
        b 
        c 
        d 
    end{tabular}
    end{center}
end{defn}

end{document}

forces the start of Definition 1 onto a new page. This doesn’t happen if thmbox is not set.

An example of a bad definition rendering due to a footnote.

What’s going on?

It looks almost like amsthm is laying out the definition correctly, then the footnote comes in and, not having enough space to be rendered, shuffles over the end bit of the page. The only issue is that the definition on the next page (and the rest of the document) are not shuffled along to compensate. Instead, the problematic part of the definition is just placed on a new page, to give it the necessary space.

One Answer

The problem is reproducible with thmbox package alone, see the following example.

documentclass{article}
usepackage{lipsum}
usepackage{thmbox}

begin{document}
Long paragraph pushing the definition over the page.footnote{lipsum[23]}

lipsum[1-3]

begin{thmbox}[M]{bfseries Definition}
    lipsum[1-2]
end{thmbox}
end{document}

enter image description here

Compared to the page-breaking algorithm used by tcolorbox package (more specifically, its source file tcbbreakable.code.tex, the definition of macro tcb@comp@h@page), I find replacing vsize with pagegoal in definition of thmbox@start solves the problem.

documentclass{article}
usepackage{lipsum}
usepackage{amsthm}
usepackage{thmtools}
declaretheorem[thmbox=M, style=definition, name=Definition]{defn}

usepackage{regexpatch}

makeatletter
% replace all vsize by pagegoal in definition of thmbox@start
xpatchcmd*thmbox@start
  {vsize}
  {pagegoal}
  {}{fail}
makeatother

begin{document}
Long paragraph pushing the definition over the page.footnote{lipsum[23]}

lipsum[1-3]

begin{defn}
    lipsum[1-2]
end{defn}
end{document}

enter image description here

Correct answer by muzimuzhi Z on May 3, 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