Skip to contents

A compiled .tex file such as slides/gaussian-processes/slides-gp-bayes-lm.pdf will be compared with an assumed to be accepted / known good version at slides-pdf/slides-gp-bayes-lm.pdf if it exists.

Usage

compare_slide(
  slide_file,
  verbose = TRUE,
  create_comparison_pdf = FALSE,
  thresh_psnr = 40,
  dpi_check = 50,
  dpi_out = 100,
  pixel_tol = 20,
  view = FALSE,
  overwrite = FALSE
)

Arguments

slide_file

character(1): A single slide .tex file (see examples).

verbose

[TRUE]: Print additional output to the console.

create_comparison_pdf

[FALSE]: Use diff-pdf to create a comparison PDF at ./comparison/<slide-name>.pdf

thresh_psnr

[40]: PSNR threshold for difference detection in diff-pdf-visually. Higher is more sensitive.

dpi_check

[50] Resolution for rasterised files used by both diff-pdf-visually. Lower is more coarse.

dpi_out

[100] Resolution for output PDF produced by diff-pdf. Lower values will lead to very pixelated diff PDFs.

pixel_tol

[20] Per-page pixel tolerance for comparison used by diff-pdf.

view

`FALSE For interactive use: Opens window showing comparison diff.

overwrite

[FALSE] Re-creates output diff PDF even if it already exists and appears up to date.

Value

Invisibly: A list of results:

  • passed: TRUE indicates a successful comparison, FALSE a failure.

  • reason: Shorthand reason for a failing comparison.

  • pages: Vector of pages with differences.

  • output: Full output produced by diff-pdf-visually.

Details

First uses diff-pdf-visually to check slides for differences based on the PSNR of rasterised versions of the slides (adjustable with thresh_psnr), and then uses diff-pdf to create a PDF highlighting the differences if create_comparison_pdf is TRUE.

This only re-runs diff-pdf to create a comparison PDF file if the output file under ./comparison/<slide-name>.pdf is more recent than both of the input PDF files. That way you can safely re-run this function repeatedly without worrying about computational overhead.

Note

Uses diff-pdf-visually and diff-pdf under the hood, you may need to adjust your $PATH.

Examples

if (FALSE) { # \dontrun{
# The "normal" way: A .tex file name
compare_slide("slides-cart-computationalaspects.tex")

# Also acceptable: A full path (absolute or relative), convenient for scripts
compare_slide("lecture_advml/slides/gaussian-processes/slides-gp-bayes-lm.tex")

# Lazy way: No extension, just a name
compare_slide("slides-cart-predictions")

# Whoopsie supplied name of PDF instead no biggie I got u
compare_slide("slides-forests-proximities.pdf")

compare_slide("slides-boosting-cwb-basics")
} # }