object pdflatex not found on Windows 7 - r

I work with RStudio (version 3.1.2). When I try to Knit PDF in my R Markdown script, I receive the following output:
Error in eval(expr,envir,enclos): object 'pdflatex' not found
I have installed MikTex basic and have searched solutions on the web. There is one in stackoverflow for Mac users, I work with Windows 7. It seems the problem is not having a path to the Tex installation. I found this brief guide to solve it on Windows: enter link description here
So, I did what it says: Sys.which("pdflatex") and received:
pdflatex
""
Ten I typed: Sys.getenv("PATH"), obtaining:
1 "C:\Program Files\R\R-3.1.2\bin\x64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;:/usr/texbin:/usr/texbin"
Finally, I entered: Sys.setenv(PATH=paste(Sys.getenv("PATH"),"/usr/texbin",sep=":")), but when I try to knit PDF again it shows me the same error message. Thanks for all your time, I would appreciate any help.

I'm working on a 64 bit Windows, so the Sys.which("pdflatex") returned:
C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe
Type in sessionInfo(). You should se something like this:
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Depending on your system the path could be either: C:\Program Files\MiKTeX 2.9\miktex\bin (for the 32-bit version) or C:\Program Files\MiKTeX 2.9\miktex\bin\x64 (for the 64-bit version).

Edit your PATH variable. You're on windows, but you've tried to add a UNIX-style directory (i.e., separated from the other directories by : and using / rather than \). '/usr/texbin/' is probably not a directory on your computer.

Check your path. It might look like this C:\Program Files\MiKTeX 2.9\miktex\bin\x64 assuming you're working on a x64 OS. After that, open a cmd console and check if is everthing ok with this command: pdflatex.exe -version. Then restart RStudio and try to render your pdf again.

Related

r pandoc problems when runing from bat file

recently I have created some Rmd script wchich create and send html file to specified recipients. Script works perfect, when i run from application level (R Studio). But it doesn't work, when i run it from Task Scheduler (bat file) - log file indicates an error:
ERROR: pandoc version 1.12.3 or higher is required and was not found
(see the help page ?rmarkdown::pandoc_available).
I have checked pandoc version n R Studio:
pandoc_available()
[1] TRUE
pandoc_version()
[1] ‘1.17.2’
Maybe application run from Task Scheduler do not use Pandoc library enclosed in R Studio, but try to find another Pandoc software instaled on my computer?
Any ideas? My operating system is Windows.
TK
Rstudio uses this environment variable to find where pandoc is installed on your machine:
Sys.getenv("RSTUDIO_PANDOC")
You need to add this location to system PATH

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

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()

RStudio can't find LaTeX after Mavericks update

I have been using Sweave for quite sometime on my system using RStudio.
However, I recently upgraded my Mac OS from Lion to Mavericks.
This caused several issues:
First, RStudio was not able to locate the R library, and it just wont start. I reinstalled RStudio, but still got the same issue. So I reinstalled both R and RStudio, and then RStudio started to work.
And now, RStudio is still not able to locate TeX installation, and gives me the following warning:
"No TeX installation detected. Please install TeX before compiling."
This will probably get fixed by a reinstall, but I would prefer to avoid a fresh download of TeX (~2.3G).
Any ideas on how to resolve this?
RStudio expects pdflatex to be on the system path (i.e. entering Sys.which("pdflatex") at the R console should return the path to pdflatex).
You can fix the problem by getting pdflatex back on the system path:
Find the path where pdflatex is installed on your system--likely /usr/texbin, but use find /usr -name pdflatex if you need help.
Create a file called TeX in /etc/paths.d that contains this path.
For example:
$ sudo -s "echo /usr/texbin > /etc/paths.d/TeX"
You'll need to restart to apply the changes.

R CMD check --as-cran warning

I am trying to do R CMD check before uploading my package to CRAN.
R CMD check --as-cran "my package folder".
However, it spits out this warning:
"checking for unstated dependencies in examples ... OK
WARNING
pdf is needed for checks on size reduction of PDFs"
I searched online but found no clue to solve this problem. This warning does not turn up when I run "R CMD check" only. And my package works with no problem. Could someone please tell me what might be wrong with my package?
qpdf is an external program necessary to reduce the size of pdf, it can be downloaded from the sourceforge site. You can install either the 32 bis or 64 bits version, both are working.
To install it, you download the file, and then copy the folder to your program folder.
Next you need to edit you system path to point to the bin folder by adding 'C:\Program Files\qpdf-version_numer\bin'. In a command batch (cmd) type qpdf to see if that has been set correctly, you should get the message
qpdf: an input file name is required
Usage: qpdf [options] infile outfile
For detailed help, run qpdf --help
Once this is done, the warning should be removed from your R CMD check
To add to Cedric's answer:
If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage. If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 7.0 is listed here).
Once you have extracted the zipped qpdf directory to your hard disk, perhaps under C:\Program Files, added C:\Program Files\qpdf-version_no\bin to your system PATH under the environment variables, and re-launched R so it picks up the new PATH, you need to convince Windows that pqdf is safe to run.
Navigate to C:\Program Files\qpdf-version_numer\bin and execute qpdf.exe (by double-clicking). Windows 10 throws up a security warning as it's an unrecognized executable file. You'll need to use the more options link to find the button to run the program. Once you've done this, Windows will recognize the file as safe to run and allow other programs, including R, to use it.

Resources