How do I create a custom page number format?

I’m formatting a book in LibreOffice Writer 4.2.4.2. To simplify, say it has three major sections with three distinct page styles: Front Matter, Body, and Appendix. Using page styles I’ve used small roman page numbers for the Front Matter section and arabic page numbers for the Body section.

I would like to create a new number format for the Appendix section: arabic numbers preceded by the prefix “A-”. The page numbers would read A-1, A-2, A-3, and so on. (It is trivial to type “A-” before a standard arabic page number field in the footer, but of course the Appendix’s page numbers show up in the table of contents without the “A-” prefix.)

Is there a way in LibreOffice Writer to do this?

Unfortunately, the use case you describe is not supported by LibreOffice. Page number ranges consist of one character and additional custom formats are not supported.

Create another page style based left and right built-in styles. (If you’re formatting a book for publication, the left and right pages have to have different margins.) Activate “Header” on both styles. Close the page style page, click on the header, and, on a left page, type “A-” on the left side and insert a page number (Insert>Fields etc.). On one of the right pages, type “A-” on the right side and insert a page number. This worked well on my book ms. Good luck.

If you re-read my question, you’ll see I already tried your approach. The problem is that the prefix (A-) is not recognized as an integral part of the page number and so is not picked up in the table of contents. In the header or footer, body page numbers appear as “1, 2, 3…” and appendix page numbers appear as “A-1, A-2, A-3…”, but in the table of contents they both appear as “1, 2, 3…”, with nothing to distinguish them … hence my inquiry about custom page number formats.