Skip to content

Commit 97ee0ae

Browse files
authored
Merge pull request #12353 from quarto-dev/bugfix/12344
latex,lua,decoratedcodeblock - force [H] when inside a layout (#12344)
2 parents 09fc49f + d704e17 commit 97ee0ae

4 files changed

Lines changed: 58 additions & 6 deletions

File tree

news/changelog-1.7.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ All changes included in 1.7:
5959
- ([#11835](https://github.com/quarto-dev/quarto-cli/issues/11835)): Take markdown structure into account when detecting minimum heading level.
6060
- ([#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'`.
6161
- ([#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.
62+
- ([#12344](https://github.com/quarto-dev/quarto-cli/issues/12344)): Ensure decorated code blocks do not float when inside layout elements.
6263
- Update to Pandoc's LaTeX template following Pandoc 3.6.3 support:
6364
- `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.
6465
- Improved Babel support:

src/resources/filters/customnodes/decoratedcodeblock.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,10 @@ _quarto.ast.add_renderer("DecoratedCodeBlock",
9595
-- further, otherwise generate the listing div and return it
9696
if not param("listings", false) then
9797
local listingDiv = pandoc.Div({})
98-
local position = ""
99-
if _quarto.format.isBeamerOutput() then
100-
-- Adjust default float positionment for beamer (#5536)
101-
position = "[H]"
102-
end
98+
-- Adjust default float positionment for beamer (#5536)
99+
-- Adjust default float positionment for code blocks that request it (#12344)
100+
local needs_hold = _quarto.format.isBeamerOutput() or node.hold
101+
local position = needs_hold and "[H]" or ""
103102
listingDiv.content:insert(pandoc.RawBlock("latex", "\\begin{codelisting}" .. position))
104103

105104
local captionContent = node.caption

src/resources/filters/customnodes/panellayout.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,23 @@ _quarto.ast.add_handler({
8989
-- construct a minimal rows-cells div scaffolding
9090
-- so contents are properly stored in the cells slot
9191

92+
-- #12344: if there are decoratedcodeblocks inside the layout,
93+
-- we need to ask them to render themselves as [H] or we'll get outer par mode errors.
94+
local layout = tbl.layout
95+
if quarto.format.isLatexOutput() then
96+
layout = pandoc.List(tbl.layout):map(function(lst)
97+
return pandoc.List(lst):map(function(cell)
98+
return _quarto.ast.walk(cell, {
99+
DecoratedCodeBlock = function(decorated)
100+
decorated.hold = true
101+
return decorated
102+
end
103+
})
104+
end)
105+
end)
106+
end
92107
local rows_div = pandoc.Div({})
93-
for i, row in ipairs(tbl.layout) do
108+
for i, row in ipairs(layout) do
94109
local row_div = pandoc.Div(row)
95110
if tbl.is_float_reftarget then
96111
row_div = _quarto.ast.walk(row_div, {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
format:
3+
pdf:
4+
keep-tex: true
5+
---
6+
7+
::: {layout-ncol="2" .column-page-right}
8+
``` {.markdown filename="01-import.qmd"}
9+
---
10+
title: Data Import and Cleaning
11+
author: Soraya Drake
12+
format:
13+
html:
14+
toc: true
15+
code-fold: true
16+
---
17+
18+
## Import
19+
20+
...
21+
```
22+
23+
``` {.markdown filename="02-visualization.qmd"}
24+
---
25+
title: Exploratory Visualization
26+
author: Soraya Drake
27+
format:
28+
html:
29+
toc: true
30+
code-fold: true
31+
---
32+
33+
## Distributions
34+
35+
...
36+
```
37+
:::

0 commit comments

Comments
 (0)