Index ¦ Archives ¦ RSS

My hack week at Collabora: (start of) padded numbering in Writer

Estimated read time: 3 minutes

As mentioned in a previous such report, a hack week is when we are allowed to hack on anything we want in LibreOffice for a few days at Collabora. I used this time to implement core support for padded numbering in Writer.


Padded numbering is a style where you insert 0 characters in front of an otherwise normal (Arabic) numbering, making sure that the result always has at least N characters. Up to now, you had to number your content manually to have this effect, while Word supports this feature.

OOXML supports padding up to 2, 3, 4 and 5 characters. Padding up to 2 characters is the older feature, supported in DOC and RTF as well, so I focused on that piece.

Results so far

Here is how the current, the baseline and the reference rendering of padded numbering looks like:
Figure 1. numbering-padded2.docx, current
Figure 2. numbering-padded2.docx, baseline
Figure 3. numbering-padded2.docx, reference

You can see how 0 is inserted before 1..9, but not before 10.

How is this implemented?

If you would like to know a bit more about how this works, continue reading… :-)

Then I found that footnote numbering needs explicit handling, so added support for padding in that case as well:

Finally I had a little bit of remaining time, so I extended support for the recently added Chicago numbering:

Future work

Padding up to 3, 4 and 5 characters would be possible to do, but it’s DOCX-only, and uses a different markup, planned to be done later.

All this is available in master (towards LibreOffice 7.0), so you can grab a daily build and try it out right now. :-)

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.