lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
911 stars 72 forks source link

Are there two separate figure/table numbering schemes for docx output? #353

Closed mhoban closed 2 years ago

mhoban commented 2 years ago

I'm trying to implement the main/supplemental numbering scheme as suggested in #35. It seems to mostly do what want it to, however there's some strange behavior when outputting to docx format (which is my primary output format). It seems that there are two separate numbering schemes, one for every figure/table, and one including the chapter label ("S" in this case). For all figures and tables, the first one is automatically included regardless of what I set figureTemplate/tableTemplate to. All in-text citations work as expected.

So, for example, if I have two primary figures, two supplementary figures, one primary table, and one supplemental table, the captions end up looking like this (with default template values):

Table 1: Table 1: tbl1 caption

Figure 1: Figure 1: fig 1 caption

Figure 2: Figure 2: fig 2 caption

Table 2: Table S1: tbl s1 caption

Figure 3: Figure S1: fig s1 caption

Figure 4: Figure S2: fig s2 caption

Regardless of how I set figureTemplate and tableTemplate, I can't get that first "Figure/Table XXX" to be suppressed. Am I missing something? Is the docx output doing its own numbering independent of the pandoc-crossref numbering?

I can suppress the double "Figure xxx: Figure xxx" output by setting the figure/tableTemplate to just $$t$$ but then I end up with the wrong numbering scheme, because it's the one that's just sequential. Which is to say, the sequential "Figure/Table XXX: " prefix seems to be included no matter what.

Here's the test document I'm using:

---
chapters: True
chaptersDepth: 1
chapDelim: ""
---

# Methods {-}

Lorem ipsum dolor sit amet, consectetur adipiscing elit ([@fig:figure1; @tbl:table1]).

something more ([@fig:figure2; @tbl:tableS1]).

# Results {-}

Etiam cursus dictum dui; id condimentum ([@fig:figureS1; @fig:figureS2]).

# Discussion {-}

Quisque finibus enim est, quis placerat turpis volutpat at.

# Figures & Tables {-}

| main | table | header | nothing | doing |
|------|-------|--------|---------|-------|
| row  | one   | two    | three   | four  |
| row  | two   | three  | four    | five  |

: This is a table in the main section {#tbl:table1}

![this is the first figure](tmp/a.jpg){#fig:figure1}

![this is the second figure](tmp/b.jpg){#fig:figure2}

# Supplementary Material {label="S"}

| supplemental | table | header | nothing | doing |
|------|-------|--------|---------|-------|
| row  | one   | two    | three   | four  |
| row  | two   | three  | four    | five  |

: This is a table in the supplemental section {#tbl:tableS1}

![this is the first supplemental figure](tmp/x.jpg){#fig:figureS1}

![this is the second supplemental figure](tmp/y.jpg){#fig:figureS2}
mhoban commented 2 years ago

Whoops, look like this is fixed in 2.18.