PDF through LaTeX

In PDF through LaTeX, the extension puts each wrapped figure in a wrapfigure from the LaTeX package wrapfig, and each wrapped table float in a wraptable. Where the text runs in columns, it does not (see Columns). If your TeX distribution does not have wrapfig, install it, for example with tlmgr install wrapfig.

Width and gap

The width and wrap-gap values change to LaTeX lengths:

  • A percent is that share of the line width, so 40% is 0.4\linewidth. In one column, the line width is the text width.
  • A px length is 0.75 pt for each px, so 200px is 150pt.
  • A length in pt, pc, in, cm, mm, em, or ex stays as it is.
  • Any other CSS unit, such as vw or rem, and a calc(), min(), max(), or clamp() value print a warning, and the document default applies.
  • A width of zero prints a warning, and the document default applies.

Lines beside the figure

The wrap-lines attribute sets the number of lines beside the figure. It works only in LaTeX. Without it, wrapfig counts the lines from the height of the figure. A block that stops the wrap ends it before that number of lines. With a value larger than the figure needs, that block starts below the figure, as it does without wrap-lines.

With a value smaller than the figure needs, LaTeX narrows that many lines. The text after them runs at full width, also beside the figure, where it prints over the figure. In body text, the block that stops the wrap starts below the figure when the paragraph that holds the figure, its narrowed lines, and that block are on one page, with no footnote beside the figure.

![Mean ratings by condition.](ratings.png){#fig-ratings .wrap-right wrap-lines="12"}

A caption inside a wrapped figure is set ragged-right. An image with a height keeps it in LaTeX and keeps its shape, and it fits in the box width.

Limits

wrapfig has limits, and the extension keeps some of them:

  • wrapfig narrows a number of lines that it counts from the height of the figure. The count can run past the bottom of the figure and its caption. In the LaTeX PDFs of this site’s example pages, a paragraph that runs on past that bottom has one or two narrowed lines there.
  • At the block that stops the wrap, the extension skips the rest of the counted lines. After a wrap-lines value smaller than the figure needs, it skips to below the figure in body text, on the figure’s page. If the text beside the figure is shorter than the figure, the space beside the figure stays empty.
  • A figure that does not fit at the bottom of a page moves to the start of a paragraph on the next page. The text before it fills the page. If its paragraphs all end before it is placed, it renders with no text beside it. It renders before the block that stops the wrap, and that block starts below it.
  • If a page break comes while lines are still narrowed, the first lines on the next page are narrowed with no figure beside them. A wrap-lines value larger than the figure needs can narrow lines past a page break in the same way.
  • Figures in a row: a figure after the paragraphs of a wrapped figure is a block that stops its wrap, so it starts below the wrapped figure. A figure that moved to the next page waits for one of its own paragraphs. A heading or the end of a callout does not take it.
  • A figure in a list keeps its normal layout, as in HTML.

Tables

Quarto writes a table as a longtable, which wrapfig cannot hold. For a wrapped table float, the extension writes the table as a tabular in a wraptable, with its caption, its number, and its @tbl- links. Citations, cross-references, shortcodes, formatting, and footnotes in a cell work as in a normal table. The limits above for figures apply to tables too, and a table has three more:

  • A wrapped table does not break across pages. A table that does not fit at the bottom of a page moves to the next page, as a figure does.
  • The columns share the width of the box, and a table’s column text wraps inside its cells. In a table where no column has a width, each column takes a share in proportion to its longest cell text. A pipe table with any line longer than 72 characters has widths of its own, set by the dashes of its separator line, and its columns keep those shares. A tbl-colwidths value of percentages on the table’s #tbl- div or code cell sets the shares, as it does for a normal table. A tbl-colwidths in the document’s metadata does not reach a wrapped table. In a narrow box, a wide table’s column text breaks inside words, and the text of columns side by side can overlap.
  • A table float that holds raw LaTeX keeps its normal layout, and the render prints a warning that names it. gt, kableExtra, tinytable, and knitr::kable(format = "latex") write a table as raw LaTeX.

Columns

  • Where the text runs in columns, set by classoption: twocolumn, a class default, \twocolumn, or multicols, wrapped figures render as normal figures and wrapped tables as normal tables: they do not wrap. A percent width is a share of the column, or of the box that holds the figure. With classoption: twocolumn, the filter writes Quarto’s normal figure, and the render prints one warning.
  • In other documents, a class that sets two columns by default, such as IEEEtran, a \twocolumn command, and a multicols environment are found only while LaTeX runs. In two-column text, a captioned figure floats as a normal figure does. An image with no caption, or a figure inside a box such as a minipage, stays in place. Inside multicols, where LaTeX loses floats, each figure stays in place. A wrapped table does what a captioned figure does. After \onecolumn, figures wrap again.
  • In those cases the render prints no warning. LaTeX writes the warning to its log, and Quarto keeps the log with latex-clean: false. A column layout from a LaTeX class or package that neither turns on LaTeX’s two-column mode nor opens a multicols environment is not detected.

Tagged PDF

Quarto 1.10.19 ignores pdf-standard: ua-1 in LaTeX, so that PDF has no tags, with or without the extension. With pdf-standard: ua-2, Quarto’s default document class fails, so set a class such as documentclass: article. In such a PDF, each wrapped figure and wrapped image keeps its fig-alt text as its alt text.