Re: Problem with numbering of listings in a book

Posted by David Jencks on
URL: https://discuss.asciidoctor.org/Problem-with-numbering-of-listings-in-a-book-tp7663p7670.html

How exactly are you specifying the caption?

I think the problem is what you suspect.  Attribute substitution isn’t as much of a “function” as at least I expect: they tend to be evaluated in context.  So perhaps when you reference from chapter one, Figure: {chapter} is evaluated with :chapter: 1.

I’m not sure how to solve the problem.

David Jencks

On Feb 24, 2020, at 2:48 PM, siddjain [via Asciidoctor :: Discussion] <[hidden email]> wrote:

Hi Alex,

Thanks.

This is working for me with one problem. I have a figure (or it could be a listing or table for that matter) in Chapter 2. It is correctly numbered as Figure 2.10 in that chapter, but when I try to reference it from Chapter 1 using <<chap2.adoc#the-figure>> the reference appears as Figure 1.10. So it does not insert the correct chapter number.

I have following preamble in the chapters

:xrefstyle: short
:listing-number: 0
:figure: 0
:figure-caption: Figure {chapter}.
:listing-caption: Listing {chapter}.
:table-caption: Table {chapter}.

the :listing-number: 0 is resetting listing counter to 0. Similarly :figure:0 resets the figure counter to 0.

and for chapter 1 I have

:chapter: 1

and for chapter 2 I have

:chapter: 2

in the preamble.

I suspect the bug has to do with the figure-caption I have inserted in the preamble.

How do I tell it to use the chapter number of the chapter that is being referenced instead of the chapter itself?



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Problem-with-numbering-of-listings-in-a-book-tp7663p7669.html
To start a new topic under Asciidoctor :: Discussion, [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML