latexdiff() uses the external utility latexdiff to create a PDF file
showing differences between two Rmd, qmd, Rnw or TeX files.
latexdiff(
path1,
path2,
output = "diff",
compile = TRUE,
open = interactive(),
clean = TRUE,
quiet = TRUE,
output_format = NULL,
ld_opts = "--replace-context2cmd=\"none\""
)Invisible NULL.
Path to the first file.
Path to the second file.
File name of the output, without the .tex extension.
Logical. Compile the diff from tex to pdf?
Logical. Automatically open the resulting pdf?
Logical. Clean up intermediate TeX files?
Logical. Suppress printing? Passed to render and knit, and hides standard error
of latexdiff itself.
An rmarkdown output format for Rmd files, probably
rmarkdown::latex_document(). The default uses the options defined in the Rmd files.
YAML front matter.
Character vector of options to pass to latexdiff. The
default avoids some problems with Rmd files.
You will need the latexdiff utility installed on your system:
# on MacOS:
brew install latexdiff# on Linux:
sudo apt install latexdiff
File types are determined by extension,which should be one of .tex, .Rmd,
.qmd or .rnw. Rmd files are processed by rmarkdown::render(). Rnw files
are processed by knitr::knit(). qmd files are processed by
quarto::quarto_render().
latexdiff is not perfect. Some changes will confuse it. In particular:
If input and output files are in different directories, the "diff.tex"
file may have incorrect paths for e.g. included figures. latexdiff
will add the --flatten option in this case, but things still are
not guaranteed to work.
Sometimes the "diff.tex" file fails to compile to pdf. If so,
set compile = FALSE and try editing the tex file manually.
if (FALSE) {
latexdiff("file1.Rmd", "file2.Rmd")
}
Run the code above in your browser using DataLab