Set page variable

Hello!
My boss asked me to make a paged book of acts. Each act should include the number of pages it has (which is stupid because (1) the book is numbered and (2) I have to print each act as pdf and digitally sign it, so it can’t be tampered with).

I am using the “set page variable” and “show page variable” fields, but “show page variable” is empty, even after I update field.
How do I use the “get page variable” field?

Alternatively, is there any way I can put the current page number inside a field, then use a formula to substract current page number from stored page number?

Or is there a way to count all pages in a chapter?
Yours,
José

Similar question Page count just for the current section? and see the discussion about possible solution.

Your case is slightly different.

Insert>More Breaks>Manual Break at the very beginning of every act. In this special break, tick Page break and restart page numbering to 1. This setting can be attached to the paragraph style for the first paragraph of an act, presumably a style dedicated to the act title.

As the last item in every act (right before the final paragraph mark, Insert>Cross-reference as Type Set Reference and give it a unique name (something related to the act title so that it is unambiguous).

Where you need to identify a page (in the header or footer), Insert>Field>Page Number for the page number and, for the page count, Insert>Cross-reference Type * Insert Reference*, Selection the name of the end of act marker, Refer using Page number (unstyled).

I highly recommend your work with View>Formatting Marks and View>Field Shadings both enabled so that you have a visual feedback about the “technical” contents of your document. Also, work with styles which provide formatting automation.

No, I shouldn’t restart page numbering. The number of the page should not change, I just need to insert the count of pages in chapter.

The solution of inserting a SECPAGE=0 field at beginning of the section a d a SECPAGE=SECPAGE+1 on the footer seems good, but… do field updates in footers get applied?

As a matter of fact, I had to insert a CHAPTER=CHAPTER+1 on the beginning of the section because a chapter counter inside a title was not being updated.

Alsi, whats the purpose of set page variable/show page variable if it does not count the number of pages from set page, as the help says it does?

This does not make a lot of sense. E.g. you can have “page 53/2” for page number 53 out of 2.

Presently, a footer or header is “computed” when the page style is first met. Then in every page, the cached footer/header is used except for a few fields which value is dynamically retrieved. A *Set/Show variable" field is not considered in this dynamic computation. I consider it a really troublesome error and submitted tdf#128041 5 years ago.

What do you mean? Chapter numbering works like a charm unless you put your Heading 1 in the header ('where we meet the cache issue – but putting a Heading 1 in a header is a structural error: do you expect the chapter number to change on every page, independent of text?).

There is definitely a bug here. I re-read the description in built-in help and it is close to what you’re looking for. I also submitted feature request tdf#153259 to suggest a different mechanism.

What I need is each chapter looks like this:

Act X of Meeting at…
Blah blah blah
This chapter comprises N pages.

I was using a variable for X (chapter counter inside a chapter title does not work).
For N, I was using “set page variable” at the title and then “show page variable” at the end.

This WAS the expected behaviour of “set page variable”, according to online help: storing a page reference to count the number of pages from it when using a later “show page variable”.

But the REAL behaviour of set page variable is changing the page nunber (I did not detect that when I wrote the previous posts).

So I am just using this:

[set ACTNUMBER=ACTNUMBER+1] " Act X of Meeting at…[Set ACTPAGES=1]
Blah blah blah
This chapter comprises [ACTPAGES] pages.
Footer:[ACTPAGES=ACTPAGES+1] [PageNumber]

Yours,

José Moya.

This can be better done using standard Heading n with numbering enabled in Tools>Heading Numbering. Since your “Act” is a chapter, Heading 1 is a good choice. No need of a variable. If you need the act number in your document, e.g. in header or footer, it is available as a cross-reference.

This won’t work. The footer is computed only once and cached. You’ll end up with ACTPAGES equal to 1 in the first page and to 2 in subsequent pages.

This is presently impossible because you can’t capture the current page number into a variable. The only workaround is what I already suggested: restart page numbering for every act. But if your constraint is to number all pages in sequence without restart, you’re out of luck.

I think you could write a macro to do that but I never did this, focusing on “pure” style-formatted documents. So, hope for another macro-verse contributor to comme by your question.

Heading number is not updated inside a chapter title. At least, the “Sequence” called “chapter number” is not updates. And I guess chapter number is the chapter number sequence.

The variable change in footer was suggested by the first link you posted.

I have filed a bug report about “set page variable”, since the documented behaviour of set page variable is the one I expected and not the one it does:

Set page variable

Inserts a reference point in the >document, after which the page >count restarts. Select “on” to enable the reference point, and >“off” to disable it. You can also >enter an offset to start the page >count at a different number.

Show page variable

Displays the number of pages >from the “Set page variable” >reference point to this field.

So either the docs or the program are wrong.

IMHO, the program is wrong.
What is the bug number?

Seems to be tdf#163312

Yes, it is. Thank you all.