Figure and Table numbering

shudson310
Posts: 133
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Figure and Table numbering

Post by shudson310 » Thu Jun 28, 2018 11:05 pm

I'm trying to auto-number figures and tables, but the counter doesn't increment. Here's my code:

Code: Select all

body {
counter-reset: figures 1;
counter-reset: tables 1;
}

*[class ~= "topic/fig"] {
counter-increment: figures;
}

*[class ~= "topic/fig"] figcaption::before {
content: "Figure " counter(figures) ": ";
}

table {
counter-increment: tables;
}

table caption::before {
counter-increment: tables;
content: "Table " counter(tables) ": ";
}
Every figure in the doc is Figure 1 right now...
Scott Hudson
Content Strategist
Jeppesen
Site: jeppesen.com

Dan
Posts: 368
Joined: Mon Feb 03, 2003 10:56 am

Re: Figure and Table numbering

Post by Dan » Fri Jun 29, 2018 12:46 pm

There are two solutions:

1. You are using the pdf-css-html5 transformation. With this you should get automatically the numbers of the tables before the table titles, with no change in your CSS file. However, I just learned that there is a "com.oxygenxml.html.custom" plugin in the DITA-OT directory that removes the figure numbers. You can delete this plugin from your DITA-OT installation (I recommend to copy the DITA-OT from oXygen to another location where you have write access, then change the DITA-OT directory option from the oXygen preferences).
Important: The numbering works if the figures and tables have titles.

2. Other workaround, using CSS (I would go for this...):

There are two problems in your CSS with the counter reset:
  • You are using the same counter-reset property twice in the CSS rule. The last one will override the first one. One should use a single property and separate the counter reset values with comma.
  • The body element will be replicated in all page sequences, so you will get more counter resets than expected.
Fortunately there are already some counters initialized on the root of the document: figcount and tablecount so you will not to define yours. You can use them like this:

Code: Select all



*[class ~= "topic/fig"] {
counter-increment: figcount;
}

*[class ~= "topic/fig"] figcaption::before {
content: "Figure " counter(figcount) ": ";
}

*[class ~= "topic/table"]{
counter-increment: tablecount;
}

*[class ~= "topic/table"] caption::before {
content: "Table " counter(tablecount) ": ";
}

/* Hide the labels generated by DITA-OT */
.table--title-label,
.figtitleprefix {
display:none;
}
Best regards,
Dan

shudson310
Posts: 133
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: Figure and Table numbering

Post by shudson310 » Fri Jun 29, 2018 4:26 pm

Worked like a charm. As always, you oXygen folks are the best!

Many thanks!
Scott Hudson
Content Strategist
Jeppesen
Site: jeppesen.com

annyjul
Posts: 11
Joined: Fri Mar 02, 2018 12:20 pm

Re: Figure and Table numbering

Post by annyjul » Wed Jul 11, 2018 12:02 pm

Dan wrote:There are two solutions:
...
Fortunately there are already some counters initialized on the root of the document: figcount and tablecount so you will not to define yours. You can use them like this:

Code: Select all



*[class ~= "topic/fig"] {
counter-increment: figcount;
}

*[class ~= "topic/fig"] figcaption::before {
content: "Figure " counter(figcount) ": ";
}

*[class ~= "topic/table"]{
counter-increment: tablecount;
}

*[class ~= "topic/table"] caption::before {
content: "Table " counter(tablecount) ": ";
}

/* Hide the labels generated by DITA-OT */
.table--title-label,
.figtitleprefix {
display:none;
}
Best regards,
Dan
Hi, I'm very sorry for stupid question, but I need figure/table numbering too. I'm still learning dita/oxygen.
Dan, I copy-pasted your code to css file, and linked this file via arg.css to Dita Map Web Help Responsive scenario. Table numbering works, but figures numbering doesn't. What am I missing?

Radu
Posts: 6140
Joined: Fri Jul 09, 2004 5:18 pm

Re: Figure and Table numbering

Post by Radu » Wed Jul 11, 2018 1:40 pm

Hi,

This particular discussion thread is about generating PDF from DITA content using CSS. So you should not use its advice for the WebHelp Responsive output.
Coming back to the WebHelp responsive output, we took the decision not to show numbers for figures for HTML-based output because the numbering is started from "1" for each HTML file which results in the output folder. So if for the first topic in the map you will have Figure 1 and Figure 2, for the second topic you will have again Figure 1 and Figure 2.
So, because for each DITA topic an HTML equivalent is generated, you will not get the numbering to continue from the first topic to the last topic in the publication, like you would when you generate the PDF.
If knowing about this limitation you still want to show the figure count next to the title, I can give you some steps to do that.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

annyjul
Posts: 11
Joined: Fri Mar 02, 2018 12:20 pm

Re: Figure and Table numbering

Post by annyjul » Thu Aug 02, 2018 9:17 am

Radu wrote:Hi,

This particular discussion thread is about generating PDF from DITA content using CSS. So you should not use its advice for the WebHelp Responsive output.
Coming back to the WebHelp responsive output, we took the decision not to show numbers for figures for HTML-based output because the numbering is started from "1" for each HTML file which results in the output folder. So if for the first topic in the map you will have Figure 1 and Figure 2, for the second topic you will have again Figure 1 and Figure 2.
So, because for each DITA topic an HTML equivalent is generated, you will not get the numbering to continue from the first topic to the last topic in the publication, like you would when you generate the PDF.
If knowing about this limitation you still want to show the figure count next to the title, I can give you some steps to do that.

