Title: | Diff TeX, 'rmarkdown' or 'quarto' Files Using the 'latexdiff' Utility |
---|---|
Description: | Produces a PDF diff of two 'rmarkdown', 'quarto', Sweave or TeX files, using the external 'latexdiff' utility. |
Authors: | David Hugh-Jones [aut, cre] |
Maintainer: | David Hugh-Jones <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0.9000 |
Built: | 2024-11-12 03:40:12 UTC |
Source: | https://github.com/hughjonesd/latexdiffr |
git_latexdiff()
checks out a previous version of a file and calls latexdiff
on it.
git_latexdiff(path, revision, clean = TRUE, ...)
git_latexdiff(path, revision, clean = TRUE, ...)
path |
File path to diff |
revision |
Revision, specified in a form that |
clean |
Clean up intermediate files, including the checked out file? |
... |
Arguments passed to |
git_latexdiff
only checks out the specific file in path
. If your Rmd file depends on external
resources which have also changed, you will need to checkout the old revision as a whole and
create the tex file manually.
The result of latexdiff
.
## Not run: git_latexdiff("file1.Rmd", "HEAD^") git_latexdiff("file1.Rmd", "master@{7 days ago}") ## End(Not run)
## Not run: git_latexdiff("file1.Rmd", "HEAD^") git_latexdiff("file1.Rmd", "master@{7 days ago}") ## End(Not run)
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\"" )
latexdiff( path1, path2, output = "diff", compile = TRUE, open = interactive(), clean = TRUE, quiet = TRUE, output_format = NULL, ld_opts = "--replace-context2cmd=\"none\"" )
path1 |
Path to the first file. |
path2 |
Path to the second file. |
output |
File name of the output, without the |
compile |
Logical. Compile the diff from tex to pdf? |
open |
Logical. Automatically open the resulting pdf? |
clean |
Logical. Clean up intermediate TeX files? |
quiet |
Logical. Suppress printing? Passed to |
output_format |
An rmarkdown output format for Rmd files, probably
|
ld_opts |
Character vector of options to pass to |
You will need the latexdiff
utility installed on your system:
# on MacOS: brew install latexdiff # on Linux: sudo apt install latexdiff
For more details see CTAN or
github. You'll need a working
perl
installation.
You can set the path to latexdiff
in the environment variable
"LATEXDIFF_PATH"
, using Sys.setenv()
or via the command line. If this is
unset, it is assumed to be "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.
Invisible NULL.
## Not run: latexdiff("file1.Rmd", "file2.Rmd") ## End(Not run)
## Not run: latexdiff("file1.Rmd", "file2.Rmd") ## End(Not run)