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

subfigure images in docx does not rescale #394

Open ayhy opened 11 months ago

ayhy commented 11 months ago

with subfigGrid=true, following code in html creates auto-rescales image table.

<div id="fig:coolFig"  class="subfigures">
![sample](./Images/ch1/sample.png){#fig:cfquatSample width=25%}
![star](./Images/star.svg){#fig:cfquatStar width=25%}
![star](./Images/star.svg){#fig:cfquatBlueStar width=25%}
![profcat](./Images/Professortocat.png){#fig:cfquatProf width=25%}

![bluestar2](./Images/bluestar.svg){#fig:cfbs}
![profcat2](./Images/Professortocat.png){#fig:cfpc}
![bluestar3](./Images/bluestar.svg){#fig:cfbs2}
![profcat4](./Images/Professortocat.png){#fig:cfpc2}

SVG, pngfiles 25% specified in its row.
</div>

image

However on docx output images retain original size. image

Is there a way to fit image for docx table cell? Regular width specification determines col width and I could not find a way to manually rescale image.

lierdakil commented 11 months ago

Hi. Thanks for the report.

Apparently, Pandoc interprets image widths in docx relative to the page width, regardless of context since 3.0. Well, there is a relatively simple fix for this (hopefully, IIUC what's going on), but I don't have the mental bandwidth to implement it at the moment. Please ping me if I don't get around to it by the end of this week. If you want to make a PR, that'd be even better, I think all that needs to be done is this code here

https://github.com/lierdakil/pandoc-crossref/blob/ef8fcf6709ef44ceb390873a7cc6b7a6ca2fabb3/lib-internal/Text/Pandoc/CrossRef/References/Blocks/Subfigures.hs#L130-L134

needs to set image width to column width instead of 100% when output format is docx. Column widths are in widths defined a few lines above. Let me know if it's something you'd be interested in doing, I can offer a couple more pointers.