emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to auto-renumber chapters
@ 2024-08-28  8:41 Sharon Kimble
  2024-08-28 16:20 ` András Simonyi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sharon Kimble @ 2024-08-28  8:41 UTC (permalink / raw)
  To: emacs-orgmode

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


I'm writing a fiction book, and have just added several chapters from a previous draft to it.

As a result I now have

** Chapter 2
blah     

** Chapter 2
blah de blah

** Chapter 3
more blahing

How can I get these new chapters to autorenumber themselves please, so that they will show Chapter 2, Chapter 3 and Chapter 4?        

Thanks
  Sharon.
- -- 
Debian 12.6, Fluxbox 1.3.7, emacs 31.0.50, org 9.7.10 
-----BEGIN PGP SIGNATURE-----

iQJRBAEBCgA7FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAmbO4qodHGJvdWRpY2Nh
c0Bza2ltYmxlMDkucGx1cy5jb20ACgkQNoGAGQr4g1seWhAAmzZfon0n2x4cJI0L
jjT8fdzNLeDp5vEUA1u3EHEJdtMsufPNIJt3L8kLQaL0+7/WaEboy3N/u/3XyPQz
IioaonnBqO6TAWXoyelpLDof48XI88jEaop/pM5CAaVe7NuPNOI7tkzVcHk53qwE
Kpy1FTVPKx9CyHLC0vOCfwoVKOzUCNfYWIALvK7wWGs5z3BHAqrcYokOdzselPNm
7eoaJjmHvu+nOFQzUMSJdPgTLE4LfXqBY8Rc7QvodRia4KNe8oHwB1Vr/TqWHIio
ZWfryOyutxAEkCUQD+yYAGD8Fg8h6Gd1GJF6TFea9iJ/cnfnmZjjjY9XwUqHHrOU
jhW+oS8PmTqU1klKDt3PHf5odN0UuD1CEJQ5VvFjfYjmY6OCL36AILxz+WdPnUmg
cT6leq/xZKFLLXVr93irUgFgohzLHBBK4pW6Wv9XsIKSA3n9V1Oyzr2t4DPJjJaL
a5fgSKHGTDpip6mtTG7AS8tkSTamdhaPjDJ9anP1NYV2Lccgx2L4EFUkZcnnqeKq
h+b5zdOqV75z6oHZvWfMyAOi5fd469/pQ7IqYW2u/Gm/uXQ096Pw2q999+9howeA
3U6PGUgzP1GcynzhMCFSLUsyokBwJeVSfPmQep1+UAWxPuy9YJjeZ9k9S3smTk6Y
aSkmndz1ePMMdQYKS07BPJXhXu4=
=Y4K2
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to auto-renumber chapters
  2024-08-28  8:41 How to auto-renumber chapters Sharon Kimble
@ 2024-08-28 16:20 ` András Simonyi
  2024-08-28 17:55 ` Gregor Zattler
  2024-08-31 18:41 ` Ihor Radchenko
  2 siblings, 0 replies; 4+ messages in thread
From: András Simonyi @ 2024-08-28 16:20 UTC (permalink / raw)
  To: Sharon Kimble; +Cc: emacs-orgmode

Dear All,

On Wed, 28 Aug 2024 at 10:41, Sharon Kimble
<boudiccas@skimble09.plus.com> wrote:

> I now have
> ** Chapter 2
> blah
> ** Chapter 2
> blah de blah
> How can I get these new chapters to autorenumber themselves please, so that they will show Chapter 2, Chapter 3

one way of doing the required renumbering would be performing a
regular expression-based replacement (using the replace-regexp or
query-replace-regexp commands) along the following lines:

