mystmd
mystmd copied to clipboard
subfigures don't work for latex or typst
For latex, it creates a figure environment within a figure environment which isn't supported. For typst, it sort of works but it creates a figure n for the whole figure, figure n+1 for the first subfigure, n+2 for the second, etc.
I'm also having issues with this. Unfortunately it makes it impossible to work with subfigures if a pdf is required.
It looks like it shouldn't be to hard to edit myst-to-tex/src/container.ts so that it uses subfigures from the subcaption package.
I don't know enough about templating yet, would that approach break existing templates? From what I can tell no the myst-to-tex library seems to have some control over the preamble.
You can insert into the imports/macros inside those functions, yes. If you are up for a PR, ideally that gets the test cases going, that would be the most helpful to move this forward! I can give a bit more direction if helpful on how to get started with adding to this area of the code base.
@rowanc1 I would be happy to take a stab. I'll take a look at the contribution guidelines. Might take me a while to get around to it, probably not until after my defense (~June). If someone else gets to it first good with me.
For anyone who sees this, right now my work around is a post processing script. I'm tagging around the markdown figures with comments then replacing the resulting latex figure tags with subfigure tags and the comments with latex \begin{figure} and \end{figure}.
<!-- @@@-subfigure-start-@@@ -->
```{figure} ./media/bands/bnd_sum_1.svg
:label: UC-N-APN-E-4
:align: center
@@@ TODO
```
```{figure} ./media/bands/bnd_sum_2.svg
:label: UC-N-APN-E-4
:align: center
@@@ TODO
```
<!-- @@@-subfigure-end-@@@ -->
Here's my quick and dirty script: https://gist.github.com/Joecstarr/ddb4aeec2d22d884e5ceaa6b79f4c8a3
@rowanc1 I have a little more time now that the semester is over. Do you have anything I can read to get going on this?