How to insert chapter nmber page number in footer

I am using template (Jinja) for automatically generate document.
In the footer, i want generate $(chapterNumber)-${pageNumber}, and the page number for each chapter start from 1.
I will prepare data (including chapter information, etc) for Jinja to rendor.
When I create my template, how can i do for the footer?

I tried insert chapter number (Insert->Field->More Fields->Document->Chapter->Chaper number) and page number (Insert->Field->More Fields->Document->Page number) in the footer in my template. But it does not works.

About your request

“It does not work” is not very specific.

You told us what you did in specific terms. That is good!
Now we need to know what you see after you inserted those two fields. Is there anything at all? A grey rectangle where the numbers should be? One number but not the other? Descriptive text (field names) instead of numbers?

Can you attach to your question the template file you made, which does not work?

Wild guess:

In Writer, you start a chapter by setting a paragraph (the chapter heading) to an outline level, which defines it as “above text body” in the structrure of your document. Typically you would do this by applying the paragraph style Header 1. Before you add such structural element, your document has no concept of chapter number. Page number should appear.

Does this apply to your situation?

I had a look to a few Jinja sites and I don’t see how it is related to LO Writer. It seems to generate Python code based on “templates”. These templates are not LO templates. Please, edit your question (= modify it without using comments) to better describe your idea (decision?) to use Jinja to create a Writer document.

If your goal is to create a .fodt file (i.e. a text document without the compression wrapper), you need deep knowledge and understanding of OASIS ODF format. Perhaps a mail-merge procedure driven by a CSV file could do the trick if the document is simple enough. An alternative could be to use Base (the frontend to databases) which provides a report generator.

In any case, mention your OS name, LO version and intended document format (odt vs. doc(x)), being aware that any solution will be stable and reliable only in odt.

1 Like