regular expression: ^** Chapter \([0-9]+\)
replacement: ** Chapter \,(+ \# 1)

This assumes that the headings to be renumbered have the form "**
Chapter ##.." and the numbering should start with 1 so might need to
be adapted slightly to your use case.

best wishes,
András

> Thanks
>   Sharon.
> - --
> Debian 12.6, Fluxbox 1.3.7, emacs 31.0.50, org 9.7.10
> -----BEGIN PGP SIGNATURE-----
>
> iQJRBAEBCgA7FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAmbO4qodHGJvdWRpY2Nh
> c0Bza2ltYmxlMDkucGx1cy5jb20ACgkQNoGAGQr4g1seWhAAmzZfon0n2x4cJI0L
> jjT8fdzNLeDp5vEUA1u3EHEJdtMsufPNIJt3L8kLQaL0+7/WaEboy3N/u/3XyPQz
> IioaonnBqO6TAWXoyelpLDof48XI88jEaop/pM5CAaVe7NuPNOI7tkzVcHk53qwE
> Kpy1FTVPKx9CyHLC0vOCfwoVKOzUCNfYWIALvK7wWGs5z3BHAqrcYokOdzselPNm
> 7eoaJjmHvu+nOFQzUMSJdPgTLE4LfXqBY8Rc7QvodRia4KNe8oHwB1Vr/TqWHIio
> ZWfryOyutxAEkCUQD+yYAGD8Fg8h6Gd1GJF6TFea9iJ/cnfnmZjjjY9XwUqHHrOU
> jhW+oS8PmTqU1klKDt3PHf5odN0UuD1CEJQ5VvFjfYjmY6OCL36AILxz+WdPnUmg
> cT6leq/xZKFLLXVr93irUgFgohzLHBBK4pW6Wv9XsIKSA3n9V1Oyzr2t4DPJjJaL
> a5fgSKHGTDpip6mtTG7AS8tkSTamdhaPjDJ9anP1NYV2Lccgx2L4EFUkZcnnqeKq
> h+b5zdOqV75z6oHZvWfMyAOi5fd469/pQ7IqYW2u/Gm/uXQ096Pw2q999+9howeA
> 3U6PGUgzP1GcynzhMCFSLUsyokBwJeVSfPmQep1+UAWxPuy9YJjeZ9k9S3smTk6Y
> aSkmndz1ePMMdQYKS07BPJXhXu4=
> =Y4K2
> -----END PGP SIGNATURE-----
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to auto-renumber chapters
  2024-08-28  8:41 How to auto-renumber chapters Sharon Kimble
  2024-08-28 16:20 ` András Simonyi
@ 2024-08-28 17:55 ` Gregor Zattler
  2024-08-31 18:41 ` Ihor Radchenko
  2 siblings, 0 replies; 4+ messages in thread
From: Gregor Zattler @ 2024-08-28 17:55 UTC (permalink / raw)
  To: Sharon Kimble, emacs-orgmode

Hi Sharon,
* Sharon Kimble <boudiccas@skimble09.plus.com> [2024-08-28; 09:41 +01]:
> I'm writing a fiction book, and have just added several chapters from a previous draft to it.
>
> As a result I now have
>
> ** Chapter 2
> blah     
>
> ** Chapter 2
> blah de blah
>
> ** Chapter 3
> more blahing
>
> How can I get these new chapters to autorenumber themselves please, so that they will show Chapter 2, Chapter 3 and Chapter 4?        

András' solution shows emacs' greatness.

But it might be easier to get rid of
numbers in the /text/ of headings and
instead do M-x org-num-mode, which
dynamically shows heading numbers like

1. Heading
2. Heading
   1.1 Heading

...

with default settings.  There plenty of
possibilities for configuration, see
(info "(org)Dynamic Headline Numbering")
[evaluate after the last closing parenthesis]
or the commentary section of org-num.el


Ciao; Gregor 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to auto-renumber chapters
  2024-08-28  8:41 How to auto-renumber chapters Sharon Kimble
  2024-08-28 16:20 ` András Simonyi
  2024-08-28 17:55 ` Gregor Zattler
@ 2024-08-31 18:41 ` Ihor Radchenko
  2 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-08-31 18:41 UTC (permalink / raw)
  To: Sharon Kimble; +Cc: emacs-orgmode

Sharon Kimble <boudiccas@skimble09.plus.com> writes:

> I'm writing a fiction book, and have just added several chapters from a previous draft to it.
>
> As a result I now have
>
> ** Chapter 2
> blah     
>
> ** Chapter 2
> blah de blah
>
> ** Chapter 3
> more blahing
>
> How can I get these new chapters to autorenumber themselves please, so that they will show Chapter 2, Chapter 3 and Chapter 4?        

Yet another solution, in addition to what was provided in other replies,
is using macros. When you have

** Chapter {{{n}}}
...
** Chapter {{{n}}}
...

{{{n}}} will be automatically replaced with a counter, but only on
export. See https://orgmode.org/manual/Macro-Replacement.html#index-n_002c-macro

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-31 18:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28  8:41 How to auto-renumber chapters Sharon Kimble
2024-08-28 16:20 ` András Simonyi
2024-08-28 17:55 ` Gregor Zattler
2024-08-31 18:41 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).