Health-Sprints / A-Machine

A-Machine
GNU General Public License v3.0
1 stars 0 forks source link

Consecutive numbering across a book: images, tables #8

Open mrchristian opened 3 years ago

mrchristian commented 3 years ago

Consecutive numbering across a book: If you need consecutive numbering within a whole book, the numbering has to be processed before generating final (X)HTML files, without using CSS counters. Or use per-chapter numbering, e.g., "Figure 2.3" for the 3rd figure in Chapter 2. In this case, the figure number in a chapter can be get with CSS counter. However, using CSS counter for such numbering will not be a good option when creating lists at back of the book because the CSS target-counter function works only within an HTML file.

Images, tables, listings at back of boo.k

mrchristian commented 3 years ago

Note from Shinyu:

If you use CSS counters (although not recommended for multiple files), it can be done using CSS counters with different counter names per HTML class attribute on images and tables, and also can exclude certain images/tables and reset with CSS counter-reset.

mrchristian commented 3 years ago

Note: Fidus Writer has categories for Images and Tables that do not get included in the consecutive numbering issue https://github.com/Health-Sprints/obp/issues/1

MurakamiShinyu commented 3 years ago

Consecutive numbering across a book: If you need consecutive numbering within a whole book, the numbering has to be processed before generating final (X)HTML files, without using CSS counters. Or use per-chapter numbering, e.g., "Figure 2.3" for the 3rd figure in Chapter 2. In this case, the figure number in a chapter can be get with CSS counter. However, using CSS counter for such numbering will not be a good option when creating lists at back of the book because the CSS target-counter function works only within an HTML file.

Sorry my mistake. Let me correct the last sentense: "the CSS target-counter function works only within an HTML file" is not true. I realized that the target-counter works in multi-HTML webbook with Vivliostyle.

For example, when a figure with id="figfoo" is in chapter2.html and another HTML file has a link to that figure, <a class="figref" href="chapter2.html#figfoo">Foo</a>, and in the stylesheet:

a.figref::after {
  content: " (Figure " target-counter(attr(href url), chapno) "." target-counter(attr(href url), figno) ", p. " target-counter(attr(href url), page) ")"; 
}

The result will be, e.g., "Foo (Figure 2.3, p. 45)".

This works with Vivliostyle. However, limitations still remain. Consecutive numbering across a book is not possible, and the chapter counter, chapno in this example, cannot be automatically incremented at beginning of each chapter HTML file (The chapter number has to be set in each chapter HTML file, e.g. <html style="counter-reset: chapno 2"> in chapter2.html).