Sweave .rnw files won't produce a pdf in RStudio - r

everyone,
Everytime I try to compile a PDF on Rstudio using Sweave, I get this error:
Running pdflatex.exe on PS1.tex...failed Error running
C:/PROGRA~1/MikText/miktex/bin/x64/pdflatex.exe (exit code
-1073740791)
I have reinstalled many times MikText. I've changed the Global settings to weave files using knitr, and I changed the MikText console to install packages on the fly.
Any ideas?
Thank you

Related

RStudio error in windows: Running pdflatex.exe on file_name.tex.. (exit code -1073740791)

I am using Rstudio in windows 10. I am triying to create a pdf from a .tex file. However, when I compile the PDF, the following error appears:
Running pdflatex.exe on file_name.tex...failed Error running C:/Users/user_name/AppData/Local/Programs/MiKTeX/miktex/bin/x64/pdflatex.exe (exit code -1073740791)
I am using a native installation of R, Rstudio and MikTeX. Not an envioronment with anaconda or similar.
If you are using RStudio, have you tried tinytex instead of MikTeX? In the Tools Menu>Global Options>Sweave, tick "use tinytex for compiling .tex files". Then install tinytex package. After installing tinytex package, write in console "tinytex::install_tinytex()". This will install the latex compiler tinytex. Try compiling your tex file using it.
I think that issue has to do with missing packages. In fact, MiKTeX doesnt preinstall most of them. I recommend to compile with TinyTeX, because it shows where the compilation stops (as I said, due to a missing package typically required in some sty file). This way you can track which are the missing packages and install them on the MiKTeX Console one by one.
I posted about this issue in an open discussion on Github. Drop the link here in case you need more details.

Cannot install framed.sty when I use knitr and RStudio to produce a pdf file on Windows

I am trying to use RStudio and knitr to produce PDF files on Windows 10. There is no LaTex on my computer. When clicking "Compile PDF" button, I have this error message:
LaTex Error: File 'framed.sty' not found.
==>Fatal error occurred, no output PDF file produced.
I found a framed.sty file under H:\R\win-library\3.3\knitr\misc. It looks like RStudio cannot find the path. So, I try some methods. For example, install framed package. I downloaded framed package from https://www.ctan.org/pkg/framed?lang=en.
However, all the websites I found are talking about the solution on Mac or Linux, for example https://github.com/rstudio/rmarkdown/issues/39. How can I fix this problem on Windows 10?
Presumably you were using MiKTeX on Windows. You can use its package manager to install a missing package: https://docs.miktex.org/manual/pkgmgt.html

creating link to rstudio installation of pandoc on mac

I'm trying to use pandoc on a markdown document I'm working on at the command line on a mac. My Mac is telling me that I don't have pandoc installed. In fact, I know that pandoc is installed because I regularly use it from within Rstudio to knit rmarkdown or sweave files. I dealt with this problem on my desktop Ubuntu before and created a link from Rstudio's copy of pandoc to my bin so I could use it at the command line. However, I can't seem to find pandoc on my Mac. Does anyone know how I can create a link on a mac to make the Rstudio copy of pandoc accessible at the terminal line?

Knitting error when knitting html on RStudio

I've been a regular R user for 1.5 years. Never seen this happen and have no idea how to fix it. I've read the whole Internet in search of a solution without luck. I have tried restarting my computer and reinstalling RStudio. I am able to knit any .Rmd as a .pdf or .html the first time I try it, but subsequent tries fail with the error messages below. This happens with both tried-and-true .Rmd that have worked previously as well as new template .Rmd files created through RStudio's File-->New option. If I re-install RStudio, it allows knitting of any .Rmd file again on the first try.
Loading required package: knitr
Warning message:
package ‘knitr’ was built under R version 3.2.3
processing file: HW16.Rmd
|.................................................................| 100%
ordinary text without R code
output file: HW16.md
[1] "HW16.md"
Error generating HTML preview for ~/Dropbox/MyProjects/spring2016/advancedMachineLearning/HW16.Rmd r error 4 (R code execution error)
The console generates:
I found a solution: delete R from your computer. You do not need to re-install RStudio. To delete R on my Mac, I went to /Library/Frameworks/R.framework/Versions/ then deleted the folders "3.2.x" (these stand for the version of R. It is possible that you have more than one version installed). Next, I re-installed R using brew in the terminal.
brew tap homebrew/science
brew install r
Open RStudio. Knit any .Rmd that is known to work, or a fresh .Rmd generated by RStudio. Knit again. Problem solved!

Knitting to PDF in R

I am new to R and am trying to knit my R Markdown files into PDF format.
I continually get the error message:
pandoc: pdflatex not found. pdflatex is needed for pdf output.
Error: pandoc document conversion failed with error 41
Execution halted
No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:
Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup
(NOTE: Be sure to download the Complete rather than Basic installation)
Mac OS X: TexLive 2013 (Full) - http://tug.org/mactex/
(NOTE: Download with Safari rather than Chrome strongly recommended)
Linux: Use system package manager
I have downloaded pandoc, and I have also downloaded TexLive and have installed them both onto my computer. For the life of me I cannot figure out why R wont recognize that Ive installed them, and knit into a PDF.
Please help!
For Mac OS X, if you have installed TexLive (I installed so through homebrew caskroom) you should have pdftex available via command line.
type 'which pdftex' to make sure something shows up. from there, i created a symbolic link into my $PATH, specifically into my /usr/local/bin (which is where all my homebrew stuff is stored) with:
ln -s /usr/texbin/pdftex /usr/local/bin/pdflatex
from there, using knitr in RStudio and R in general seemed to work and rendering R Markdown is definitely a really beautiful option (check some of the templates too like the Tufte one!)
I had the same problem, after downloading mactex through FireFox and installing the package.
I quit and restarted RStudio, and it worked (no changes at the terminal command line level).
The .pdf output is, however, a bit blurry at least on my first attempt.
I had a similar issue as I wasn't able to knit pdf file & solved it by installing & running tinitex packages using those commands in the console -- not the terminal
install.packages("tinytex")
tinytex::install_tinytex()

Resources