Skip to content

Commit 7b32c82

Browse files
committed
fix fig-align=right in latex output
1 parent fcbd784 commit 7b32c82

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
@@ -560,9 +560,15 @@ end, function(float)
560560
})
561561
})
562562
elseif align == "right" then
563-
figure_content:insert(1, quarto.LatexInlineCommand({
564-
name = "hfill",
565-
}))
563+
local plain = quarto.utils.match("[1]/{Plain}")(figure_content)
564+
if plain then
565+
local cmd = quarto.LatexInlineCommand({
566+
name = "hfill",
567+
})
568+
plain[1].content:insert(1, cmd)
569+
else
570+
warn("Could not find a Plain node in figure content of " .. float.identifier .. " to right-align.")
571+
end
566572
end -- otherwise, do nothing
567573
-- figure_content:insert(1, pandoc.RawInline("latex", latexBeginAlign(align)))
568574
-- 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)