Skip to content

Commit

Permalink
Merge pull request #7341 from quarto-dev/bugfix/7334
Browse files Browse the repository at this point in the history
Lua: warn and remove floatreftargets from LaTeX callouts
  • Loading branch information
cscheid authored Oct 24, 2023
2 parents 14b2b6d + e9845ed commit 452eea6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/resources/filters/layout/latex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ function latexFigurePosition(el, env)
if env == kMarginFigureEnv then
return attribute(el, kOffset, nil)
else
return attribute(el, kFigPos, nil)
local prefix = refType(el.identifier) or "fig"
return attribute(el, prefix .. "-pos", nil)
end
end

Expand Down
18 changes: 16 additions & 2 deletions src/resources/filters/quarto-post/latex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,19 @@ function render_latex()
-- require special handling
local hasVerbatimInNotes = false
local noteContents = {}
local nodeContent = node.content:walk({
local lifted_contents = pandoc.Blocks({})

local nodeContent = _quarto.ast.walk(node.content, {
traverse = "topdown",
FloatRefTarget = function(float, float_node)
if float.identifier ~= nil then
local ref = refType(float.identifier)
if ref ~= nil then
float.attributes[ref .. "-pos"] = "H"
return float
end
end
end,
Note = function(el)
tappend(noteContents, {el.content})
el.content:walk({
Expand Down Expand Up @@ -235,7 +247,7 @@ function render_latex()
local endEnvironment = callout.endInlines
local calloutContents = callout.contents
if calloutContents == nil then
calloutContents = pandoc.List({})
calloutContents = pandoc.Blocks({})
end

if lua_type(nodeContent) == "table" then
Expand Down Expand Up @@ -270,6 +282,8 @@ function render_latex()
end
tappend(calloutContents, v)
end

calloutContents:extend(lifted_contents)

-- Enable fancyvrb if verbatim appears in the footnotes
if hasVerbatimInNotes then
Expand Down
19 changes: 19 additions & 0 deletions tests/docs/smoke-all/2023/10/24/7334.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "table in a div"
format:
html: default
pdf: default
---
Table in a div

::: callout-tip
```{r, echo=FALSE, message=FALSE, warning=FALSE}
#| label: tbl-table1
#| tbl-cap: "A table"
library(tidyverse)
table <- tribble(~a, ~b, ~c,
"text", 1, "Long text",
"others", 2, "Long text")
knitr::kable(table)
```
:::

0 comments on commit 452eea6

Please sign in to comment.