I'm following Gregor Gorjanc's tutorial on LyX & Sweave. Using Ubuntu 10.04 and LyX version 1.6.5 with all of texlive-full installed.
R scraps which result in numerical output produce a valid PDF.
But, when I try to compile simple figures like
<<chunk, fig=T>>= [ctrl+enter]
hist(rnorm(100)) [ctrl+enter]
#
I get cryptic errors. Either that chunk.temp.Rnw wasn't found, or that LaTeX encountered an error and I should hit <enter> to ignore.
If I change fig to figure and T to TRUE, then the LyX document compiles but displays no graphics. With pgfsweave I get this error, or sometimes this one.
Am I working with the wrong versions of these programs? Is there a way to elicit better error messages? Can I somehow dive into the LaTeX prompt and hit <enter> myself?
update: I was using the wrong version of LaTeX; Ubuntu's default is too old. Also I needed to update to LyX 2.0.1 and a newer version of pgf and pgfSweave (the programs are distinct).
The new (nondescript) error message is: An error occurred while running: Rscript '/home/mars/.lyx/scripts/lyx-sweave-exec.R' 'UTF-8' 'pgfSweave' "/home/mars/" "/tmp/lyx_tmpdir.T1663/lyx_tmpbuf2/" "test.sweave.lyx.Rnw" > "test.sweave.Rnw".log 2>&1
According to https://tex.stackexchange.com/questions/27993/can-i-download-ctan-packages-from-the-command-line-ubuntu/27994#27994 there is a perennial problem with TeX in Ubuntu: their packages are way behind. Since many innovations with Sweave have happened in 2010-2011, it seems one must download and install an .iso from http://ftp.ctex.org/mirrors/CTAN/systems/texlive/Images/ rather than use Synaptic. So much for package management!
I'll accept my own answer only if this actually works.
update: Make sure you disregard anything you read about Noweb.sty because in LyX 2.0.1 there is a "Sweave Module" meaning you should just use regular document classes (article, book, report) -- the scraps are replaced by chunks and essentially Sweave is handled natively. Also disregard Brett Collier's lucid explanation of how to install LyX because it's now outdated, despite Gregor Gorjanc's highly-googleable blog post saying it works. That is also outdated, or maybe it only works in Ubuntu 9 and not Ubuntu 10.04.
So the steps to successfully getting Sweave to work in LyX for Ubuntu 10.04 as of August 2011 are:
Get the newest texlive from tug.org -- not the one from Synaptic. How to do that: https://tex.stackexchange.com/questions/27993/can-i-download-ctan-packages-from-the-command-line-ubuntu/27994
Get pgf and kTikz as described here: http://justbloodywork.blogspot.com/2011/07/installing-latex-and-pgf.html
Follow Yihue's instructions here: http://yihui.name/en/2010/10/how-to-start-using-pgfsweave-in-lyx-in-one-minute/#comment-10929. Build lyx-devel from source, apply Yihue's patch, and configure some LyX preferences.
Tools > Reconfigure LyX.
Pray.
Start LyX and load Yihue's test file from (3). Hit Ctrl + R, not Ctrl + D to view.
Related
I've had a functioning RStudio setup for a while, on a Manjaro machine.
But suddenly it seems to no longer to able to interpret latex code. (Or is this an RMarkdown issue?). When I try to Knitr a pdf, I now get the following error message in the 'render' window:
You may need to add $ $ around a certain inline R expression r in Labb2New.Rmd (see the above hint). See https://github.com/rstudio/rmarkdown/issues/385 for more info.
Error: LaTeX failed to compile Labb2New.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Labb2New.log for more info.
Execution halted
What could be the issue here?
I've done no installation or updates (that I'm aware of) since Rstudio last worked.
There's tons of ways that you can compile Latex inside RMarkdown in RStudio, it can be confusing... so personally I did this:
Be sure to install everything in ONE SINGLE USER and not in the system, it could cause directory conflict and MiKtex somehow doesn't work for the whole systems, i read other comments where they can't solve that problem, me neither xD.
You should have all this requirements
R (you already installed it)
RStudio
MikTex
TeX Live
Install from CRAN
install.extras(repos = "http://cran.us.r-project.org")
THEN
## Install from CRAN
install.packages('rmarkdown')
Everything should work, you should have enough space memory to do this though. I just had this exact same problem yesterday so i reviewed my history x3
anyway if you have other problem with this process please feel free to tell me, be sure to read the documentations for what I listed there's lots of requirements inside, so probably is that!
I randomly started getting the error messages below while trying to run a RMarkdown document. I am on a Windows, so I deleted the TinyTex subfolder within the AppData folder and reran tinytex::install_tinytex(). That installed but didn't fix the error messages, so I tried tinytex::reinstall_tinytex() but that didn't help.
I know from the error messages I am missing LaTeX packages, so I tried running the code below but it will not run. I assume there is a greater problem at hand, and guidance would be greatly appreciated.
tinytex::parse_install(text = "! LaTeX Error: File `setspace.sty' not found.")
Error messages:
A new version of TeX Live has been released. If you need to install or update any LaTeX packages, you have to upgrade TinyTeX with tinytex::reinstall_tinytex(). If it fails to upgrade, you might be using a default random CTAN mirror that has not been fully synced to the main CTAN repository, and you need to wait for a few more days or use a CTAN mirror that is known to be up-to-date (see the "repository" argument on the help page ?tinytex::install_tinytex).
tlmgr.pl: Local TeX Live (2021) is older than remote repository (2022).
Cross release updates are only supported with
update-tlmgr-latest(.sh/.exe) --update
See https://tug.org/texlive/upgrade.html for details.
! LaTeX Error: File `setspace.sty' not found.
! Emergency stop.
<read *>
Error: LaTeX failed to compile markdown.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See markdown.log for more info.
Execution halted
Two possibilities:
set your mirror to the historic version which still has 2021, e.g.
tinytex::tlmgr("option repository https://ftp.tu-chemnitz.de/pub/tug/historic/systems/texlive/2021/tlnet-final")
install vanilla texlive2022 from https://tug.org/texlive/
(I'd go with the second solution. If you use a complete texlive installation instead of tinytex, you'll never again have to deal with missing packages)
The error messages above should no longer appear for anyone who is trying to knit a pdf with RMarkdown based on the feed at https://github.com/yihui/tinytex/issues/293. TeX Live released their 2022 version on April 3, so there is a window of time where tinytex needs to update.
One could also use #samcarter_is_at_topanswers.xyz recommendations and install TeX Live 2022 themselves (https://tug.org/texlive/acquire-netinstall.html), and update their path within RStudio (How to teach R find the texlive directory when using rstudio?).
i have a knitr based Rnw file that is compiling to pdf perfectly fine in RStudio on mac (v0.97.316) and knitr (v1.1) but in a windows enviornment (same versions) i get a compilation error. I've checked the options in RStudio in both environments and they are consistent.
It appears that the windows setup is always injecting: "\SweaveOpts{concordance=TRUE}" into the ".tex" file even though i have no such flag in the Rnw file, and/or if i toggle the settings in the preferences, and/or if i add the "opts_knit$set(concordance=FALSE)" options to a knitr settings chunk. If i drop the line from the ".tex" file and compile it manually at the cmd prompt the output is generated as expected.
I'm not sure if this is an RStudio or knitr problem, but any pointers would be appreciated.
Note, i've also posted this question on the RStudio support board (http://support.rstudio.org/help/discussions/problems/5039-knitr-compile-problems-with-rstudio-windows?unresolve=true).
The reason that it was injecting \SweaveOpts{concordance=TRUE} is likely to be your weaver was Sweave instead of knitr, and you also enabled Rnw concordance: http://www.rstudio.com/ide/docs/authoring/rnw_weave But I cannot say for sure it is not a bug for the Windows version of RStudio. Anyway, it is easy to verify if it is an RStudio problem -- open the Compile PDF panel and you should see the log like this:
If your weaver was Sweave, you will see something like this instead:
This is my configuration (I'm under Ubuntu):
If you are using knitr indeed, and RStudio still inserts \SweaveOpts{concordance=TRUE}, I guess it must be a bug of RStudio.
I encountered this problem with "R CMD build KFAS-master" downloaded 2016-04-24 as "KFAS-master.zip" clicking "Download ZIP" from KFAS on GitHub (https://github.com/helske/KFAS). I'm unable to replicate the problem, but the work around I used was to find the line mentioned in the pop-up (copied below), and comment it out by preceding it with "%%".
After downloading it, I unzipped it and changed the name of the folder to "KFAS". Then I got a command prompt and navigated to the directory containing the KFAS-master folder renamed as KFAS. This time "R CMD build KFAS" worked as expected. Then I opened ~KFAS/vignettes/KFAS.Rmw in RStudio 0.99.893, the current version as of 2016-04-26. I changed something and saved the result. When I repeated "R CMD build KFAS", I got the problem portrayed in the image below.
Jouni Helske directed me to this post. I commented out line 69 mentioned in the screen shot below by prepending "%%" to "\SweaveOpts{concordance=TRUE}". I saved the result, and "R CMD build KFAS" worked.
Something seems to occasionally insert a line like "\SweaveOpts{concordance=TRUE}" into a *.Rnw file, but I don't know what it is. I'm running R 3.2.4 on a MacBook Pro with OS X 10.11.2.
Thanks to Yihui and others for earlier posts in this thread.
screen shot showing pop-up complaining, "It seems you are using the Sweave-specific syntax in line(s) 69... ."
I had the same problem even when knitr was set for "Weave Rnw files using" by default.
I solved it by going to Tools/Global Options/Sweave and setting "Weave Rnw files using" to Sweave and pressing Ok. Then, I went back and set it back to knitr, and everything works fine now.
I guess it was indeed Rstudio bug
Knitr / Rmarkdown Execution halted
When I run Knitr and Rmarkdown, even with the knitr example scripts, I get the below error message.
Error in system(paste(shQuote(pandoc_path), "--version"), intern = TRUE) :
'"C:/Program Files/RStudio/bin/pandoc/pandoc"' not found
Calls: <Anonymous> ... get_pandoc_version -> with_pandoc_safe_environment -> force -> system Execution halted
I have installed and loaded knitr and rmarkdown from the libraries and alternatively using dev tools to get the most recent versions from github.
As it was working previously and I haven't changed any settings, I was wondering whether it might be due to the new R release and whether that has caused this?
I have tried uploading pandoc to the specific location it requested in the error but the online guidance was difficult to follow so didn't move into folder just it case it made it worst, as it was not required before I was confused as to why it was an error?
Not sure what else to try out, I have googled, stackflowed and explored knitr and pandoc webpages for any clues but with not success.
If anyone knows how to fix this as soon as possible I would be very grateful!!
I know this is a very old question, but I had the exact same issue, where knitting an Rmd file worked perfectly yesterday, and today, stopped working with the identical error message above. Even knitting the default Rmd starter document failed.
It's possible that a Windows patch was applied by our IS folks that may have broken something, as I had not changed my setup at all.
Doing a Sys.which('pandoc') suggested that it was looking in the wrong place (a user-specific location).
Updating RStudio did not help. Adding the following to my Rmd file also did not work:
Sys.setenv(RSTUDIO_PANDOC="PATH_TO_MY_PANDOC_BIN")
What eventually worked was a subset of the response by Ivo Fugers:
install.packages('installr')
install.pandoc()
(I wasn't paying close attention but think I allowed it to uninstall another version of pandoc.) After a system restart, knitting is working again.
Hope this helps folks in the future, as it seems to be a problem that still sporadically recurs.
I had a similar problem in a Statistical Computing class. A solution that worked for some of my classmates (including myself) is installing a few version of MikTex (takes about an hour). Otherwise, this is a solution that our teacher gave us:
So here is a possible strategy when you end up with a pandoc error, or when your Latex Equations do not show up in the 'markup':
Step 1
Re-install pandoc manually in your R console:
installing/loading the package:
if(!require(installr)) { install.packages("installr"); require(installr)} #load / install+load installr
Installing pandoc
install.pandoc()
Step 2
Download the the self-extracting protext.exe file from http://www.tug.org/protext/ . Install MikTex from this .exe file using the default settings...
2a. Make sure you allow Protext to install packages on the fly without asking permission.
Step 3
Look at https://tex.stackexchange.com/questions/81739/the-memory-dump-file-could-not-be-found , not the solution. Change the persmissions of all users in
C:\Users\YourUsername\AppData\Local\Temp
and
C:\Program Files\MikTex 2.9\
to full control.
How to do this? Go to C:\Users\YourUsername\AppData\Local , and right click on the folder Temp. Go to properties --> Security... and make sure all users listed there (even the trusted install) will have full control acces.
I faced the exact same problem yesterday and shocked because everything was working until day before yesterday. I was finishing my project in R markdown and it started throwing error.
Without having much help, I just have upgraded my RStudio to its latest version (0.98.1091). It took less than 10 minutes and everything started working as it was. I believe this sudden chocking was due to Windows patch update, but not 100% sure.
change your file name "C:/Program Files/RStudio/bin/pandoc/pandoc" into
"C:/ProgramFiles/RStudio/bin/pandoc/pandoc" or something else.
It doesn't allow space in the file address (like Program Files).
I'm working on getting knitr setup. I installed the latest version of R (2.15.1), Lyx 2.0 including the MiKTex 2.9 distribution, and RStudio 0.96.304 on a Windows 7 Enterprise box. I can get pdflatex output if I open up Lyx and simply view the tutorial, so the basic system is working. I then downloaded the minimal Rnw example saved it in my working directory as testknitr.Snw, opened that file in RStudio, and pressed the compile PDF button. The knitr output completes with a single warning about the parser package, and produces a file testknitr.tex. pdflatex.exe then runs, but fails, and the particular error in the log file seems to be
! LaTeX Error: Environment alltt undefined.
I received the same error when attempting to compile testknitr.tex using TexWorks. I created that file from inside R using knit("testknitr.Rnw") - different extension because of the default in RStudio. I did tell MikTek to update packages automatically when compiling. A bit of research on CTAN suggests that the alltt environment is part of the ltxbase package, which is installed when I look at the package manager. In fact it seems like a pretty core part of the whole thing!
OK - I was reading the comments on the minimal example page, and discovered a workaround to that problem, and that it is a known bug as of 19 hours ago. And yes, I doublechecked that RStudio is set to use knitr, not sweave. I now get a new error:
! LaTeX Error: Command \textquotesingle unavailable in encoding T1.
EDIT: OK! it turns out that error isn't fatal - there's a lovely pdf of the minimal example sitting in the working directory if one takes the time to look. Somewhat alarming that RStudio thinks compilation failed when it didn't?
The workaround, perhaps obvious to an experience LaTex-ie, is to add
\usepackage{alltt}
to the file. According to Yihui's comment this will be fixed in future versions, or now if you want to get the development version from github. I also tested #Yihui's comment above that the line
\usepackage[T1]{fontenc}
could be commented out. This fixes the 2nd issue in the question, and RStudio now treats the compilation as successful, cleaning up (some?) intermediate files and immediately previewing the pdf.