Skip to contents

layout_grid() calculates a layout data frame for a grid of identically sized print-and-play components.

Usage

layout_grid(
  nrow = 2L,
  ncol = 1L,
  width = 2.5,
  height = 3.5,
  bleed = 0,
  ...,
  paper = getOption("papersize", "letter"),
  orientation = c("landscape", "portrait"),
  angle = 0,
  name = layout_name_fn(),
  direction = "left-to-right",
  input = NULL,
  pages = "all"
)

Arguments

nrow, ncol

Number of rows and columns of print-and-play components (e.g. cards)

width, height, bleed

Width, height, and bleed for each print-and-play component (in inches)

...

Ignored.

paper, orientation

Print-and-play paper size and orientation. paper defaults to getOption("papersize", "letter") unless input is passed.

angle

Vector of angles of the pieces in degrees (counter-clockwise) (assigned direction, top-to-bottom)

name

Either a vector of names of each piece or a function with arguments nrow and ncol to be used to generate a vector of names for each piece. These will be assigned direction, top-to-bottom. layout_name_fn() can be used to generate such a function.

direction

Should name and angle be assigned "left-to-right" or "right-to-left". Also supports aliases "ltr", "lr", "rtl", and "rl".

input

If not NULL then an input pdf filename whose (selected) pages' paper size as inferred by pdf_paper() is used as paper. Only paper is inferred from input: for the layout to be centered on the actual pages orientation must also match them. It is an error to pass both input and paper, to pass pages without input, or if the selected pages don't all share a supported paper size.

pages

Which pages of input to infer the paper size from. Supports the same values as the pages argument of pdf_apply() e.g. "all", "even", "odd", or a numeric vector. It is an error if no pages are selected.

Value

A data frame with columns "row", "col", "x", "y", "angle", "width", "height", "bleed", "paper", "orientation", and "name".

Examples

# Button Shy card layout
layout_grid(nrow = 2L, ncol = 3L, height = 3.447, width = 2.469, bleed = 0.125)
#>   row col     x      y angle width height bleed  paper orientation    name
#> 1   1   1 2.781 6.0985     0 2.469  3.447 0.125 letter   landscape piece.1
#> 2   1   2 5.500 6.0985     0 2.469  3.447 0.125 letter   landscape piece.2
#> 3   1   3 8.219 6.0985     0 2.469  3.447 0.125 letter   landscape piece.3
#> 4   2   1 2.781 2.4015     0 2.469  3.447 0.125 letter   landscape piece.4
#> 5   2   2 5.500 2.4015     0 2.469  3.447 0.125 letter   landscape piece.5
#> 6   2   3 8.219 2.4015     0 2.469  3.447 0.125 letter   landscape piece.6

# Center the layout on the paper size of a pdf's pages
input <- pdf_create_blank(paper = "a4", orientation = "portrait")
layout_grid(nrow = 3L, ncol = 3L, orientation = "portrait", input = input)
#>   row col        x        y angle width height bleed paper orientation    name
#> 1   1   1 1.633858 9.346457     0   2.5    3.5     0    a4    portrait piece.1
#> 2   1   2 4.133858 9.346457     0   2.5    3.5     0    a4    portrait piece.2
#> 3   1   3 6.633858 9.346457     0   2.5    3.5     0    a4    portrait piece.3
#> 4   2   1 1.633858 5.846457     0   2.5    3.5     0    a4    portrait piece.4
#> 5   2   2 4.133858 5.846457     0   2.5    3.5     0    a4    portrait piece.5
#> 6   2   3 6.633858 5.846457     0   2.5    3.5     0    a4    portrait piece.6
#> 7   3   1 1.633858 2.346457     0   2.5    3.5     0    a4    portrait piece.7
#> 8   3   2 4.133858 2.346457     0   2.5    3.5     0    a4    portrait piece.8
#> 9   3   3 6.633858 2.346457     0   2.5    3.5     0    a4    portrait piece.9
unlink(input)