Skip to content

Commit

Permalink
🔽 Add typst captions for subfigures (#1613)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Oct 30, 2024
1 parent 3ce5404 commit dd4569b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-fans-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"myst-to-typst": patch
---

Add captions for sub figures
6 changes: 3 additions & 3 deletions packages/myst-to-typst/src/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ export const containerHandler: Handler = (node, state) => {
state.useMacro('#import "@preview/subpar:0.1.1"');
state.write(`#show figure: set block(breakable: ${allSubFigs ? 'false' : 'true'})\n`);
state.write('#subpar.grid(');
let columns = 2;
let columns = nonCaptions.length <= 3 ? nonCaptions.length : 2; // TODO: allow this to be customized
nonCaptions.forEach((item: GenericNode) => {
if (item.type === 'container') {
state.write('figure(\n');
state.renderChildren(item);
state.write('\n),');
state.write('\n, caption: []),'); // TODO: add sub-captions
if (item.identifier) {
state.write(` <${item.identifier}>,`);
}
Expand All @@ -117,7 +117,7 @@ export const containerHandler: Handler = (node, state) => {
columns = 1;
}
});
state.write(`columns: (${Array(columns).fill('1fr')}),\n`);
state.write(`columns: ${columns},\n`);
if (label) {
state.write(`label: <${label}>,`);
label = undefined;
Expand Down

0 comments on commit dd4569b

Please sign in to comment.