wrapped extension: wrap text around figures and tables in HTML, PDF, and Word
#15241
jmgirard
started this conversation in
Show and Tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Wrapping body text around a figure has come up here several times: #376, #4541 and #11053. For PDF you can write a raw
wrapfigure, but that does nothing in HTML or Word, and the figure loses Quarto's caption and cross-reference handling.wrapped is a filter extension for this. You add a class to a figure, and each output format draws the wrap with its own tools:
breakpointkey changes this).The figure keeps its number, its caption, and its
@fig-links. In other formats, such as EPUB, a wrapped figure renders as a normal figure, and the render prints one warning.Install it in your project:
Then turn on the filter:
Add
.wrap-rightor.wrap-leftto a figure:The paragraphs after the figure flow beside it. Wrapping stops at the next block that is not a paragraph, such as a heading or a list, or earlier at an empty
::: {.wrap-clear}div.It also wraps:
#| classes: wrap-right, with#| out-width:and#| wrap-gap:;#tbl-table floats, code cell tables included (#| width:,#| wrap-gap:), and gt and flextable tables in Word.widthandwrap-gapattributes set the size and the space beside the text. Document or project defaults go under thewrapped:key.Limits: a figure in a place that cannot hold a wrap (a list, a callout, the margin, a column layout, a subfigure panel) keeps its normal layout, and the render prints a warning that says why. In PDF through LaTeX, a table that gt, kableExtra, or tinytable writes as raw LaTeX keeps its normal layout, and a wrapped table does not break across pages. Each format's page in the docs lists its limits.
It needs Quarto 1.9.36 or later.
Docs and examples: https://jmgirard.github.io/wrapped/
Source: https://github.com/jmgirard/wrapped
Bug reports and requests are welcome as issues on the repo.
All reactions