Restart end-of-document footnotes per chapter

First result: the “chapters” were written with LO
I’m trying to discover the setting to reset footnote number. Perhaps, there was no parameter forcing in this release when you switch from notes at page bottom to at end of document.
There are also “many” formatting “rrors”, the most serious of which is using Default Paragraph Style for real text. This style is the ancestor of all others and everything you set there forces you to override in other styles when that setting conflict with your graphical charter.

It was very difficult but I found something. I think a change between and now ( on my computer) is to be blamed for the difference. From experiment, when you configure your footnotes for “end of document”, numbering is reset to “per document”.
In the underlying XML, if I force the setting for “chapter”, Writer behaves as you were used to. Consequently, code for it is still there. I suppose this parameter forcing was introduced to remove a case of numbering ambiguity for the common case where notes at end have no chapter separator.

Bug report is tdf#150207

The temporary fix for you is not obvious and may be dangerous for your documents. I’ll give a procedure in an answer.

Analysis your “chapters” shows that your formatting is rather “elementary” and can greatly be improved.

  • don’t use Default Paragraph Style for your text; Text Body is the standard style for this
  • you never use character styles; instead you apply manual formatting for bold, italics and other variations
  • don’t use empty paragraphs for vertical spacing; instead customise paragraph styles; since you don’t pay special attention to the style of these empty paragraphs, some of them are Heading n and end up in the TOC forcing you to manually edit the TOC to erase spurious entries
  • you number your chapters manually instead of relying on Tools>Chapter Numbering; in case you shuffle your chapters, you’ll have to renumber manually
    If this is motivated by your need for unnumbered chapters, you can always have unnumbered headings by pressing Bksp once at the very beginning of a heading. This removes the number.
  • don’t use manual page breaks for forcing page parity (starting a chapter on a right page); you’ll have to check this manually whenever you edit your book; instead play with page style properties and their automatic sequencing
  • instead of inserting chapter “separator” manually among the end notes (which is not reliable in case of edits and isn’t possible with real endnotes), attach an unnumbered footnote to a chapter heading; the corresponding note will be inserted at the right location and you can style it with any style you like. With fields, you can also echo the chapter heading automatically, so that you don’t need to type it again (and when you modify it, the field updates)
  • you’re not consistent in your end-of-sentence horizontal spacing
    Sometimes you use two spaces after a full stop. This translates to a <text:s/> element in the XML (I don’t know what it does but I’d recommend using a single space and letting Writer do the job; double spaces disturbs its job)


Note that for a new document, this is set to Per document, and there’s no way to change it to anything else, because there’s only one element in this list.

The Per document seems to imply exactly what is wanted, but works differently. Possibly needs investigation what changed this; I suspect one of Caolan’s welding commits.

@mikekaganski what I meant in fact was a “reset in the XML”. I found it through trial and error.

I filed a bug report (or is it a feature request?) at tdf#150207.

If you feel brave, here is a procedure to workaround a change between releases and It may very easily damage your document. Consequently backup your subdocuments in some directory before attempting the patch.

Work in your master and sub-documents without caring for effective note numbering. It is usually wise to work with the latest available LO release than with an outdated one. You benefit from new features, bug fixes and generally improved performance and better UI. When you’re ready for the final proof, follow the procedure:

  1. Save your master and sub-documents in some backup directory so that you have an up-to-date copy in case something goes wrong
  2. Apply the following patch to every sub-document
    1. Open the sub-document and save it .fodt; close
    2. Open the .fodt in text editor, preferentially one which has an XML operating mode (under KDE Plasma I use KWrite; under Mate, gedit is probably a good choice)
    3. Look for the <office:styles> block
      It seems to appear after <office:settings>, <office:scripts> and <office:font-face-decls> blocks. If your text editor is XML-aware, you can click on the margin triangle to “close” the block and decrease screen clutter.
    4. At the end of this block, there are two <text:notes-configuration …> elements, one for footnotes, the other for endnotes
    5. The one for footnotes ends with an attribute text:start-numbering-at="document"; change document to chapter
    6. Save
    7. Process the next sub-document
  3. Rebuild the updated sub-documents; for all of them:
    1. Open the .fodt version of the sub-document in Writer (may need a right-click to force launching Writer on it)
    2. Don’t use Tools>Footnotes & Endnotes **otherwise you’ll have to replay the preceding stance
    3. Save as .odt without any edit
      This overwrites the existing .odt; so check that the backup exists before allowing to overwrite.
  4. You can now open the master to verify that the notes are numbered as you expect.

