0

I am using the mathpartir package to display some inference rules. I defined my own LaTeX command based on the samepage environment to add some explanation below a rule where there should be no page break between the rule and the explanation. However, I would like to have automatic page breaks between such groups of rules and explanations. This does not work yet. I looked for keywords such as "automatic pagebreaks several samepage environments" (and various combinations and modifications thereof), but did not find a solution.

Here is my MNWE that produces an empty page and an overfull page, but should produce two or more pages where as many rule/explanation groups as fit are displayed on the first page and the remaining ones on the next page(s):

\documentclass{book}

\usepackage{mathpartir}

\newcommand{\myrule}[4]{\begin{samepage}\begin{mathpar}\inferrule*[right=(\textsc{#1})]{#2}{#3}\end{mathpar}\begin{center}#4\end{center}\end{samepage}}

\begin{document}

\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}

\end{document}

I played around with some simple modifications that did not work: Just adding empty lines between the \myrule commands does not change anything. Appending \\ to the end of the command does not work as it is not allowed there. Appending \par instead does not change anything (that was to be expected after the test with empty lines). Appending \leavevmode\newline or \leavevmode\\ to each command only produces an additional empty page after the overfull one.

1 Answer 1

1

just add a legal breakpoint at the end, I used \goodbreak here:

As book uses flushbottom, the terms spread out vertically to fill the space, if you want the space at the bottom, use \raggedbottom

\documentclass{book}

\usepackage{mathpartir}

\newcommand{\myrule}[4]{\begin{samepage}\begin{mathpar}%
\inferrule*[right=(\textsc{#1})]{#2}{#3}\end{mathpar}%
\begin{center}#4\end{center}\end{samepage}%
\par\goodbreak}

\begin{document}

\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}
\myrule{name}{premise}{conclusion}{explanation}

\end{document}

You must log in to answer this question.

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