diff --git a/news/changelog-1.7.md b/news/changelog-1.7.md index f85d85f9b6..d06b1414cb 100644 --- a/news/changelog-1.7.md +++ b/news/changelog-1.7.md @@ -59,6 +59,7 @@ All changes included in 1.7: - ([#11835](https://github.com/quarto-dev/quarto-cli/issues/11835)): Take markdown structure into account when detecting minimum heading level. - ([#11903](https://github.com/quarto-dev/quarto-cli/issues/11903)): `crossref` configuration like `fig-title` or `tbl-title` now correctly supports multi word values, e.g. `fig-title: 'Supplementary Figure'`. - ([#11878](https://github.com/quarto-dev/quarto-cli/issues/11878), [#12085](https://github.com/quarto-dev/quarto-cli/issues/12085)): Correctly fixup raw LaTeX table having an unexpected table env with options (e.g `\begin{table}[!ht]`) to be handled as crossref table. +- ([#12344](https://github.com/quarto-dev/quarto-cli/issues/12344)): Ensure decorated code blocks do not float when inside layout elements. - Update to Pandoc's LaTeX template following Pandoc 3.6.3 support: - `format: beamer` now uses its own template. The main template for latex does not use `$if(beamer)$` anymore, and the new template for beamer uses the same partials as latex one. - Improved Babel support: diff --git a/src/resources/filters/customnodes/decoratedcodeblock.lua b/src/resources/filters/customnodes/decoratedcodeblock.lua index e996b0a618..5aeefb0a55 100644 --- a/src/resources/filters/customnodes/decoratedcodeblock.lua +++ b/src/resources/filters/customnodes/decoratedcodeblock.lua @@ -95,11 +95,10 @@ _quarto.ast.add_renderer("DecoratedCodeBlock", -- further, otherwise generate the listing div and return it if not param("listings", false) then local listingDiv = pandoc.Div({}) - local position = "" - if _quarto.format.isBeamerOutput() then - -- Adjust default float positionment for beamer (#5536) - position = "[H]" - end + -- Adjust default float positionment for beamer (#5536) + -- Adjust default float positionment for code blocks that request it (#12344) + local needs_hold = _quarto.format.isBeamerOutput() or node.hold + local position = needs_hold and "[H]" or "" listingDiv.content:insert(pandoc.RawBlock("latex", "\\begin{codelisting}" .. position)) local captionContent = node.caption diff --git a/src/resources/filters/customnodes/panellayout.lua b/src/resources/filters/customnodes/panellayout.lua index 6ba5cadfbd..0a48422a06 100644 --- a/src/resources/filters/customnodes/panellayout.lua +++ b/src/resources/filters/customnodes/panellayout.lua @@ -89,8 +89,23 @@ _quarto.ast.add_handler({ -- construct a minimal rows-cells div scaffolding -- so contents are properly stored in the cells slot + -- #12344: if there are decoratedcodeblocks inside the layout, + -- we need to ask them to render themselves as [H] or we'll get outer par mode errors. + local layout = tbl.layout + if quarto.format.isLatexOutput() then + layout = pandoc.List(tbl.layout):map(function(lst) + return pandoc.List(lst):map(function(cell) + return _quarto.ast.walk(cell, { + DecoratedCodeBlock = function(decorated) + decorated.hold = true + return decorated + end + }) + end) + end) + end local rows_div = pandoc.Div({}) - for i, row in ipairs(tbl.layout) do + for i, row in ipairs(layout) do local row_div = pandoc.Div(row) if tbl.is_float_reftarget then row_div = _quarto.ast.walk(row_div, { diff --git a/tests/docs/smoke-all/2025/03/21/issue-12344.qmd b/tests/docs/smoke-all/2025/03/21/issue-12344.qmd new file mode 100644 index 0000000000..6af00bd780 --- /dev/null +++ b/tests/docs/smoke-all/2025/03/21/issue-12344.qmd @@ -0,0 +1,37 @@ +--- +format: + pdf: + keep-tex: true +--- + +::: {layout-ncol="2" .column-page-right} +``` {.markdown filename="01-import.qmd"} +--- +title: Data Import and Cleaning +author: Soraya Drake +format: + html: + toc: true + code-fold: true +--- + +## Import + +... +``` + +``` {.markdown filename="02-visualization.qmd"} +--- +title: Exploratory Visualization +author: Soraya Drake +format: + html: + toc: true + code-fold: true +--- + +## Distributions + +... +``` +::: \ No newline at end of file