Forum Bugs

Interaction between footnotes, body height, page boxes, and some margins

jyasskin
When I generate a PDF from the attached file, the footnote gets pushed down below the first page, nothing but the footnote appears on the second page, and the rest of the document appears on the third page.

If I apply either of the following two diffs, the footnotes still gets pushed down below the first page, but it appears on the second page with the rest of the document content:

diff --git a/prince_bug.html b/prince_bug.html
index 546b414..ee7b279 100644
--- a/prince_bug.html
+++ b/prince_bug.html
@@ -2,7 +2,7 @@
 <!-- Sources at https://github.com/cplusplus/fundamentals-ts -->
 <html><head>
 <style>
-section header { margin-top: 20px; }
+section header { margin-top: 0px; }
 </style>
   <meta charset="utf-8">
 <style>

diff --git a/prince_bug.html b/prince_bug.html
index 546b414..252ad22 100644
--- a/prince_bug.html
+++ b/prince_bug.html
@@ -7,7 +7,7 @@ section header { margin-top: 20px; }
   <meta charset="utf-8">
 <style>
 @page {
-    @top-left { content: ""; }
+    @top-left { }
 }
 
 html, body {height: 100%}


If I apply this third diff, the footnote appears on the first page, where I want it to:

diff --git a/prince_bug.html b/prince_bug.html
index 546b414..bb7cd58 100644
--- a/prince_bug.html
+++ b/prince_bug.html
@@ -10,8 +10,6 @@ section header { margin-top: 20px; }
     @top-left { content: ""; }
 }
 
-html, body {height: 100%}
-
 aside { float: footnote; footnote-policy: line; }
 </style><title>C++ Extensions for Library Fundamentals, Working Draft</title></head>
 <body>


(The "height:100%" is the only way I've found to produce a page-sized title page that works on screen media (http://cplusplus.github.io/fundamentals-ts/main.html), but I can hack around it on print by fixing the size of the output page.)
  1. prince_bug.html3.9 kB
mikeday
Right, definitely don't apply "height: 100%" in paged media, it doesn't help. :)

You can always force a page break after the title page using "page-break-after: always" instead of changing the height of the element.
jyasskin
It's much less about forcing a page break than about centering the title vertically and putting another element close to the bottom of the page. The 'vh' CSS unit would work well for that positioning, but my brief attempt to use it didn't work, so I assumed Prince doesn't support it. Is there some other way to specify that an element is sized or positioned as a fraction of the non-margin space?

It would be nice to have the CSS work just as well for A4 as 8.5x11 paper, which becomes less true if I set the height of the title page to an absolute value.
mikeday
Ah, vertical centering, the age old nemesis of CSS layout. :)

You could use page floats ("float: bottom") to put an element at the bottom of the page, regardless of the size of the page. All I can suggest for the title is to make the element a reasonable size and center it within that, or just use top margin/padding to align it relative to the top of the page, rather than centering per se.

Currently Prince doesn't support 'vh' units, and percentages are relative to width, and different paper sizes have different aspect ratios, so that doesn't help.
jyasskin
Hence using `height:100%`, which lets me position things vertically on the first page without depending on the page size. However, I do have the workaround, so it's not the end of the world. Thanks for the pointers.