Reputation: 72769
When building a package, I received the following warning:
* checking PDF version of manual ... WARNING
LaTeX errors when creating PDF version.
This typically indicates Rd problems.
I have no idea how to even begin diagnosing this. Is there a tool that tells me what .Rd file the problem is in?
I get no warnings about any of my Rd files in the checking documentation step....
Upvotes: 78
Views: 15373
Reputation: 13817
Oftentimes this error occurs because of Unicode characters in the package. In these cases, the error message might look like this.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
! Package inputenc Error: Unicode character (U+009D)
(inputenc) not set up for use with LaTeX.
You can find any Unicode characters in your package using tools::showNonASCIIfile()
. Here's a simple way to check for these characters in your functions and documentation:
# functions
functions <- list.files(path = './R', all.files = T, recursive = T, full.names = T)
lapply(X=functions, FUN = tools::showNonASCIIfile)
# documentation
docs <- list.files(path = './man', all.files = T, recursive = T, full.names = T)
lapply(X=docs, FUN = tools::showNonASCIIfile)
Upvotes: 2
Reputation: 5287
First, @dirk-eddelbuettel's approach in the current question identified the missing tex package (which was "makeindex" in my case).
system("R CMD Rd2pdf --no-preview --output=./documentation-peek.pdf ." )
# ... <omitted pages of output> ...
# Warning in sys2(makeindex, shQuote(idxfile)) : '"makeindex"' not found
# Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
# unable to run 'makeindex' on 'Rd2.idx'
# Error in running tools::texi2pdf()
Then @pedro-lima's answer in https://stackoverflow.com/a/69968791/1082435 worked for my specific case.
tinytex::tlmgr_install("makeindex")
Upvotes: 0
Reputation: 1398
In my case, I had no error when running devtools::check()
nor devtools::document()
but when running R CMD check mypackage_version.tar.gz
I got an error:
* checking PDF version of manual ... WARNING
LaTeX errors when creating PDF version.
This typically indicates Rd problems.
LaTeX errors found:
* checking PDF version of manual without hyperrefs or index ... ERROR
In this question in RStudio Community they point to a problem with LATEX installation. I have the LATEX installation suggested in R markdown cookbook: TinyTex. I fixed the issue by running in the R console
tinytex::latexmk(file = "../mypackage.Rcheck/mypackage-manual.tex")
This command automatically updated my LATEX installation so the output file mypackage-manual.pdf was created. After this, I did not get any other error related to PDF when running R CMD check
:
* checking PDF version of manual ... OK
* DONE
Upvotes: 2
Reputation: 1479
...and another reason is that you haven't installed MikTex yet.
Download MikTex from here and follow the dialog prompts to install. I found the defaults to be reasonable and worked well for me.
Try to build your R package again. It should be OK now.
Upvotes: 5
Reputation: 4380
Concluding from the comments and from my own experience the problem often seems to be that some TeX fonts are missing, most often
inconsolata.sty
andupquote.sty
First you have to find the right directory where TeX fonts are stored - in my case this is:
C:\Program Files\R\R-3.3.0\share\texmf\tex\latex
Then you can download them here:
Just copy them to the respective folder and in many cases the problem will be solved (in my case too). This should work for all operating systems.
Upvotes: 7
Reputation: 412
If you are on Ubuntu just install Tex Live by this command:
apt-get install texlive
and restart Rstudo if you use it.
Upvotes: 1
Reputation: 28274
Though @Dirk's answer also helped me to fix the problem I would like to add a bit which might especially help recent updaters. That is, people who haven't encountered other LaTeX / R troubles after the update to 3.1.3 yet. The problem is little bit more general than just building. For me, on OS X the problem was that R CMD Rd2pdf
as well as the R CMD CHECK
expected texi2dvi
to be in /usr/local/bin
while it was in /usr/bin
.
A symlink helped to fix the problem. On terminal type:
# to check whether the same issue exists for you
which texi2dvi
# if so
cd /usr/local/bin
ln -s /usr/bin/texi2dvi
Of course if the first line returns something else, you need to adapt the symlink here.
Upvotes: 19
Reputation: 368439
Try R CMD Rd2pdf mypackage
to create the manual, and possibly also set the --no-clean
option to keep the temporary files. This should allow you to debug the LaTeX code triggering the error.
Upvotes: 76