Hmm. Sounds tedious, but not difficult, especially with the “safety net” of backup folder for insurance. Well, okay, maybe tedious and blood-pressure-raising for the first two ODTs. After a few successes, the “bravery” you mention will be unimportant. The big deal is the “little deals” — not unbalancing quotation marks, <>'s, and not clipping final /'s.

Throughout this process, I was wondering if it were safe to update everything to the latest version of LO. I was mainly afraid that’d I’d lose the “success” in the older file (the one from which I sent you the sample). Apparently that’s not an issue if the sample I sent you behaved as advertised.

BTW, you mentioned release Since that’s not one of the ones to which I referred, did you just pull that out of thin air, or did you actually find it in the code of the files I sent you?

Other observations / questions:

  • I used an experimental ODT and sic’d the Mate Extract utility on it. Interesting unpacking! Is there any problem with using this utility? (Not for the process that you have described above; it’s just a general question for future exploration.)

  • On text-based files (e.g., CSS, HTML) I use Geany. Any problem with that app? As I recall, I can pick an option that lets it know I’m working with a particular type of file or language. In my test, it automatically picked up the fact that the FODT was an XML file.

  • After experimenting further, it looks like I can save a lot of time by just searching the open FODT on the phrase 'at="document"'. The line for footnote comes before the line for endnote; and apparently only the <text:notes-configuration text:note-class="footnote" line seems to contain the search string.

I just had a meeting canceled for me this evening, so I’m going to carefully experiment on two of the chapters in question, using your magic recipe. I’ll report back, and I hope to do so gleefully.

Thanks for all your help on this!

This is what is recorded in <meta:generator> at the beginning of the .fodt file (or meta.xml in the .odt).

No problem as long as you can patch neatly the .odt. I preferred to explore .fodt because I bypass the compression step.

Right, that quite a long time I haven’t worked under MATE and I forgot the name of the “standard” editor.

For your last point: use any search criteria as long as you hit the correct target.

I’ve thought a bit longer on my procedure. It can be simplified. Set the “chapter” attribute. Then, as long as you don’t reference Tools>Footnotes & Endnotes, the setting in XML won’t change. But if you reconfigure the notes, you must again patch manually the XML. Thus, the patching procedure needn’t really by applied as the last step.

BTW, have you read my last comment above the “answer”. I give you many points to care for to avoid trouble with edits.

I’ve tried the procedure 3 chapters. Very straightforward, no errors or wounded file. But also, so far no re-numbering joy. Is there a need/way to also do this FODT-like editing to the ODM as well?

Meanwhile, I’m going to upgrade LO to the latest version and then have another go at it. I’ll report back soon. I feel like we’re closing in on it…

The edits have gone without incident. In fact, the data available in the FODT is fascinating. In each of three files, the relevant footnote-entry code-line ends this way:

…style:num-format="1" text:start-value="0" text:footnotes-position="document" text:start-numbering-at="chapter"/>

I have updated to version to level the playing field, but, alas…

…there is still no number restart, unfortunately. I even tried (during one experiment) changing the text:start-value="0" to a value of “1” in chapter 2; but that didn’t make any difference has since been backed out of the experiment, restoring the default “0”.

