plot_hook_textpos: Plot placement and resizing hook

Description Usage Details

Description

Not called directly but automatically set as knitr's plot hook, so that chunks with plots can process the chunk options textblock_width and inside_textblock, which allow you to use the textpos grid for placing and sizing plots on slides arbitrarily instead of in the flow of text.

Usage

1

Details

This gives us some new options and changes the meaning of two others:

out.width, out.height

reinterpreted as units on the textpos grid. This sets the scaling by pdflatex of an image file whose generated dimensions are set by fig.width and fig.height (which are always in inches).

textblock_width

width of the block in textpos grid units

textblock_pos

two-element vector of grid coordinates of the textblock

center

Boolean: enclose graphic within center environment?

inside_textblock

don't generate textblock environment, just the \includegraphics line (useful if, e.g., you write out the environment \begin and \end yourself and stick the code chunk between them)

Grid positioning only happens if inside_textblock=T or textblock_width is specified in the chunk positions; otherwise we revert to knitr's normal behavior. Grid positioning also always makes graphics inline rather than floating. Use inside_textblock=T and enclose it in a figure environment yourself if you want to combine the textblock and the figure environment (you probably don't).

N.B. the default knitr plot output hook for LaTeX responds to many more options than this does. But in my workflow we are knitting to markdown, not LaTeX. That's a simplifying decision in some ways but with some costs in flexibility.


agoldst/scuro documentation built on Nov. 5, 2021, 3:44 a.m.