Page 1 of 1

Target-counter targets the wrong counter

Posted: Mon Jul 08, 2019 11:50 am
by NielsVerstappen
Hi,

I'm trying to display the figure and table numbering in an xref by using the target-counter() function. However when I target tablecount or figcount for a certain table or figure, the output displays the page number. I checked the documentation for the target-counter() function and I do not see any errors in my code. The counters get reset whenever a new topic is started like below:

Code: Select all

*[class ~= 'topic/topic'][is-chapter] {
    counter-reset: tablecount 0
                   figcount 0
                   section1 0
                   section2 0
                   section3 0
                   section4 0 !important;
In my DITA code all links to figures or tables have the outputclasses 'fm:Figure_Num' and 'fm:Table_Num' respectively. The content of these links is then set to the following in my CSS file:

Code: Select all

*[outputclass ~= "fm:Table_Num"] {
    content: "Table  " counter(chapter) " - " target-counter(attr(href), tablecount) !important;
}
*[outputclass ~= "fm:Table_Num"]:after {
    content: " " !important;
}
*[outputclass ~= "fm:Figure_Num"] {
    content: "Figure " counter(chapter) " - " target-counter(attr(href), figcount) !important;
}
*[outputclass ~= "fm:Figure_Num"]:after {
    content: " " !important;
}
I would expect the output to display: Figure 4 - 2 for the second figure in chapter 4. However it displays: Figure 4 - 21 while the second figure of chapter 4 is on page 21. I hope someone is able to help me out here.

Thanks in advance,
Niels

Re: Target-counter targets the wrong counter

Posted: Tue Jul 09, 2019 12:34 pm
by Dan
Hello Niels,

I tried reproducing your problem using the CSS rules you provided with oXygen 21.1 and it works fine. Can you tell me what version are you using?
Do you get the same errors for the tables?

Another thing: I am not sure if you are using the HTML5 based PDF transformation. If you are, in the oXygen version 21.1 we introduced a new parameter that applies to this transformation type:

Code: Select all

args.css.param.numbering = deep-chapter-scope
https://www.oxygenxml.com/doc/versions/ ... eters.html
It basically does exactly what you need. Can you give it a try and let me know if it the links exhibit the same problem?

Many regards,
Dan

Re: Target-counter targets the wrong counter

Posted: Wed Jul 10, 2019 10:57 am
by NielsVerstappen
Hi Dan,

I was using oXygen version 21.0 when I uploaded this topic.
Indeed after I downloaded the update, it worked as expected.

Thank you for your fast response!

Many regards,
Niels