Works here with otherwise I wouldn’t have suggested the workaround. Can you check that the attribute has not been reset by Writer?

No, there has been no reset. I’ve just re-exported the three ODTs to FOTDs and checked each in turn in my XML editor. The line in each sub-doc/ODT appears as I presented it in my posting yesterday. No change, but it was certainly worth checking, just in case.

This stalemate does leave me with a question and a… superstition?

The question is this: Is there a XML way to set the footnote “chapter” attribute in the ODM? I know the ODM’s styles overwrite and “disagreement” with the ODT sub-docs. Perhaps the ODM is “overwriting” what we’ve manually set in out FODT edits. And then again, you said you got it working, so perhaps this idea should be scratched.

The superstition is this: What if the difference between the working ODM/ODTs I sent you and the current non-working one has to do with the process of origin? I’m pretty certain I recall the 2018 ODM/sub-doc setup as having been created from the outset as an ODM to which I then added chapter ODTs. With the current problematic document, I had a full 13-chapter file; then I separated the “pieces” using LOW’s ODM-splitter function (the goal being to get chapter-based footnote renumbering in the collected footnote area). One would think it would make no difference; but then again, one would assume that the simple requirement we’re making of the footnote function to work without as much head-scratching as we’ve been doing.

Thank you, @ajlittoz, for your continued dogged patience on this issue.

Answer to the question: the contorted procedure results from the failure to find footnote configuration in the .odm. I found it strange because, as you noted, master configuration takes precedence over subdocs. In addition, collecting notes at end of document makes no sense in a single chapter. It is relevant in the master only. And it surprised me that it worked after fiddling “locally” with a parameter with “global” consequences.

And to add to the difficulty/confusion, while it is possible to save .fodt a master document, it is impossible (or I should say I could find how) to recreate a master from a .fodt. If you want to experiment tweaking a master, you must act directly on the zip’ped .odm.

Rabbit paw or talisman against superstition: in case your book is in the 500-page range (and your computer is sufficiently recent to offer at least 4-8GB), I think you may have a try with a single .odt (common text document). But due to the size of contents.xml, don’t save as XML to change the magic setting. Do that directly on the zipped contents.xml after extracting it and replace it after patching. Of course, do this on a copy of the original document.

Well, since I started with a one-piece ODT, “getting back” to that is no problem.

But since I’m new to fiddling with XML files, not mentioned “exploding” ODT files on command, I have an ignorant question regarding:

How do I put the genetically modified “Humpty” back together again?

FWIW, the book is ~230pp, of the 6in x 9in variety, so probably more like 150 U.S. “letter” size sheets. Both my systems have Core i7s and 16 Gb of RAM.

I have very complex documents ~250 A4 pages in single files. They contains tables, frames, cross-references, … but they are fully styled which contributes to decrease stress on Writer. They are easily managed on my now ageing computers (even on my 2-core only 1.1 GHz AMD laptop). So you shouldn’t have any problem on your machines.

Regarding patching .odt, it should be possible to do this in the GUI.

  • make a copy of your document
  • change extension from .odt to .zip and double-click on it
    If you have installed an archive manager application, this will open the .zip as if it were a directory and you’ll see the contents in a new window
  • OR right-click on the .odt copy and select “Open with” to choose the archive manager application
  • extract the contents.xml sub-file
  • modify it with a text editor
  • store back the modified sub-file by drag-and-drop over the .zip window
  • make sure you haven’t two instances of contents.xml
  • change back the extension from .zip to .odt
  • check the document is not damaged (thus the importance of wotking on a copy)

@ajlittoz, my friend, you are a genius. I now have “endnotes” (footnotes) at the end of the all-in-one document, and they restart numbering at “1” with each chapter.

Knowing that my machine could handle it, I re-used your simpler ODT → FODT → make change in XML editor → save back to ODT method. It’s perfect. Best of all, without ODM and subdocs, I only had to tweak one setting in one file!

