From 174e9ac3a7eea98a368bceeccacb4e7d60a2054b Mon Sep 17 00:00:00 2001 From: Charles Teague Date: Tue, 5 Sep 2023 15:26:42 -0400 Subject: [PATCH] Pandoc 3.1.7 outputs label, so omit this https://github.com/jgm/pandoc/issues/9045 --- src/resources/filters/crossref/equations.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/resources/filters/crossref/equations.lua b/src/resources/filters/crossref/equations.lua index 2caa9ed3afc..4f202b24e70 100644 --- a/src/resources/filters/crossref/equations.lua +++ b/src/resources/filters/crossref/equations.lua @@ -46,7 +46,17 @@ function process_equations(blockEl) if _quarto.format.isLatexOutput() then targetInlines:insert(pandoc.RawInline("latex", "\\begin{equation}")) targetInlines:insert(pandoc.Span(pandoc.RawInline("latex", eq.text), pandoc.Attr(label))) - targetInlines:insert(pandoc.RawInline("latex", "\\label{" .. label .. "}\\end{equation}")) + + -- Pandoc 3.1.7 started outputting a shadow section with a label as a link target + -- which would result in two identical labels being emitted. + -- https://github.com/jgm/pandoc/issues/9045 + -- https://github.com/lierdakil/pandoc-crossref/issues/402 + if PANDOC_VERSION >= pandoc.types.Version("3.1.7") then + targetInlines:insert(pandoc.RawInline("latex", "\\end{equation}")) + else + targetInlines:insert(pandoc.RawInline("latex", "\\label{" .. label .. "}\\end{equation}")) + end + elseif _quarto.format.isTypstOutput() then targetInlines:insert(pandoc.RawInline("typst", "#set math.equation(numbering: \"(" .. inlinesToString(numberOption("eq", order)) .. ")\"); " ..