-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for wrapfigure #376
Comments
This is a great suggestion and something that we'll plan on supporting in the future. Thanks! |
When a supplemental file is contributed to a render, it can now includes foramts that go along with it (so that it won’t be forced to render in an unsupported format). For example, when a listing gets added to the render of a revealjs document, it still needs to render as an html document rather than as a revealjs presentation. #376
When a supplemental file is contributed to a render, it can now includes foramts that go along with it (so that it won’t be forced to render in an unsupported format). For example, when a listing gets added to the render of a revealjs document, it still needs to render as an html document rather than as a revealjs presentation. #376
When a supplemental file is contributed to a render, it can now includes foramts that go along with it (so that it won’t be forced to render in an unsupported format). For example, when a listing gets added to the render of a revealjs document, it still needs to render as an html document rather than as a revealjs presentation. #376
Just for reference and in case you want to take this even further: With html / css text can also wrap text around the outlines of a transparent png, which I used in this quarto-made scientific poster: https://hits-mbm-dev.github.io/paper-talin-loop/poster.html |
Is there a way to do this with PDF (via RStudio IDE)? Using 'float', it looks ok in the visual editor, but not when rendered... I copied syntax from hello.qmd, which also doesn't render correctly in PDF (which I discovered later...). |
No, this is a feature of html and css. There may be a LaTeX package that does something similar for pdf but I am no export on TeX. |
Any progress on this? It would be very useful to be able to wrap figures in PDF files for e.g. grant applications and other reports where pages are limited. |
An open issue means it's still planed. Note that you can add a reaction on the main post to show your interest. Anyhow, thanks for your interest in this issue and Quarto! |
As this is the first thing that shows up when searching for "quarto wrapfigure", I thought it might be helpful to share a workaround to get code block plots to be behave as a wrapfigure for Latex PDF output. I wrote a small lua filter to temporarily redefine the figure environment when the Click to see code and exampleLua filter:if FORMAT:match 'latex' then
function Div(elem)
-- Check if this div has wrapfigure attribute
if elem.attributes and elem.attributes["wrapfigure"] then
local wrap_pos, wrap_width = elem.attributes["wrapfigure"]:match("^%s*(%S+)%s+(%S+)%s*$")
if wrap_pos == nil or wrap_width == nil then
io.stderr:write("Error: wrapfigure attribute must be of the form 'pos width', e.g. 'R 0.5'. Found: '" .. elem.attributes["wrapfigure"] .. "'\n")
return elem
end
return {
pandoc.RawInline('latex', '\\let\\oldfigure\\figure\n\\let\\endoldfigure\\endfigure\n\\renewenvironment{figure}{}{}\n\\begin{wrapfigure}{' .. wrap_pos.. '}{' .. wrap_width .. '\\textwidth}\\centering\\captionsetup{format=plain, labelformat=simple}'),
elem,
pandoc.RawInline('latex', '\\end{wrapfigure}\\let\\figure\\oldfigure\n\\let\\endfigure\\endoldfigure')
}
end
return elem
end
end Save this somewhere (e.g. under
Usage:
Here |
That's a good workaround, thanks for sharing! I'll note here that Quarto does support @gordonwoodhull Do you think we could add something like https://sitandr.github.io/typst-examples-book/book/packages/wrapping.html to our Typst renderer? I would be happy with shipping native
|
That’s a good idea. They mentioned on the community call that Typst is adding built-in support for wrapping text around images soon. So if we add a dependency we should also plan to remove it soon. |
Did you get a sense of what "soon" meant? If it's 0.13-ish, then we probably want to wait for them. If not, then we should do what you suggested instead. |
They were using words that sounded like “next release” but I wouldn’t want to bank on it because I know how software works. I think it involves some more ambitious layouts than just this feature. |
I've been working on solving this problem with a Quarto plugin: multimeric/fwrappe. Currently only HTML and PDF/LaTeX are supported but I would welcome a typst implementation. I do ultimately think this logic should live in quarto core because it's so fundamental, so I'm happy to contribute my code and be involved in discussions relating to that. I've written some technical docs that might be helpful for such an implementation. It's quite a tricky problem in LaTeX that won't have an easy solution. Mine is just scratching the surface. |
@multimeric I agree, and we'd love to take your contribution! Do you want to start a PR? How can we help? |
I assume this doesn't make sense as a Quarto feature until all the output formats are supported (correct me if this is not true), which means it can't be done incrementally. This is why I did it as an extension. On the other hand, extensions aren't really "powerful" enough to do this feature well, because they don't have access to all the lifecycle hooks (see #11749 and #11750), and also they don't have access to the much more extensive internal lua API. So I'm not sure the best way to proceed. |
We have a number of features that don't span across all formats. We prefer many- or all-format features, but formats are different from each other for good reasons, and so we don't hold this too strongly. In addition, the rendering of a wrapfigure can degrade gracefully into a regular figure + warning. I think HTML + LaTeX is a good minimal version that I'd be happy to merge. If we supported Typst that would be even nicer; there's some public-domain code to start from. |
I have some use case where I need the figure to be wrapped within the text.
I can achieve this with:
but it would be very handy to have it natively supported for both HTML and pdf output.
HTML could simple use
float
css property.The text was updated successfully, but these errors were encountered: