1

Google Docs is getting the page numbering wrong in the index, but only some of the time.

These screenshots are from a doc that demonstrates the issue. They show 3 pages in a document, each with its own page number in the top right. The first page contains a Title and Table of Contents. The other two pages each contain a Header 1 and some unformatted lorem ipsum.

First page, showing page number, Title and Table of Contents Second page, showing header and paragraph of nonsense Third page, showing header and paragraph of nonsense

Notice the problem? Yup, the ToC thinks page 2 is on page 1! (And yes, I updated the ToC just before taking the screenshot, so that's not the problem.

What's happening here?!

1

1 Answer 1

3

It turns out I'm not the only one to discover this problem…

Search results showing multiple Google Help forum posts over the years with only workarounds offered…all locked, or else I'd have posted the solution there, rather than here on SuperUser.

…but none of those old, locked posts has a proper solution offered, only workarounds.

We'll get to the solution in a moment, but, for anyone who likes to solve little puzzles, let me first share a few screenshots that illustrate the problem and solution graphically:

The Problem

Page 1, this time with non-printing characters displayed. There are paragraph markers to the right of the page number, the title, the 2 page numbers in the table of contents, and at the bottom-left of the page, as well as just above the table of contents. There is a page break just below the table of contents. Page 2, again with non-printing characters shown. Paragraph markers right of the page number, header, text block, a page break which is just below the text block, and at the bottom-left of the page Page 3, with non-printing characters. Paragraph markers in all the same spots as Page 2, though, being the last page, this one doens't have a page break.

The Solution Page 1, identical except for a paragraph marker after the page break, and this time the pages in the table of contents are both labelled correctly

Spot the difference? Adding a paragraph after the page break fixes it! Why?

I believe this demonstrates a subtle rendering bug in Google Docs. Note how the added paragraph marker, despite being to the right of the page break (and, therefore, theoretically existing on the next page (page 2) that new marker appears on page 1, stuck to the page break.

Why? Why? Why?

In case some relevant Google employee happens on this post, here's a hunch that might put you on the fast track to finding and eliminating this bug! 😎

Guessing it's something to do with the way Paragraph markers carry formatting information for content to their left, while Page Breaks affect content to their right. This bug exists in that liminal space between. By having business logic that uses both left-of and right-of reasoning, different components can end up with subtly different interpretations. The renderer clearly interprets the header as being on page 2, as required by the page break, while the Table of Contents seems to think that all content before the first paragraph marker exists on the previous page, page 1. Inserting the content-less paragraph keeps the print renderer happy, since the empty marker doesn't print, and allows the ToC's rule to suddenly work as expected.

2
  • You are allowed to tick your own answer Commented Apr 23 at 13:45
  • The image under "The Solution" seems to be a repeat of the first image (a Google search result), rather than a screenshot of the Google doc itself? Commented May 2 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.