If everyone reads a PDF document on screen, and no one actually prints it out, we don't need to break text every 11 inches (or 297 mm) to fit the text into a physical paper. It often creates awkward widow/orphan lines.

So I'm using very long-length paper size to minimize the occurrence of page breaks. But I also thought: If no one prints the document, there is no need to make every page the same size. A reasonable alternative would be to use variable page length so that one page fits exactly the length of one section. This way, there would be no more extra-long white spaces, and readers can use 'next page' command in their PDF reader application to easily jump to next section.

I can do this easily with package Preview with tightpage option, but it doesn't work with marginpar. If there is a marginpar, TeX spits out "Float(s) lost" error.

Package Standalone also does this, but it loads package Preview with tightpage option internally to do this, so it's no different. Marginpar still doesn't work.

I also had a look on this answer (Varying Page Lengths). This works perfectly with marginpar, But the code is (presumably) for PDFTeX only. It doesn't work with LuaLaTeX. Maybe I can modify the code a little to make it work with Lua, but I don't know how.

Minimally non-working example with Preview package:


Some text to test.\marginpar{Some text in marginpar}
  • With the preview package you also need the luatex85 package. – Henri Menke Dec 31 '17 at 4:25
  • Thanks for reply. But adding \usepackage{luatex85} to the MWE above didn't change anything. – luatexuser Dec 31 '17 at 4:37
  • Use \RequirePackage{luatex85} before \documentclass in Boris' answer. Your example won't typeset regardless (also with pdflatex) as the preview package cannot do marginpar. – Henri Menke Dec 31 '17 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.