-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Brilliant! Thank you very much Jean, works like a dream, thank you very much!

Thanks
    Sharon.
  
> Jean Louis <bugs@gnu.support> writes:

> * Sharon Kimble <boudic...@skimble09.plus.com> [2025-07-20 16:14]:
>> Hi folks.
>> 
>> I've written a book and just created a new chapter by splitting one in half.
>> 
>> They are numbered Chapter 1, Chapter 2, etc, and they're all level one 
>> headings.
>> 
>> So how can I auto-renumber them please?
>
> #+TITLE: My Book
> #+OPTIONS: num:t
>
> * Chapter 1
> :PROPERTIES:
> :CHAPTER: 1
> :END:
> This is my first chapter content...
>
> * Chapter 2
> :PROPERTIES:
> :CHAPTER: 2
> :END:
> Second chapter content...
>
> * Chapter 3
> :PROPERTIES:
> :CHAPTER:  3
> :END:
> Second chapter content...
>
> * Chapter 3
> :PROPERTIES:
> :CHAPTER:  3
> :END:
> Second chapter content...
>
> * Chapter 3
> :PROPERTIES:
> :CHAPTER:  3
> :END:
> Second chapter content...
>
> * Chapter 4
> :PROPERTIES:
> :CHAPTER:  4
> :END:
> Third chapter content...
>
> Put this function in your init file:
>
> (defun org-update-chapter-numbers ()
>   "Update all chapter numbers sequentially in the current buffer."
>   (interactive)
>   (save-excursion
>     (goto-char (point-min))
>     (let ((counter 0))
>     (while (re-search-forward "^\* " nil t)
>       (when (= (org-current-level) 1)
>         (setq counter (1+ counter))
>         ;; Update the property
>         (org-set-property "CHAPTER" (number-to-string counter))
>         ;; Update the heading text
>         (org-edit-headline (format "Chapter %d" counter)))))))
>
> Now you can do M-x org-update-chapter-numbers to update numbers of chapters.

- -- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk
So you want to write a book ... = https://sharonmk.co.uk
Debian 12.11, Fluxbox 1.3.7, emacs 31.0.50, org 9.7.32 
-----BEGIN PGP SIGNATURE-----

iQJRBAEBCgA7FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAmh98PcdHGJvdWRpY2Nh
c0Bza2ltYmxlMDkucGx1cy5jb20ACgkQNoGAGQr4g1tHsw//WtTdMycof2UBGCd1
QiX/cxLd+A3sQhIgb1A4CQ5IZmuPDfWNtn2/dsEAoOQfNhdd2GqDSiogQkzMKy8q
c3+sQ22vRpyT5ne7KvJFN/d+gAbcJ2hP9b2gWpMNGsIN7CdLsifR90zcvn8/6THb
e003l0LXc1LGF9x3IkrVBANk+F2nxrR7kekrJ1WBBfjpa0P27sffIeNmbovPZI6l
P8LMCNU70QEwlLxYt44dcqmDbmEGs/1euEdXns2itU4T60aFRO4K8jJZbgNAVsYg
Es25a4XyWqkgN+1jbCbm0rLzX+fFzKrfckORKDrBTAFU1Qnbw0EdxNd7cRSA2P5J
clcL7TxAtfjTDaWZOs/JzJh7Kib5zHlfdnaiX8HA7gLzqKSPKKQRM0yYJME35CIT
FmRzoOYrE5160KYFPdtYBhKqVJthhjJJUFV6rFR3v2/65EUKctmFjI5ZL2T8V5Ob
4etbEEPsfU2ZB3RLvPTFe9bOX9q5k3U4ENBa5GrqXxcJoQ6nqFfo12QOQLmMt3Jr
LlNiKBvIU+y7sV7tZau6dK/NPJxQH2vHLSvMJgHEoKDn/XThs+uep4ShQznInBMY
g2Y26afxhXdYbul+UH2rUi8tfwfrrW7jicW0zyuFnuj4OYCoQqmgvAnVRY8MwfS3
tCXzslchSlyXj3rmdlncr21gb/U=
=DOk+
-----END PGP SIGNATURE-----

Reply via email to