pdf_pdfxup() creates an n-up pdf using the pdfxup command-line program.
pdf_pdfxup_booklet() is a convenience wrapper around pdf_pdfxup() with
opinionated defaults better suited for printing a physical booklet on a home printer.
pdfxup computes the bounding box of the input to remove margins, keeping text readable.
Usage
pdf_pdfxup(
input,
output = NULL,
...,
ncol = 2L,
nrow = 1L,
byrow = TRUE,
booklet = FALSE,
orientation = "landscape",
paper = getOption("papersize", "letter"),
margins = unit(5, "pt"),
intspaces = unit(1, "pt"),
innermargins = unit(5, "pt"),
framewidth = ifelse(isFALSE(booklet), unit(0.4, "pt"), unit(0, "pt")),
default.units = "pt",
clip = TRUE,
pages = "all",
bb_pages = "all"
)
pdf_pdfxup_booklet(
input,
output = NULL,
...,
booklet = "se",
margins = unit(0.375, "in"),
intspaces = unit(0.1875, "in"),
innermargins = unit(0, "pt")
)Arguments
- input
Input pdf filename.
- output
Output pdf filename.
NULLdefaults totempfile(fileext = ".pdf").- ...
Ignored.
- ncol, nrow
Number of columns/rows per page.
- byrow
If
TRUEfill pages row by row. IfFALSEfill pages column by column.- booklet
If
TRUEconfigure for printing as a 2-up booklet. Can also be"se"(short-edge mode) or"le"(long-edge mode) for explicit control over two-sided printing;booklet = TRUEdefaults to "le" mode.- orientation
Either
"landscape"or"portrait".- paper
Paper size (e.g.
"letter"or"a4"). The name must be known by the LaTeXgeometrypackage.- margins
Margin of pages of the new document as a
grid::unit()object.- intspaces
Space between pages as a
grid::unit()object.- innermargins
Inner margin between frame and page as a
grid::unit()object.- framewidth
Width of the frame around each page as a
grid::unit()object.- default.units
Default units when a numeric value is passed for
margins,intspaces,innermargins, orframewidth.- clip
If
TRUEclip pages to the computed bounding box.- pages
A positive numeric vector of pages to include, a negative numeric vector of pages to exclude, or a string:
- all
Include all the pages.
- even
Include just the even pages.
- odd
Include just the odd pages.
The functions
pdf_pages()andpdf_subset()also support the string:- 2-up saddle stitch
The order of the pages to create a saddle-stitch booklet if printing 2-up.
- interleave
Interleave the first and second halves of the pages. Requires an even number of pages.
- interleave_first
Repeat the first page
n - 1times and interleave with the remainingn - 1pages.- interleave_last
Repeat the last page
n - 1times and interleave with the firstn - 1pages.
- bb_pages
Pages to use when computing the bounding box (see
pagesargument for supported values). Defaults to"all". Note negative numbers indicate pages to omit from computation of bounding box.
Details
pdf_pdfxup() tries to closely follow the pdfxup defaults. In contrast pdf_pdfxup_booklet() makes these alternative defaults:
booklet = "se"which I find easier to reason about than"le"margins = unit(3/8, "in")to provide adequate margins for home printersintspaces = unit(3/16, "in")to provide adequate gutter space for foldinginnermargins = unit(0, "pt")
See also
https://ctan.org/tex-archive/support/pdfxup for more information about pdfxup
Examples
f1 <- system.file("doc", "Sweave.pdf", package = "utils")
if (nzchar(Sys.which("pdfxup")) && file.exists(f1)) {
f2 <- pdf_pdfxup_booklet(f1)
unlink(f2)
}