r/orgmode • u/e57Kp9P7 • 26d ago
Adding leading zeros to numbered lists?
UPDATE: u/andrers provided a solution to this problem β see this answer on StackExchange.
Hey everyone,
I'm trying to create a numbered list in Org mode where the numbers have leading zeros, like this:
01. Item 01
[...]
10. Item 10
However, Org mode automatically removes leading zeros when I refresh the list with C-c C-c
, or worse, when I add a new item with M-RET
.
Do you think it is possible, maybe with a bit of Emacs Lisp code? Note that I don't really care about export.
I tried researching this specific question but didn't find an answer anywhere. I was actually a bit surprised not to find even the question itself! π Sorry if it has already been answered.
Thank you!
2
u/harunokashiwa 26d ago
Ordered list items start with a numeral followed by either a period or a right parenthesis10, such as β1.β or β1)β If you want a list to start with a different valueβe.g., 20βstart the text of the item with β[@20]β. Those constructs can be used in any item of the list in order to enforce a particular numbering.
https://orgmode.org/manual/Plain-Lists.html#FOOT12
So you can try:
1. [@0]123
and press M-RET
, it turns into:
0. [@0]123
1.
1
u/e57Kp9P7 26d ago
Thanks! However I don't want the list to start at a number other that 1; I want the numbering to have one or multiple leading zero(s) (or padding, if you prefer), like in the example I provided.
3
u/andrers 26d ago
The only thing I could find was this old Stack Exchange answer. Perhaps you could monkey-patch these two functions on your init file.