pandoc-crossref icon indicating copy to clipboard operation
pandoc-crossref copied to clipboard

subfigure images in docx does not rescale

Open ayhy opened this issue 2 years ago • 1 comments

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.

ayhy avatar Jul 31 '23 19:07 ayhy

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.

lierdakil avatar Jul 31 '23 21:07 lierdakil