lierdakil / pandoc-crossref

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

How to include a listing as a subfigure in a figure? #423

Open charmoniumQ opened 5 months ago

charmoniumQ commented 5 months ago

Is it possible to create a subfigure grid, where one of the cells of the grid is a code listing? The following snippet doesn't quite do the trick. The listing does not get a label or a caption and the fourth subfigure gets labeled "c".

<div id="fig:prov">
![Application-level prov](app-lvl-prov.svg){#fig:app-lvl-prov width=24%}
![Workflow-level prov](wf-lvl-prov.svg){#fig:wf-lvl-prov width=24%}
```{#lst:sys-lvl-log caption="Sys-level log" width=24%}
read A
write B
read C
write D
write E
```
![System-level prov](sys-lvl-prov.svg){#fig:sys-lvl-prov width=24%}

Several provenance graphs collected at different levels.
</div>
lierdakil commented 5 months ago

Yeah, unfortunately subfigures only work for figures as Pandoc understands them, that is, images. There are a few reasons for that, the main one being pdf/latex needs quite a few hacks to handle heterogenous subfloats, and even with the hacks it's wonky. In terms of workarounds, the best I can suggest at the moment is to write the listing to an SVG and use that.