mystmd icon indicating copy to clipboard operation
mystmd copied to clipboard

subfigures don't work for latex or typst

Open thesamovar opened this issue 1 year ago • 4 comments

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.

thesamovar avatar Jun 25 '24 23:06 thesamovar

I'm also having issues with this. Unfortunately it makes it impossible to work with subfigures if a pdf is required.

lorenzo-rovigatti avatar Oct 14 '24 21:10 lorenzo-rovigatti

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.

Joecstarr avatar Mar 12 '25 20:03 Joecstarr

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 avatar Mar 13 '25 12:03 rowanc1

@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

Joecstarr avatar Mar 15 '25 01:03 Joecstarr

@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?

Joecstarr avatar May 20 '25 17:05 Joecstarr