Separate page count for each style?

My document has several styles with headers. I would like to have my headers in the following form:

Text X of Y

where X is the page number for the corresponding style and Y is the page count for that style so that my
headers would look something like this:

Chapter 1 page 1 of 10
Chapter 2 page 4 of 23
etc.

I can manage changing the page numbers for each style but I don’t know how to count all the pages of a certain style only rather than the whole document. Can you help?

Problem solved with a workaround:

  1. Make a bookmark on the last line of a style: Insert > Bookmark
  2. Name it like “LastPageSTYLENAME” where STYLENAME is the name of the corresponding style.
  3. Make a cross-reference to it where you want the “page count for style field” to be: Insert > Cross-reference
  4. Select type “Bookmark”, select the bookmark you made, select “Page” for the “Insert reference to” option and click insert.
1 Like

Well done. Good lateral thinking. I completely forgot about bookmarks and cross-references.

This workaround works pretty well but is sensitive to the bookmark being accidentally deleted, especially in a multi-user environment.

This feature would be particularly useful for documents with a header section (cover, table of contents etc) but where the main text is to be formatted with “page n of x”, which is a structure we use at work for our reports.

I see the bug/feature request is still outstanding.

By what I could test, this method gives a running total at each bookmark.
In the original post sample, chapter 2 has 13 pages, so 10+13=23.

But, what if I need to count chapter 2 pages?

There is currently no field available to obtain a page count for a part / chapter / section within a document as this is not supported by the ODF v1.2 specification. Instead <text:page-count> (7.5.18.2) relates to the document as a whole:

The <text:page-count> element displays the value of the meta:page-count attribute of the <meta:document-statistic> element of a document. 19.332

It is probably possible to write a macro to calculate a required page count, but you will need to write the macro.

Question1:

Is there a workaround for this other than writing a macro? I read something about adding a bookmark somewhere and a cross-reference to it. Would it work?

Question 2:

How can I make a feature request for the LibreOffice developers to include a “Page count for style” feature in the future?

You answered Q1. For Q2, there is currently no open or closed bug for an enhancement request relating to page+count. Please file an enhancement bug and provide as much information about this new feature as possible. Include a link to this thread if necessary. Don’t forget to mark your bug as an ‘enhancement’. The QA team will be happy to help you triage your feature request in the bugtracker. Please post a link to any bugs you file in a comment below using the format “fdo#123456”.

Reported as Bug 71583.

Thanks. I have confirmed the bug report.

Awesome. Let’s hope the feature gets implemented.

If you make different sections, and each section having a different stylem you should be able to page count by section and therefore by style?

I tried but it does not work. I get the total page count when I insert a page count field in one of my sections with a specific style which has only a few pages. I’m running LibreOffice 3.5.7.2. Could that be the reason why it does not work?