PDF through Typst
In PDF through Typst, the extension puts each wrapped figure and the paragraphs after it in a wrap-content call from the Typst package wrap-it 0.1.1. The extension ships its own copy of wrap-it, so the render does not download it. Citations and @fig- links in the text beside the figure work. A wrapped table float goes in a wrap-content call in the same way.
Width and gap
The width and wrap-gap values change to Typst lengths:
- A percent is that share of the text width, or of the column width in a document with
columns:set. - A
pxlength, or a number with no unit, is 0.75ptfor eachpx, so200pxis150pt. Apclength is 12ptfor eachpc. - A length in
pt,mm,cm,in, oremstays as it is, with its unit in lowercase. - Any other unit, such as
ex,vw, orrem, and acalc(),min(),max(), orclamp()value print a warning, and the document default applies. - A width of zero prints a warning, and the document default applies.
Widths that leave no room
A percent of 100% or more leaves no room for the text in Typst, so it prints a warning. A percent width and a percent gap with a sum of 100% or more also print a warning, for example width="75%" with wrap-gap="25%". A figure’s own width then takes the document default. If the document default is a percent that with the gap also fills the text, the figure’s width takes the built-in 40%. A wrapped: width of 100% or more, or a wrapped: width and gap in percents with such a sum, takes the built-in 40%.
A width plus its gap in other units can also fill the text. Examples are 5in with a 1.5in gap, and 99% with a 1em gap. Such a width also leaves no room for the text. The extension cannot know the text width or the column width, so Typst checks the width plus the gap while it lays out the page. The figure then takes the document default. If the document default plus the gap is that wide too, the figure takes the built-in 40%. Typst cannot print a warning, so the render prints none for such a width. If 40% plus the gap is that wide too, the figure keeps 40% and the gap.
Attributes that Typst ignores
The wrap-lines attribute does nothing in Typst. Typst does not use an image’s height in a wrapped figure or table. The image fills the box width, or its table column, and keeps its shape, and the render prints a warning.
Right-to-left text
The sides stay physical in right-to-left text. Typst sets that direction from the document’s lang, such as lang: he, or from a raw Typst #set text(dir: rtl). Quarto does not pass dir: rtl to Typst.
Columns
In a document with columns: set, such as columns: 2, a wrapped figure wraps inside its column. A percent width is a share of the column width, and Typst checks a width plus its gap against the column width. If a figure and the text beside it do not fit at the bottom of a column, they move to the next column. The rest of that column stays blank. The extension does not test a raw Typst #columns() call.
Limits
wrap-it has limits:
- wrap-it puts the figure and the text beside it in one box, and the box does not break across pages or columns. If the box does not fit at the bottom of a page or a column, it moves to the next page or column. The rest of the page or column before it stays blank.
- When the text is longer than the figure, wrap-it breaks a paragraph at the word where the figure ends. The rest of that paragraph starts on a new line below the figure and runs the full width.
- wrap-it issue #1 reports that first-line indents change in wrapped text. The extension does not test this case.
- A table keeps to the width of its box. Typst narrows a wide table’s columns and breaks its words to fit. In a narrow box, the text of columns side by side can overlap.
Tagged PDF
With pdf-standard: ua-1, each wrapped figure and wrapped image keeps its fig-alt text as its alt text.