3

One of the Amazon -- KDP requirements for print books is that the inner margins be determined by the page count of the book, so that larger books have more gutter -- more specifically, according to the formula:

Page Count Inside (Gutter) Margins
24 to 150 pages 0.375” (9.6 mm)
151 to 300 pages 0.5” (12.7 mm)
301 to 500 pages 0.625” (15.9 mm)
501 to 700 pages 0.75” (19.1 mm)
701 to 828 pages 0.875” (22.3 mm)

as seen here.

How can one start out with the geometry package and set the inside margins according to the page count?

Paulo Ney
  • 2,405
  • Their wording is a bit odd—they specify "at least" on the outside margins but not the inside margin, but I would argue that it applies to inside margins as well and those would be minimum margins and not an absolute standard margin. – Don Hosek Jan 23 '21 at 03:08
  • If you're automating the setting, it will take a minimum of two passes—the second to reset the margins after getting a page count—but that will likely cause other page-dependent settings to change (e.g., page references, table of contents and indexing). Far better to just set it to a value based on the estimate of the page count and adjust it if after writing/editing the estimate is wrong. – Don Hosek Jan 23 '21 at 03:11
  • @DonHosek, on thousands of books that may be a bit hard... – Paulo Ney Jan 23 '21 at 04:26

1 Answers1

3

The following setup provides you with a dynamic way of setting the inner dimension based on the number of pages within your document. It uses the latest (Oct 2020) LaTeX kernel that defines \@abspage@last to capture the total number of pages within your document within the .aux. As an alternative one can also use the lastpage package to achieve the same goal. Since it uses the .aux for page totals, it does require at least two compilations for things to settle (if you run over the page boundary breakpoints).

\documentclass{article}

\usepackage{lipsum}

\usepackage{geometry}

\makeatletter \AtBeginDocument{ \providecommand{@abspage@last}{1}% Ensure @abspage@last is defined \begingroup\edef\x{\endgroup \noexpand\newgeometry{ inner=\ifnum@abspage@last<151 0.375in \else\ifnum@abspage@last<301 0.5in \else\ifnum@abspage@last<501 0.625in \else\ifnum@abspage@last<701 0.75in \else 0.875in \fi\fi\fi\fi }}\x } \makeatother

\begin{document}

\sloppy \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 40 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 79 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 119 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 162 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 202 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 242 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 283 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 328 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 369 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 410 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 451 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 492 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 538 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 579 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 621 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 662 pages \lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]% 719 pages

\end{document}

In principle the you set the inner geometry using \newgeometry at the beginning of the document.

Werner
  • 603,163