# Never break a page unless explicitly told so, expand the margins to fit the content, and have mixed margins in the same document

The first part of this question is basically this question: Absolutely, definitely, preventing page break

Partially modified MWE from that answer,

\documentclass{article}
\usepackage{lipsum}
\newenvironment{absolutelynopagebreak}
{\par\nobreak\vfil\penalty0\vfilneg
\vtop\bgroup}
{\par\xdef\tpd{\the\prevdepth}\egroup
\prevdepth=\tpd}
\begin{document}
\lipsum[1]

\begin{absolutelynopagebreak}
\raggedbottom
\lipsum[1-3]\lipsum*[4]\lipsum[1-3]\lipsum*[4]\lipsum[1-3]\lipsum*[4]
\end{absolutelynopagebreak}

HERE WE RESTART \lipsum[2]
\end{document}


Except, this only accomplishes the never break a page part. It never breaks a page indeed, but you still have to calculate the margins manually.

I can extend this page with the margins package, manually. But I have to do it myself. Since latex knows when to break a page, it has to know the needed size for items. I am wondering if there is a way to automate this?

Basically, the case below is what I want to accomplish,

• Have one page with 10 lorem ipsums, this page should take as much space as 10 pages.
• Have the next page with 20 lorem ipsums, this page should take double the space.

This would require mixed margins within the same document as well.

Is this possible, even if only partially so?

I don't mind having to use a different rendering engine if there is a specific feature for this in either xetex or luatex.

• @John Kormylo Seems so. Sadly, now I have another problem. I already use some KOMA features, so I would like to use use the "scrartcl" class. I don't mind losing the margins and all that(I am familiar enough with koma to configure those from stratch), but it seems when I do \documentclass[class=scrartcl,preview,pagesize=off]{standalone}, I can't insert a page break at all. And without the preview part, there are no page breaks, and the text skips horizontally. Do you have any ideas how can I use -some- of the KOMA(even if partially broken) and insert a real page break? – Lacey May 10 at 8:01