From de14b69f3d72bfb9fe7ae280e3eee96e89289302 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Wed, 29 Nov 2023 09:10:27 -0700 Subject: [PATCH] fix typst equation handling --- src/resources/filters/crossref/equations.lua | 8 +++++--- tests/docs/smoke-all/2023/11/29/7744.qmd | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/docs/smoke-all/2023/11/29/7744.qmd diff --git a/src/resources/filters/crossref/equations.lua b/src/resources/filters/crossref/equations.lua index c3ac0c1a1ab..e4693a8eae3 100644 --- a/src/resources/filters/crossref/equations.lua +++ b/src/resources/filters/crossref/equations.lua @@ -54,10 +54,12 @@ function process_equations(blockEl) targetInlines:insert(pandoc.RawInline("latex", "\\end{equation}")) elseif _quarto.format.isTypstOutput() then + local is_block = eq.mathtype == "DisplayMath" and "true" or "false" targetInlines:insert(pandoc.RawInline("typst", - "#set math.equation(numbering: \"(" .. inlinesToString(numberOption("eq", order)) .. ")\"); " .. - "$ " .. eq.text .. " $ <" .. label .. "> #set math.equation(numbering: none)" - )) + "#math.equation(block: " .. is_block .. ", numbering: \"(" .. inlinesToString(numberOption("eq", order)) .. ")\", " .. + "[ ")) + targetInlines:insert(eq) + targetInlines:insert(pandoc.RawInline("typst", " ])<" .. label .. ">")) else local eqNumber = eqQquad local mathMethod = param("html-math-method", nil) diff --git a/tests/docs/smoke-all/2023/11/29/7744.qmd b/tests/docs/smoke-all/2023/11/29/7744.qmd new file mode 100644 index 00000000000..b2bfabf85e6 --- /dev/null +++ b/tests/docs/smoke-all/2023/11/29/7744.qmd @@ -0,0 +1,17 @@ +--- +title: issue-7744 +format: typst +keep-typ: true +--- + +$$ +\begin{aligned} +\frac{dS_1}{dt} &= -\frac{\rho \beta S_1(c_{11} I_1 + c_{12} I_2)}{N} \\ +\frac{dS_2}{dt} &= -\frac{\beta S_2(c_{12} I_1 + c_{22} I_2)}{N} \\ +\frac{dI_1}{dt} &= \frac{ \rho \beta S_1(c_{11} I_1 + c_{12} I_2)}{N} - \gamma I_1 \\ +\frac{dI_2}{dt} &= \frac{\beta S_2(c_{12} I_1 + c_{22} I_2)}{N} - \gamma I_2 \\ +\frac{dR_1}{dt} &= \gamma I_1 \\ +\frac{dR_2}{dt} &= \gamma I_2 +\end{aligned} +$$ {#eq-model} +