Skip to content

Commit 46fd3c6

Browse files
authored
Merge pull request #8736 from quarto-dev/bugfix/8733
fix fig-align=right in latex output
2 parents 6e3dd66 + 7b32c82 commit 46fd3c6

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/resources/filters/customnodes/floatreftarget.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,15 @@ end, function(float)
568568
})
569569
})
570570
elseif align == "right" then
571-
figure_content:insert(1, quarto.LatexInlineCommand({
572-
name = "hfill",
573-
}))
571+
local plain = quarto.utils.match("[1]/{Plain}")(figure_content)
572+
if plain then
573+
local cmd = quarto.LatexInlineCommand({
574+
name = "hfill",
575+
})
576+
plain[1].content:insert(1, cmd)
577+
else
578+
warn("Could not find a Plain node in figure content of " .. float.identifier .. " to right-align.")
579+
end
574580
end -- otherwise, do nothing
575581
-- figure_content:insert(1, pandoc.RawInline("latex", latexBeginAlign(align)))
576582
-- figure_content:insert(pandoc.RawInline("latex", latexEndAlign(align)))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "Quarto Testfile"
3+
format: latex
4+
_quarto:
5+
tests:
6+
latex:
7+
ensureFileRegexMatches:
8+
- ["\\\\hfill\\\\includegraphics"]
9+
- []
10+
---
11+
12+
# Test alignment to the right
13+
14+
![dummy image](test_image_r.jpg){#fig-logor fig-align="right" width=4in}

0 commit comments

Comments
 (0)