1

Recently, I have updated R using installr so that I have now two versions (3.6.1 e 4.0.3) installed in my computer running Windows 10, but I only use the 4.0.3 version. For some reasons I do not know, the 'exams' package has not been transferred to the new version so I had to reinstall it, but now 'exams2pdf' does not work anymore and I get the following error message:

LaTeX Error: File `Sweave.sty' not found.

Any help would be very much appreciated.

user12703198
  • 423
  • 3
  • 11

2 Answers2

2

I opened the MikTeX Console, selected: Settings > Directories, and then the small + button to add the folder "C:\Program Files\R\R-4.0.3\share\texmf". Now I do not get anymore the error message and it works.

user12703198
  • 423
  • 3
  • 11
1

I would guess that you have the R package tinytex installed which does not always find the Sweave.sty file that is shipped in base R's texmf folder. Installing the file in a texmf folder where it is easier to find (as you did in your answer) is one possibility to solve the problem. Uninstalling the R package tinytex probably would have also solved the problem. Or you could use a template that avoids using Sweave.sty.

For further details on using LaTeX with R/exams, see http://www.R-exams.org/tutorials/latex/. This question and answer is also related: How to configure R/Exams to use system LaTeX?

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
  • Thanks for the detailed information. Running `"tinytex" %in% installed.packages()` I get `TRUE` even if I do not recall installing it. Was it installed together with R exams? – user12703198 Dec 31 '20 at 15:17
  • Yes, it is "suggested" by the exams package. Thus when you run `install.packages("exams", dependencies = TRUE)` or is also installed. – Achim Zeileis Dec 31 '20 at 15:35