Writer: will I ever be able to define conditions using internal variables?

Will it ever be possible to define conditions using internal variables (page, section numbers,…)?
e.g. Page == Pages for conditional text in last page footer.

Hi

+1 with @jimk & @mikekaganski

However, it is at least possible:

  • To display text on all but the last page. A common example is to display PTO (please turn over). For this just insert a field ▸Document tab▸Type: Page▸Select: Next page▸Format: Text▸Value: type your text. See TextExceptOnLastPage.odt
  • To display footer only if the document has more than 1 page. For this insert Hidden Paragraph field with condition page==1 . See ConditionalFooter.odt (add one or more pages to see the footer).

HTH - Regards

The Next_page text trick is just what I needed.
A good succinct explanation plus an example document too - very much appreciated. Thanks.

Instead of fields, create a different page style for the last page. Then enter whatever is needed in the footer.

Headers and footers are the same across all pages with that style. So a condition like currentpage == page is not possible in the footer. Note that page confusingly refers to the total number of pages.

Furthermore, as you apparently know, there is no such variablecurrentpage. According to https://help.libreoffice.org/Writer/Defining_Conditions:

You cannot use internal variables, such as page and chapter numbers, in condition expression.

To me, this seems unlikely to change and would require a great deal of effort to implement. However, you could file an enhancement request and see if anyone is willing to tackle it.

A workaround to determine in the text body whether it is the last page is to increment a variable on each page. I do not see how this would be useful, but here is a sample file: Last Page condition.odt

Although you are correct that currently it’s impossible, the reasoning behind that (“Headers and footers are the same across all pages with that style. So … not possible in the footer”) is not strictly valid, because if it were, we couldn’t have page numbers or chapter titles in headers/footers. Dynamic fields could use dynamically changing stuff in headers; so in theory, it’s not impossible.

Thanks. Yes, this was the approach I’d tried before posting the question. It works fine provided you don’t have paragraph/table content spanning between the last 2 pages, as this method requires a section break to change page_style.

You can do quite a lot already. See, for example, @JimK’s useful sample for a conditional counter in an earlier Q&A

See also the help information on "Defining Conditions " and “Variables”, and the internal links in those pages. It might well be possible to accomplish your scenario, though I haven’t attempted that one myself.