Regards,
Radu
I'm fine with those limitations, but i need numberibg to reference picture ( "as shown in the picture N" ) even If it's for each topic. I export to pdf and web, so I would need to change text of reference specifically for web output.
What so I need to change to get figure numbering in web? Thanks!

Radu
Posts: 6140
Joined: Fri Jul 09, 2004 5:18 pm

Re: Figure and Table numbering

Post by Radu » Tue Aug 07, 2018 1:44 pm

Hi,

Sorry for the delay.
If you edit the Oxygen transformation scenario, in the Parameters list there is a parameter called "args.figurelink.style" which you can set to "NUMTITLE".

https://www.dita-ot.org/2.0/readme/ant- ... types.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

art
Posts: 20
Joined: Fri Nov 14, 2008 8:21 am

Re: Figure and Table numbering

Post by art » Mon Jan 21, 2019 12:20 pm

I made use of Dan's suggestion and added a few lines to my custom css file according to option (2) in his post "There are two solutions:"

Now it appears as though the references to figures and tables starts from "1" with every chapter. For example in the third chapter there is a reference to "figure 1 (on page 57)" which refers to a figure right below the paragraph that has a caption "figure 11: Lorem ipsum". In other words the numbering of the references is reset whereas the numbering of the pictures (and tables) is not reset.

I should like the numberinf of references and pictures/tables to be without reset for the whole publication.

I use a <oXygen/> XML Editor 20.1 build 2018101517, a dita bookmap with multiple chapters and no parts, "PDF (CSS Formatter - HTML5)" transformation, no plugins, no customized DITA-OT, one custom css file (with no other mentioning of figures or tables) that is referenced by parameter args.css, de-de in the root of my bookmap and de-de as a parameter default.language.

Is there a fix that I may apply to the issue?
Best, art

Costin
Posts: 539
Joined: Mon Dec 05, 2011 6:04 pm

Re: Figure and Table numbering

Post by Costin » Tue Jan 22, 2019 11:01 am

Hi,

As we fixed a lot of issues and implemented many improvements in our internal development stream, your issue could have most probably been fixed.
We have nightly builds of a publishing engine that contains the latest Chemistry engine from our development and a custom DITA OT, tailored for it.
If you are interested in giving the publishing engine a try and see if it helps overcoming the issues you currently encountered, please send us an email on support@oxygenxml.com and request access to the latest nightly build of the Oxygen publishing engine.

Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support

Manohar_1024
Posts: 31
Joined: Wed Mar 27, 2019 10:12 am

Re: Figure and Table numbering

Post by Manohar_1024 » Thu Mar 28, 2019 3:17 pm

i am sorry to ask again but the thing is i want figure numbers as 2.1 2.2 2.3 and so on
I got the figures and tables counting but unable to achieve it according to the chapters.like figure 1.2 stamen ,figure 1.3 flower layout
in this manner.
So please help me in this issue

Dan wrote:
Fri Jun 29, 2018 12:46 pm
There are two solutions:

1. You are using the pdf-css-html5 transformation. With this you should get automatically the numbers of the tables before the table titles, with no change in your CSS file. However, I just learned that there is a "com.oxygenxml.html.custom" plugin in the DITA-OT directory that removes the figure numbers. You can delete this plugin from your DITA-OT installation (I recommend to copy the DITA-OT from oXygen to another location where you have write access, then change the DITA-OT directory option from the oXygen preferences).
Important: The numbering works if the figures and tables have titles.

2. Other workaround, using CSS (I would go for this...):

There are two problems in your CSS with the counter reset:
  • You are using the same counter-reset property twice in the CSS rule. The last one will override the first one. One should use a single property and separate the counter reset values with comma.
  • The body element will be replicated in all page sequences, so you will get more counter resets than expected.
Fortunately there are already some counters initialized on the root of the document: figcount and tablecount so you will not to define yours. You can use them like this:

Code: Select all



*[class ~= "topic/fig"] {
counter-increment: figcount;
}

*[class ~= "topic/fig"] figcaption::before {
content: "Figure " counter(figcount) ": ";
}

*[class ~= "topic/table"]{
counter-increment: tablecount;
}

*[class ~= "topic/table"] caption::before {
content: "Table " counter(tablecount) ": ";
}

/* Hide the labels generated by DITA-OT */
.table--title-label,
.figtitleprefix {
display:none;
}
Best regards,
Dan

Costin
Posts: 539
Joined: Mon Dec 05, 2011 6:04 pm

Re: Figure and Table numbering

Post by Costin » Mon Apr 01, 2019 2:42 pm

As it is not clear for us what exactly do you need to achive, you should send us a screenshot from the PDF and paint on it how exactly you expect the figure/table number to appear.
Use support@oxygenxml.com to send the screenshot and the details.

Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support

Manohar_1024
Posts: 31
Joined: Wed Mar 27, 2019 10:12 am

Re: Figure and Table numbering

Post by Manohar_1024 » Wed Apr 03, 2019 12:56 pm

For example the below mentioned one is my figure.
Image
Then the naming should come chapter wise.and follow the deep numbering like
That is like 1.1 Stars in night......
So final output should be like...Fig 2.4 .some information
Fig 2.5 another figure...............
In this way i want labeling under each figure

Dan
Posts: 368
Joined: Mon Feb 03, 2003 10:56 am

Re: Figure and Table numbering

Post by Dan » Tue Apr 09, 2019 9:05 am

Hello,
Currently there is no way of doing this chapter-wise figure and table numbering. I will record a feature request.
Thank you,
Dan

Post Reply