'Page count' field for a letter with inserted envelope(s)

I want to have page n of m in the bottom margin of each page of a multi page business letter with one or more inserted envelopes.

But the problem is that the page count is incorrect and includes both letter pages and envelopes.

For example: for a 2 page letter, with 2 envelopes at the top, the pages field is 4, but it should be 2.

In other words m should only count letter pages and not also inserted envelopes.

I’m already using

  • Insert | Envelope at the top of the letter (4 times for my 4 envelopes), and then
  • Insert | Field | Page count in the letter’s footer, and
  • Format | Paragraph | Text Flow | Breaks | Page number | 1 to make the first page of the letter have page # 1.

BTW: Page Numbers - LibreOffice Help tells how to set n.

How do I correctly set m?

I have found this link and am studding it: Libreoffice Writer: restart page numbering and include total pages - Super User

I strongly advise against the trick given in the link. The use of a formula for a page number is a test for existence of a page at ±offset from the current page. If the page exists, the number is returned, other formula result is void. This feature is offered to insert texts like “continued on next page”/blank or “see previous page”/blank.

In your case, it may work if you are “sufficiently far away” from the document ends. But be prepared for void results because the offset references an nonexistent page (beyond the last one or before the first one).

One can’t do this. Here’s the bug report.

@ajlittoz, Not interested in introducing a problem to fix a problem. Thanks anyway.

Short answer: you can’t with field Page Count, which counts all pages allocated by Writer, no matter how they are “decorated” or otherwise numbered. Your envelopes are pages and included in total page count. Full stop.

Workaround

Since Page Count cannot be used, you must reference another “field”.

At the very last position of your letter part, Insert>Bookmark and give it LetterLast name (or any other mnemotechnic for you). Where you used Page Count, replace with Insert>Cross-reference, type Bookmarks, selection LetterLast, insert reference to Page (or whatever you need).

Now, you can insert your envelopes before or after your “letter”, it won’t make any difference. However, don’t forget to “refresh” the value from time to time with Tools>Update>Update all.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

Thanks, however as was pointed out in a comment here while this approach might work, it is susceptible to accidentally deleting the bookmark.

Yes, that’s the risk, but there’s no free meal. To mitigate it, you may add a warning comment. Comment do not print unless you ask for that. So that’s pretty innocuous.