Page variable stops part way through document

I have a text document created in LibreOffice Writer which is part of a larger historical document. I want to show the overall page number in the header. I did this last year using the page variable, and it worked well. This year I find it works for a few pages, then stops. On the next page I see the gray background for the variable, but no value.

I am using LibreOffice Version: 6.0.7.3.0+ on Fedora Linux 28. the LibreOffice build is from the Fedora Project.

Thank you ajlittoz for your response.

The document is 66 pages, all use Default Style. My first draft had a custom style for two pages, changing that to Default did not affect this.

View > Field Names showed me where the problem was. I had the Page Variable inserted in the body of a page, the Page Variable did not display in the header after that. Removing the “Set page variable” and “Show page variable” in the page body cleared the problem.

My problem is resolved.

Thank you for the caution about variables.

Page Number would have worked, it would display on all pages, but this document is a logical continuation of a larger document. My first page is number 2256.

A year ago I searched for a solution and found a description of using Page Variable.

I agree that your answer describes a simpler way of solving this.

I appreciate your patience and clear explanation. This has certainly helped me. Thank you.

How’s your document structured? Only one page style or several? In the latter case, did you inadvertently inserted the wrong field variable? You can check with View>Field Names. Is there a break (manual or style-induced) before the location where it stops working?

Provide answers through editing your question, not using an answer.

I have the same configuration. If your document is not confidential, attach it so that I can have a look. Otherwise, try to “lorem ipsum” it , reducing it to the minimum still exhibiting the problem.

Using Variables>Set page variable or Show page variable is not the right way to go. Either Insert>Field>Page number or Insert>Field>More Fields then Document>Page>Page numbers but not Variables>… The “variables” are intended to set operational context or define counters and they require an extensive setup before being used. Unless you’re an expert, keep away from them as long as there are simpler ways to do things.

If I understand right your intent, you want to start your document at page # 2256.

When you want to force a page number to a specific value, you do this with a page break. In some circumstances, you can use a carefully crafted paragraph style, e.g. to restart numbering at 1 for TOC or indexes (those parts begin with a unique title which can be identified by a dedicated paragraph style). In your case, a manual page break will do.

  • Put the cursor at the start of the paragraph which is the beginning of the page with the forced page number.
  • Insert>Manual Page Break (not >Page Break)
  • Page break is already preset
  • Select the page style to switch to (according to your description, Default is the right choice)
  • You can now check Change page number and set 2256

EDIT 2020-02-24

To start a document at an arbitrary page number without inserting unneeded blank pages, do the following:

  • Put the cursor in the very first paragraph
  • Format>Paragraph, go to Text Flow tab
  • In the Breaks section, check the Insert box (Page Before are preselected) and the With page style* box; do not change the suggested page style (it is set to the current one, which is what you want); enter the desired Page number.

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!

@ajlittoz: but you can’t check [x] With page style, and have page style blank! The list of the drop-down does not contain an empty entry, and the combo-box is select-only. Where is this method described in help please?

See also my tdf#114085

@mikekaganski: I checked on a computer with an older LO version. It is empty initially, but you’re right, it takes the current style as soon as you click. I update my answer.

The recipe is in “page numbers; inserting/defining/formatting”, paragraph “To Start With a Defined Page Number”

I fully back your tdf.

This is a very annoying bug of Libreoffice which is still not addressed and ignored here again.

The problem with the proposed solution of ajittoz is, that this DOES NOT work if you want to start a document with a different page! Which is actually a typical application of this: you have a document with different pages and have to set - since many of the automated formating does not work - the first page number yourself. Now with above solution, you only create a blank page and then on the second page get the right page number - but this does not solve your problem.

The second possible solution for this is the offset value in the page field variable. Here is bug #2 of Libreoffice - known for many years already: if your page+offset is larger than the number of pages of your document, NO PAGE NUMBER is shown. Just vanishes. Somehow Libreoffice checks if the shown page is larger than the number of pages and does not show anything. Uuups! Hard to understand why this is, but can be reproduced. Has nothing to do with paragraph formats etc.

So none of above does help. Both needs to be adressed.

Edit: uploaded file to show both problems: 1st empty page to start the document with page #2, then the vanishing page number for page >8. page_numbers_vanish_with_offset2.odt.

