Skip to content

Commit b130aac

Browse files
authored
Merge pull request #3853 from quarto-dev/fix/theorem-vertical-space
Remove id on theorems Divs so that Pandoc does not insert raw Latex for us
2 parents 84a9714 + 2c47b1b commit b130aac

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

news/changelog-1.3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- Add support for automatically converting SVG images to PDF ([#2575](https://github.com/quarto-dev/quarto-cli/issues/2575))
3737
- Previously, if the `pdf-engine` was set to `latexmk`, we would bypass many features of Quarto and use Pandoc to produce the PDF output. Starting in in Quarto 1.3, all Quarto features will be enabled for the `latexmk` engine and `latexmk` will be used to run the PDF generation loop.
3838
- Fix author processing in default PDFs for complex author names (#3483)
39+
- Remove excessive vertical space between theorem type blocks ([#3776](https://github.com/quarto-dev/quarto-cli/issues/3776)).
3940

4041
## Beamer Format
4142

src/resources/filters/crossref/theorems.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ function crossrefTheorems()
6363
end
6464
preamble.content:insert(pandoc.RawInline("latex", "]"))
6565
preamble.content:insert(pandoc.RawInline("latex",
66-
"\\label{" .. label .. "}")
66+
"\\protect\\hypertarget{" .. label .. "}{}\\label{" .. label .. "}")
6767
)
6868
el.content:insert(1, preamble)
6969
el.content:insert(pandoc.Para(pandoc.RawInline("latex",
7070
"\\end{" .. theoremType.env .. "}"
7171
)))
72+
-- Remove id on those div to avoid Pandoc inserting \hypertaget #3776
73+
el.attr.identifier = ""
7274
elseif _quarto.format.isJatsOutput() then
7375

7476
-- JATS XML theorem

tests/smoke/crossref/latex.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,22 @@ const subTableRegexes = [
3232
];
3333

3434
const theoremRegexes = [
35-
/\\begin{theorem}[^]*?\\label{thm-line}[^]*?\\end{theorem}/,
35+
/\\begin{theorem}[^]*?\\protect\\hypertarget{thm-line}{}\\label{thm-line}[^]*?\\end{theorem}/,
3636
/Theorem~\\ref{thm-line}/,
3737
];
3838

39+
const theoremRegexesNo = [
40+
/\\leavevmode\\vadjust pre{\\hypertarget{thm-line}{}}%/,
41+
];
42+
3943
testRender(allQmd.input, "latex", true, [
4044
ensureFileRegexMatches(allQmd.output.outputPath, [
4145
...simpleFigRegexes,
4246
...subFigRegexes,
4347
...simpleTableRegexes,
4448
...subTableRegexes,
4549
...theoremRegexes,
50+
], [
51+
...theoremRegexesNo,
4652
]),
4753
]);

0 commit comments

Comments
 (0)