[R] Vignette from existing .pdf manual

Henrik Bengtsson hb at biostat.ucsf.edu
Wed Dec 10 06:10:50 CET 2014

With recent versions of R there is no longer a need to trick R with
dummy Rnw files etc.  Instead, try the following:

1. Put your rSARP.tex file in vignettes/, i.e. vignettes/rSARP.tex.
If you have other files that the LaTeX file depends on (e.g. figures),
these should also be put under vignettes/.  When the LaTeX file is
compiled, it's relative to this directory.

2. Rename it to rSARP.latex.  (rSARP.tex will also work, but then R
CMD check will give a NOTE that there is a *.tex file left behind.)

3. Add the following to the top of the rSARP.latex file:

%\VignetteIndexEntry{User manual}

4. Add the following two entries to the package DESCRIPTION file:

Suggests: R.rsp
VignetteBuilder: R.rsp

Now 'R CMD build <pkg>' will automatically compile the LaTeX to PDF,
which will be a proper package vignette that is part of your package
*.tar.gz file.  For there on it is just as any other vignette.

If you can't get it to work, make that the following

> tools::buildVignette("vignettes/rSARP.tex")

correctly generates rSARP.pdf without errors. If that works, then 'R
CMD build <pkg>' should also work.

Hope this helps


On Sun, Nov 23, 2014 at 7:50 AM, John Hutcheson <hutchesonjohn at att.net> wrote:
> Greetings!  I am trying to develop a package for R for Search and Rescue planning.  I'd like to  re-use an existing PDF file that was created in emacs (so I have the .tex and source data) for use in inst/docs.  The vignette sections of the 'Writing r extensions' manual starts off implying that this can be done, but after lots of effort, I find no way of getting it done.  I did find a suggestion to use a 'dummy' .Rnw file stored alongside the pdf in the inst/doc folder, but haven't been able to make that work.
> Here's the setup data:
> Package name:   rSARP
> directory structure :  rSARP/inst/doc
>                                             rSARP/inst/extdata
>                                             rSARP/man
>                                             rSARP/R
> Existing pdf manual:  rSARP.pdf located in rSARP/inst/doc/  (Its less than 5 meg in size)
> VignetteIndexEntry file:        rSARP.Rnw located in rSARP/inst/doc/    The file contents for the dummy .Rnw are:
> %\VignetteIndexEntry{User manual}
> \documentclass{article}
> \begin{document}
> \end{document}
> I've tried creating an rSARP/vignette folder and storing the .Rnw file there - no luck.
> I appreciate any assistance I can get to incorporate the existing documentation into the package.
>       John Hutcheson
>      hutchesonjohn at att.net
>             989 - 430 - 7560
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list