Interestingly, if you insert the page break to start the page numbering after the initial annoyingly empty page, and add an offset, then then above bug dios not show and I see page numbers up to 14…: page_numbers_do_not_vanish_with_offset_after_pagebreak.odt

This is a very annoying bug of Libreoffice which is still not addressed and ignored here again.

The problem with the proposed solution of ajittoz is, that this DOES NOT work if you want to start a document with a different page! Which is actually a typical application of this: you have a document with different pages and have to set - since many of the automated formating does not work - the first page number yourself. Now with above solution, you only create a blank page and then on the second page get the right page number - but this does not solve your problem.

The second possible solution for this is the offset value in the page field variable. Here is bug #2 of Libreoffice - known for many years already: if your page+offset is larger than the number of pages of your document, NO PAGE NUMBER is shown. Just vanishes. Somehow Libreoffice checks if the shown page is larger than the number of pages and does not show anything. Uuups! Hard to understand why this is, but can be reproduced. Has nothing to do with paragraph formats etc.

So none of above does help. Both needs to be adressed.

Edit: uploaded file to show both problems: 1st empty page to start the document with page #2, then the vanishing page number for page >8. page_numbers_vanish_with_offset2.odt.

Interestingly, if you insert the page break to start the page numbering after the initial annoyingly empty page, and add an offset, then then above bug dios not show and I see page numbers up to 14…: page_numbers_do_not_vanish_with_offset_after_pagebreak.odt

but this does not solve your problem

How? What @ajlittoz offered is just that - starting a document with a different page. And that is the correct way to do that; using page variable or offset is incorrect way, and there’s no bug discussed here, only improper use of the tool.

But then you end up with an initial empty page - annoying if you want to later ligate PDFs into one document. I have uploaded also a document to show the vanishing page number problem - after page 8 no page number is visible if you use the offset field in the page number. Easy to reproduce bug. Sorry, I do not know how to attach a file, so please download from the German science network here: https://gigamove.rz.rwth-aachen.de/d/id/9NppFB8YruTHoH

Best,
Dieter.

  1. The initial page is there for duplex printing, where even pages are the left ones, and odd are the right ones. In that case, you wouldn’t want the part of the document (the one that you decided to start on even page) to break your overall page layout. But you are free to avoid any automatically inserted blank pages - just uncheck corresponding [ ] Export automatically inserted blank pages in PDF dialog (or in print dialog, if you need).
  2. Offset also works correctly when you attempt to show a number of page absent in the document. Yes, the offset is not just a means of “show arbitrary page number”; it’s a kind of reference to an actual page that is offset by N pages from current. If there’s no such page, nothing is displayed, and that is not a bug.
  1. Again - since you have headers etc - these are typically not empty pages, so this workaround for the PDF export does not work.
  2. I would say that this is a bug since I just want to have higher page numbers to show - even if of course they do not exist! It is my business to define the page numbers I want to have. Sure - in the past we just added blank pages such that these pages existed and then truncated the PDF export to the last written page - the only actual possible workaround for the situation. So you have to memorize for each document the “real” page number in the PDF export… I had to do this for a multipage proposel for the german science foundation…
  1. Again - since you have headers etc - these are typically not empty pages, so this workaround for the PDF export does not work.

Did you actually try? It just works, with headers and footers.

I would say that this is a bug since I just want …

It works as designed. If someone wants to abuse the tool, it’s not a tool’s fault.

Yes, just tried with above test document and due to the headers, it is in the PDF. [Also in the past this was the case]. I am not abusing a tool, I want to have it to things I would expect it would do when I insert a “offset” number in a page field (namely a mathematical operation “+”) - or want to have the option to start a document at page1 with a different page number without creating fake empty pages which export as PDF. Both is not in the toolbox of Libreoffice.

If I would have a field variable what gives me the running page number so that I can insert it as formula field variable (with a mathematical offset), I would be already happy. But “page” is the number of pages of the document, not the running page number. Any help in that direction? Could not find something.

Tried with all the attachments you made, and they indeed don’t show any leading empty page. Again: it just works.

To stop this sterile discussion, I updated my answer to give the recipe for arbitrary first page number without fake empty pages before. I also want to emphasise that this recipe is mentioned in the built-in help. A little search by user in this help would have avoided the above rant. Built-in help worth is generally underestimated or is it common user laziness leading to questions rather than personal introspection?