PDF-CSS: Creating new CSS counters for new types of figures
Posted: Tue Aug 17, 2021 2:54 am
Hello, I need some advice on adding additional CSS counters to the PDF-css scenario for custom types of figures.
In addition to the default figures, we also have examples and equations. We would like the captions and counters on these types to be "Example N", and "Equation N", where N is a counter for the respective type. The counts for each of these 3 types must be distinct. Therefore, the already defined 'figcount' css counter is placed on default figures, and we need to create and add two additional css counters for examples and equations.
We have already implemented custom CSS for counting our custom types, and it works for captioning and numbering the item itself, however, when we have elements that refer to these custom types, it uses the figcount counter and caption. For example, if we have an <xref> that targets an equation, the caption on this <xref> is "Figure XX", and the count XX is incorrect (it is the figcount counter, not our custom counter).
This mismatch in captions and count for xrefs makes me think that our custom CSS for our custom types is implemented incorrectly. Indeed, when I search the com.oxygenxml.pdf.css plugin for "figcount", I see dozens of resets, increments, and usages. Currently we use an outputclass attribute on the figure with our own custom value ("ExampleTitle", "EquationNum") to count these things. For internationalization, we look up the caption in XSLT, like the XHTML build does it.
For <xref> elements, I see that a <span> is inserted, and this span has a class attribute value of "- topic/ph ph fig--title-label-number ". The string "fig--title-label-number" is also used in a <span> element within the fig itself. I have found XSLT where these are inserted, and "fig--title-label-number" seems to be hardcoded, so that the <xref> always uses the figcount counter.
Sadly, I just don't understand the connection between the <span> elements in the <xref>, and the <span> element in the figure. How do these two work together with the CSS to produce the caption and count?
I would appreciate some guidance on best practices for implementing new CSS counters -- it seems that what we have done so far is both incorrect and incomplete (in terms of internationalization of the words "Figure", "Example", and "Equation").
Thanks,
-J
In addition to the default figures, we also have examples and equations. We would like the captions and counters on these types to be "Example N", and "Equation N", where N is a counter for the respective type. The counts for each of these 3 types must be distinct. Therefore, the already defined 'figcount' css counter is placed on default figures, and we need to create and add two additional css counters for examples and equations.
We have already implemented custom CSS for counting our custom types, and it works for captioning and numbering the item itself, however, when we have elements that refer to these custom types, it uses the figcount counter and caption. For example, if we have an <xref> that targets an equation, the caption on this <xref> is "Figure XX", and the count XX is incorrect (it is the figcount counter, not our custom counter).
This mismatch in captions and count for xrefs makes me think that our custom CSS for our custom types is implemented incorrectly. Indeed, when I search the com.oxygenxml.pdf.css plugin for "figcount", I see dozens of resets, increments, and usages. Currently we use an outputclass attribute on the figure with our own custom value ("ExampleTitle", "EquationNum") to count these things. For internationalization, we look up the caption in XSLT, like the XHTML build does it.
For <xref> elements, I see that a <span> is inserted, and this span has a class attribute value of "- topic/ph ph fig--title-label-number ". The string "fig--title-label-number" is also used in a <span> element within the fig itself. I have found XSLT where these are inserted, and "fig--title-label-number" seems to be hardcoded, so that the <xref> always uses the figcount counter.
Sadly, I just don't understand the connection between the <span> elements in the <xref>, and the <span> element in the figure. How do these two work together with the CSS to produce the caption and count?
I would appreciate some guidance on best practices for implementing new CSS counters -- it seems that what we have done so far is both incorrect and incomplete (in terms of internationalization of the words "Figure", "Example", and "Equation").
Thanks,
-J