Now to ask two less self-centered questions:

  1. Shouldn’t we make an official bug report about this? (A re-implementation of this “lost” feature would probably benefit other academic writers.) And,
  2. How do we do that?

BTW, for however few may be lurking or seeing this exchange later, I use a cheater’s method to give each chapter’s end-of-document endnotes a chapter heading. How? After creating a style for endnote-chapter-heading, I use this at the bottom of the last endnote of each chapter. So the last endnote of chapter 1 carries with it the heading for the endnotes of chapter 2, etc.

Ah, but what about the heading for chapter 1, since no endnotes precede that chapter? I’m surprised that it worked, but this how I solved it: by putting the endnote-chapter-heading for the first chapter in the page header of the first endnotes page. I don’t know if that’s a help to anyone else or not.

Once again, thanks, @ajlittoz, for your help, your friendly persistence, and your solution. And thank you, too, @mikekaganski, for your input.

Bug report: already done as tdf#150207

Your procedure for endnotes chapter heading is faulty and you’ll create further problems.

  • On a logical point of view, a chapter is an “independent” semantic unit. Adding the note heading at end of previous chapter creates a link between two units which prevents you from managing or reorganising your chapters with the Navigator. In fact, if I understand right, you don’t add an autonomous note but a new paragraph to an existing note. This is intellectually even worse because this heading paragraph has nothing to do with the note. More, the last note has not a fixed position in the text and you need to track it in case of modification (new note or deletion).
    Fix: attach the note heading to the Heading 1 chapter heading with Insert>Footnote & Endnote>Footnote or Endnote. You get a dialog which allows you to choose the anchor character. In this case, it’ll be a space character so that the note is unnumbered.
  • Don’t play tricks with the headers. In principle, everything in a header is repeated on every page. A header is not intended for argumentation, only for “titling” or reference identification.
    Writer lock-protects headers by not allowing to add notes there. Consequently, I assume you requested different header contents in the page style configuration. It woks, but it is not “logically” valid because you mix argumentation/discourse and "decoration.
    Fix: see preceding trick for note headings.

Sorry. By my using the term “chapter heading” all too loosely, I gave you the impression that I was actually using that entity properly named “heading.” My bad. Actually, I was just using a paragraph style that bolds/centers/underlines, and tacking that onto the bottom of any chapter’s final footnote. This style has no “heading” attributes. And you’re correct that a chapter might gain a new last endnote in editing. But your warning certainly would be warranted if I were actually fiddling with a true heading of some sort. Anyone reading my previous post, please take heed.

I like MUCH BETTER the solution you offer, as it seems far more elegant and sophisticated. As soon as I can back to the manuscript (probably not until tomorrow afternoon), I'm going to try to replace my clumsy hack with your far superior magic trick.

Also noted is the fact that you posted the bug report on this 3 days ago.

It was a lucky day for me when you chose to respond to my request for help. Once again, thank you, @ajlittoz!

No, you can use the word heading because, logically, it is a heading. And you can even make it a real heading. All you have to do is attach the specific paragraph style to some Outline level in the Outline & List tab of the style configuration. If you don’t change TOC parameters, these headings won’t be collected in the TOC (unless you want them so for your own TOC). And the endnote headings will be listed in the Navigator, which is handy to quickly jump to them.

Use of a computer document processor must not break the logical structure an author imposes on a book. Parts which are not related to each other should not be artificially linked through an unmastered feature of the application. This is the most important aspect of authorship. Writer is a very powerful application. It has relatively few limitations on creative freedom. But you must be clear in your mind. If you’re confused and not well-organised, your book will be a mess.

Unfortunately, Writer is extremely feature-rich. In the beginning you’re hypnotised by all this wealth and may be inclined to try features only for their appearance without backing their use on your real need (in relation with your purpose, the message you want to pass to the reader and the “modulated” strength of the message).

Using Writer is not difficult. Using it to support your argumentation is art.