I’m new to Scrivener 3 for Windows (which I consider awsome !), and can’t succeed to properly add chapter/section autonumbering in image caption and in footer.
As it may seem very basic to experienced users, I would be grateful of any help
For example, for the 3rd image in Section 2 of Chapter 2, it would be a caption like " Fig. 2.2.3 - Caption text ".
And the footer of that page would be like " 2.2 - Section name "
I’ve tried hours in vain with nested placeholders like <$n:image:<$hn>>, and <$parentposition> in footer.
Two different ways exist using $n and using $hn. This first you have to restart the numbering stream, the second restarts automatically after a Page Break.
If your Chapters and Sections are numbered in the Titles, you need to use a “#” in the code, so they don’t increment. The number of the Image you use a colon “:”, so it increments when you use it.
I use:
For the chapters: Chapter <$n:chapter> - Chapter name
For the sections: Section <$n#chapter>.<$n:section> - Section name
For the images: Figure <$n#chapter>.<$n#section>.<$n:figure:ImageName> - Caption text. (ImageName without spaces must exist for this number to increment)
Restart the Sections and Figures in the Chapter Prefix: <$rst_section><$rst_figure>
Restart the Figures in the Sections: <$rst_figure>
When you use $hn for your Titles, you can do the same, but you don’t have to restart the numbering for chapters and sections. This way it seems not possible to restart the Image Numbering Stream, so if you want 2.3.1 for the first Image in the next Section, it will turn out to be 2.3.4.
[Edit] Actually, the reset not working in Sections or Chapters is also the case in the first way of numbering, using $n. If someone knows how to circumvent this, please let me know. [/Edit]
I’ve done exactly as you say, and get close to the objective :
in a figure global number (such as 2.2.3), the chapter and section number are correct, but the figure number in a section doesn’t reset, it counts from the very first image of the book (maybe that’s what you mention at the end of your message).
Besides, for PDF or ebook, do you know if a figure global number mentioned anywhere in the book can be hyperlinked to the corresponding caption being in a different chapter/section ?
I’ve further tested and found something better but not adequate :
If in image captions placeholder, I remove keywords, the caption full number is correct except for the 2nd caption of each 1st section (see image here) : the caption number last digit doesn’t increment from 1 to 2, and consecutive captions correctly increment from 2 onwards.
I’ve copied the project and reduced content to a minimum, but the problem remains after many tweakings on placeholders, project tree and section types.
Hi @michelo , have you tried to remove the <$rst_figure> at the Chapter level? Maybe that produces the repetition of the number 1 in the Images Numbering stream. I haven’t tested this yet. Just wondering…
Did you solve the problem in the end?
I’ve just tried : the figures numbering is now correct for section 1.1 but the problem remains identical for other sections. And the section numbering itself doesn’t increment too from chapter 7 (???).
Maybe it’s a bug : when I searched on the net, I came across a Scrivener forum post from “Keith”, in June 2018 (Mac version) :
Here’s the bottom :
IMPORTANT NOTE: While putting together this reply, I noticed that there is a bug in the current version of Scrivener whereby the above example will not work correctly. When you compile using 3.0.2, you will notice that the hierarchical numbering in my sample project comes out wrong, with both 2.1 and 2.2 being labelled “2.1”. I have fixed this for 3.0.3, which will be out later this week or early next week, so please wait for that to test this properly.
Full post :
So I plan to open a support ticket, and will post the answer here.
I know this thread was created a while ago. I am having similar yet slightly different issue with Scrivener. Basically, I want my figure to be labelled by chapter number followed by auto-number that get reset in every chapter.
So,
I used the following in the compile replacement option:
Figure <$n#chapter>.<$n:figure:$1>
Then for each chapter, I used <$rst_figure> to reset the auto-number.
So far, all the figures seem to work well and I was able to generate a list of figures too.
However, I don’t know how to refer to this figure cross chapter now…for the figures in the same chapter, I can use the same syntax <$n#chapter>.<$n#figure:$1> but I am wondering if you know how to cross reference a figure in other chapters? The <$n#chapter> gives the current chapter.
I had to look this up. The Scrivener-Placeholders PDF (found in the Help menu) says:
You can create special auto-numbering placeholders that include a name and a
keyword to enable you to refer back to auto-numbers, for instance for referring to
tables and figures. The format of such auto-numbering placeholders is this:
<$[auto-number-type]:[name]:[keyword]>
Subsequent instances of placeholders that use the same auto-number type,
name and keyword will be replaced with the same number as was generated for
the first instance of that combination; only placeholders that have a different
keyword will cause the number to be incremented.
This is best explained with an
example:
[An image]
Figure <$n:figure:myImage>
[Another image]
Figure <$n:figure:nextImage>
[A table]
Table <$t:table:myTable>
See Figure <$n:figure:myImage>, Figure <$n:figure:nextImage> and Table <$t:table:myTable>.
When compiled, this will result in the following:
[An image]
Figure 1
[Another image]
Figure 2
[A table]
Table One
See Figure 1, Figure 2 and Table One.
Note how the placeholder “<$n:figure:myImage>” occurring later in the text was
replaced with the same number (“1”) generated for the first instance of that
placeholder.
If you want to create a forward reference, for the reference use the format:
<$[auto-number-type]#[name]:[keyword]>
(i.e. Use a hash instead of the first colon.)
E.g:
<$n:eg:foo> Example sentence.
See example <$n#eg:foo> and compare it with <$n#eg:bar> below.
<$n:eg:inbetweener> Another sentence.
<$n:eg:bar> The final sentence.
When compiled, this will result in the following:
1 Example sentence.
See example 1 and compare it with 3 below.
2 Another sentence.
3 The final sentence.
Using names and keywords in auto-numbering placeholders can thus allow you
to refer to table and figure numbers. (Note that names and keywords cannot
contain any whitespace characters such as spaces.)
Thanks @AntoniDol. That’s very helpful. My current dilemma is whether to stick with labelling figures by chapters, or just use the auto-numbering of figures without the chapter.
It sounds like having the chapter number as prefix requires a lot of fiddling in Scrivener, i.e.,
I can’t use the <$n:chapter> in Section Layouts → Title Options → Title Prefix (under Compile)
I will have to name each chapter like <$n:chapter:chapter1> <$n:chapter:chapter2>…
Then, for each figure, I will create the label in “replacements” using Figure <$n#chapter>.<$n:figure:$1>
Then, to reference the figure from another chapter, I will have to specify (or hardcode) the chapter number such as if the figure is in chapter 1, and I refer the figure in chapter 5, I will have to do something like <$n#chapter:chapter1>.<$n#figure:figure-name>
My secret wish is, given that each figure is labelled with a unique name, Scrivener could automagically figure out the chapter of the figure…but apparently, I haven’t been able to find a solution that is simpler than the above.
So, for now, I will keep it simple with auto-numbering figures without a chapter prefix.
If anyone knows a simpler solution, I would be very much like to know and learn about it. Although, I am contemplating writing my own Pandoc filters to post-processing it…