Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docx writer: Customizable figure and table caption for docx output #7451

Open
memyr opened this issue Jul 21, 2021 · 7 comments
Open

Docx writer: Customizable figure and table caption for docx output #7451

memyr opened this issue Jul 21, 2021 · 7 comments

Comments

@memyr
Copy link

memyr commented Jul 21, 2021

For the 2.14.1 release that included changes to the Docx writer, which adds fields with numbering for figures and tables (a3d745e), the outputted Docx figures and tables with captions appear to have the following prepended to the captions:
Figure #: (caption) and Table #: (caption)

Is there a way to make this prepended text customizable so we can have:
Figure S#: (caption) or Fig. #: (caption) or Figure #: (caption)?

I've tried changing this with numbering the table/image caption style in the custom-reference Docx, but then I end up with:
[custom numbering] Figure #: (caption)

Thank you!

@jgm
Copy link
Owner

jgm commented Jul 21, 2021

Table numbers were changed in 0948af9 to use Word's numbering system, so they ought to be customizable using the mechanisms in Word.
We just need to do something similar with figure numbers.

@jgm
Copy link
Owner

jgm commented Jul 21, 2021

Well, maybe this isn't enough for what you want. I guess we're hard-coding that the numbers are ARABIC. It would be better to make this adjustable in a style, but I don't know how to do this. Even if they were adjustable, Word doesn't offer a sequence number like S#.

You can mess with translations data files to make the translation for Figure "Figure S", but you'll get a space between "S" and #, so probably not what you want.

You can make the whole caption boldface with the Caption style, but again probably not what you want.

You might be expecting a degree of customization that goes beyond what we can easily provide.

@memyr
Copy link
Author

memyr commented Jul 21, 2021

Thanks for your reply. In that case, I might either 1) use an older version of pandoc that doesn't insert the hardcoded text so it just uses the image/table caption numbering format from my reference.docx (this would lose the ability to insert a table of figures, which is fine in my case) or 2) just post process the word doc with a find and replace.

I appreciate your time!

@jgm
Copy link
Owner

jgm commented Jul 21, 2021

How do you customize the caption numbering format in your reference.docx?

@memyr
Copy link
Author

memyr commented Jul 21, 2021

I have used the Numbering options when modifying the style in the reference.docx:
Modify Style > Format > Numbering...
Screen Shot 2021-07-21 at 2 00 12 PM
Choose one of the outline numbered styles > Customize...
Screen Shot 2021-07-21 at 1 45 47 PM
Then edit it for whatever:
Screen Shot 2021-07-21 at 1 46 55 PM
With pandoc 2.12, The output looks okay I think:
Screen Shot 2021-07-21 at 1 57 14 PM
But with 2.14.1, the extra "Figure #:" is added:
Screen Shot 2021-07-21 at 1 59 15 PM

Either way, I technically have to post process the docx files because any references to the figures still show up as "see Figure 1" since the S isn't really part of the figure number.

@chrisgrieser
Copy link

Up until now, I was using pandoc-crossref for the figure numbering. While I think the support for automatic numbering in docx are a great addition, I am not entirely sure how to do the referencing to figures now. 2.14.1 creates a dilemma:

  • Either I use pandoc-crossref and I am able to reference figures from the text via @fig:label. However now with pandoc 2.14.1, using pandoc-crossref (or pandoc-fignos, for that matter), will result in double figure numbers (see image below).
  • Or I omit using crossref and fignos for docx as output format, as I get figure numbering already. But in that case, I loose the ability to reference an image from inline with automatically determined number, which was (one half of) the reason for using pandoc-crossref in the first place.

Screenshot 2021-08-15 21 43 53

Or am I mistaken and you can reference a figure with its future number when writing? If the dilemma as I state it here is indeed correct, an options to suppress automatic figure/table numbering would indeed be useful to be able to use docx writer with crossref/fignos; maybe as an extension?

@jgm
Copy link
Owner

jgm commented Aug 15, 2021

See #7499. In the commit I just pushed, native_numbering is made applicable to docx, and turned off by default. This should restore the pre 2.14.1 behavior, unless you explicitly specify -t docx+native_numbering. (Just as with odt.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants