Diagnosing R package build warning: “LaTeX errors

2019-01-13 05:31发布

问题:

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....

回答1:

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.



回答2:

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.



回答3:

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 and
  • upquote.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:

  • https://www.ctan.org/tex-archive/fonts/inconsolata/?lang=en
  • https://www.ctan.org/tex-archive/macros/latex/contrib/upquote?lang=en

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.



回答4:

If you are on Ubuntu just install Tex Live by this command: apt-get install texlive and restart Rstudo if you use it.



回答5:

...and another reason is that you haven't installed MikTex yet.

  1. Download MikTex from here and follow the dialog prompts to install. I found the defaults to be reasonable and worked well for me.

  2. Try to build your R package again. It should be OK now.