I have this basic R markdown file:
---
title: 'test'
output:
html_document
---
![myimage](test.png)
The file test.png can be found in the project folder. If I compile the document the first time all is good:
|.................................................................| 100%
ordinary text without R code
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS /Users/nf/test/test_file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/x0/87l48swx73lg569_81cctqt00000gp/T//RtmpYYJgwp/rmarkdown-stree426f43954e.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight
processing file: test_file.Rmd
output file: /Users/nf/test/test_file.knit.md
Output created: test_file.html
But if I compile it the second time (without changing anything) I get this error:
|.................................................................| 100%
ordinary text without R code
processing file: test_file.Rmd
output file: /Users/nf/test/test_file.knit.md
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS /Users/nf/test/test_file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/x0/87l48swx73lg569_81cctqt00000gp/T//RtmprFBDzb/rmarkdown-streef56b8e7e99.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight
pandoc: Could not fetch test.png
test.png: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 67
Execution halted
If I look into my project folder the image test.png is gone. In the process of the first compilation of the document the image get's deleted. I can reproduce it every time. And then of course it is missing for the second compilation. This also happens with .RData files I load inside R chunks. I even tried to keep the files in a separate folder and copy them every time inside my project folder I compile my document (with the command file.copy()). But then the files in the outside folder disappear as well. It seems that every file mentioned in the markdown document gets deleted or moved somewhere else.
What I found out is that this happens only if the name of the markdown file contains spaces like test file.Rmd. Html pages produced from this file are formated test_file.html so I guess some transformation to a filename without spaces takes place.
I think this is a bug I should report on some bug tracker, but since I don't know whether this is about rmarkdown, knitr, pandoc, RStudio or something else I post it here.
My session info:
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)
locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.11
loaded via a namespace (and not attached):
[1] tools_3.2.2
Updating to rmarkdown_0.9.2 fixed the problem according to this issue: https://github.com/rstudio/rmarkdown/issues/580
Related
I'm having problems knitting an .rmd file to a .html (and pdf for that matter) file using rmarkdown. The report that I'm trying to knit in the following example is just the example report you get when starting a new rmakrdown document.
This is the error message I get:
==> rmarkdown::render('C:/Users/***/Documents/test/test.Rmd', encoding = 'UTF-8');
processing file: test.Rmd
|.......... | 14%
ordinary text without R code
|.................... | 29%
label: setup (with options)
List of 1
$ include: logi FALSE
|.............................. | 43%
ordinary text without R code
|........................................ | 57%
label: cars
|.................................................. | 71%
ordinary text without R code
|............................................................ | 86%
label: pressure (with options)
List of 1
$ echo: logi FALSE
|......................................................................| 100%
ordinary text without R code
output file: test.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output test.html --email-obfuscation none --self-contained --standalone --section-divs --template "\\storage-***.se\home$\****\My Documents\R\win-library\4.0\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\*****\AppData\Local\Temp\Rtmpc1mrLs\rmarkdown-str511010115ff7.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --lua-filter "\\storage-****.se/home$/****/My Documents/R/win-library/4.0/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "\\storage-***-se/home$/*****/My Documents/R/win-library/4.0/rmarkdown/rmd/lua/latex-div.lua"
pandoc.exe: \\: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Execution halted
Pandoc tries to reach a file saved on my computer but for some reason can't find it. This is my work computer where everything is saved locally and then uploaded to a server. I have talked with IT at my office and they don't know why it wont work.
I have managed to get a rmarkdown report before when I moved EVERYTHING (r project, packages and the files where I do my analysis) to a map that is not uploaded to the backup server.
However, this is not a safe way since there is no backup, obviously. I've tried to just have the r-project locally for the knitting but it doesn't work either.
Why can't pandoc find this binary file and is there a way I can get it to work without having to risk the safety of my work? If not, is there another way of creating similar files without pandoc?
I have seen similar questions but nothing that could give me any answers. Or give the people at the IT department any clues.
Thanks!
Johanna
Here is the session information:
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252
[3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Sweden.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.2 htmltools_0.5.0 tools_4.0.2 yaml_2.2.1 rmarkdown_2.3
[6] knitr_1.29 xfun_0.16 digest_0.6.25 rlang_0.4.7 evaluate_0.14
Versions:
> version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.2
year 2020
month 06
day 22
svn rev 78730
language R
version.string R version 4.0.2 (2020-06-22)
nickname Taking Off Again
> pandoc_version()
[1] ‘2.7.2’
> pandoc_available()
[1] TRUE
I have solved the problem!
The actual problem was the path of the rmarkdown package. It was on my //storage... path. What I finally had to do was to go into system settings and add an environmental variable for R_LIBS_USER to my H:/ path. Now when pandoc is looking for the rmarkdown details it can find the path.
Using this link as research. try using the RELATIVE path for your file. in this one you are using the absolute path C:/Users/... and this temporarily changes R's working directory.
Mac Os: 10.11.6
R version: 3.3.1
MacTex: 2016 / TexLive: 6.2.2
RMarkdown: 1.0.9014
Knitr: 1.14
Pandoc: 1.17
RMarkdown fails to knit PDF when latex commands such as:
\textcolor{blue}{Character String}
are present in the .rmd file. The error output is:
/usr/local/bin/pandoc +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template ~/R/3.3/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine /Library/TeX/texbin/pdflatex --variable graphics=yes --variable 'geometry:margin=1in'
! Undefined control sequence.
l.105 \textcolor
pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted
Inclusion of an r code chunk with echo = TRUE such as:
```{r, echo = TRUE}
# I am a glitch
```
in the .rmd file allows for the successful creation of the PDF document.
If all r code chunks in the .rmd file are set with echo = FALSE or equivalent statements, the PDF file will not knit regardless of latex engine used if latex commands such as /textcolor are present. If only latex commands such as \begin{tabular}, many, etc… are used the error is not present.
Addition of “header-includes: \usepackage{color}” to the YAML header, as seen below, addresses the issue. However, it is unclear why insertion of an “echo = TRUE” R-code chunk also resolves the issue.
---
title: "test"
output: pdf_document
header-includes: \usepackage{color}
---
Interestingly, with a previous version of the R-Studio suite, as see below, inclusion of “header-includes: \usepackage{color}” in the YAML header, did not appear necessary prior to use of commands such as "\textcolor{blue}{Character String}" in the .rmd file.
Mac OS: 10.10.5
R Version: 3.2.2
MacTex: 2014 / TexLive: 6.2.0
Rmarkdown: 1.0
Knitr: 1.13
Pandoc: 1.13.1
I have been trying to make a simple PDF using the "Knit PDF" functionality from RStudio.
Every time I try to convert the sample doc to a PDF I get the following message:
|............. | 20%
ordinary text without R code
|.......................... | 40%
label: unnamed-chunk-1
|....................................... | 60%
ordinary text without R code
|.................................................... | 80%
label: unnamed-chunk-2 (with options)
List of 1
$ echo: logi FALSE
|.................................................................| 100%
ordinary text without R code
"PATH1" +RTS -K512m -RTS ECON_404_HW_4.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output DOCTITLE.pdf --template "PATH2" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"
output file: DOCTITLE.knit.md
pandoc.exe: pdflatex not found. pdflatex is needed for pdf output.
Error: pandoc document conversion failed with error 41
In addition: Warning message:
running command '"PATH1" +RTS -K512m -RTS DOCTITLE.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output DOCTITLE.pdf --template "PATH2" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' had status 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 edited out the path locations on my PC as well as the intended title of the PDF (changing them with "PATH1", "PATH2", and "DOCTITLE" where appropriate.)
I have used the link to download MikTex multiple times to multiple locations, I have tried using ProTex as some others have had success doing. I have tried adding the bin of MikTex to the environment but no matter what, it seems that R is unable to find Tex. Most of the advice available is for OSX, and I have tried adapting those solutions for windows to no avail.
#Matty R, after getting that error I restarted Rstudio, and then it asked me to instally packages like "upquote" using MikTex Package Manager, after three or four packages installation I got the pdf file created.
I have search the answers in the forum, but they dont seem to work.
I am knitting a pdf document in Rstudio using the knitr package. I am using Windows 7 and Rstudio.
pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" PA1_template.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output PA1_template.pdf --template "C:\R\Library\rmarkdown\rmd\latex\default.tex" --highlight-style tango --latex-engine pdflatex --variable "geometry:margin=1in"' had status 43
Execution halted
Thanks,
Luis
I had the same issue but on Linux using the latest rmarkdown package and pandoc 1.13. In essence it seems like pdflatex does not work with the output generated by pandoc - you need to replace the latex-engine pdflatex with xelatex (part of TeXLive)
For rmarkdown my solution was to edit the file
rmarkdown/templates/tufte_handout/resources/tufte-common.def
and replace the line
\typeoutbool{pdfatex}{#tufte#pdf}
with
\typeoutbool{xelatex}{#tufte#pdf}
Then xelatex will be used instead of pdflatex to generate pdf's with rmarkdown
I faced the same issue, here are the steps I took to solve the problem:
install devtools in Rstudio (install.packages(devtools))
install rmarkdown (devtools::install_github("rstudio/rmarkdown"))
fix the files tufte-common.def and tufte-handout.tex in ~/R/x86_64-pc-linux-gnu-library/3.2/rmarkdown/rmarkdown/templates/tufte_handout/resources/
If the rmarkdown installation did not go smoothly this way then do it like this (devtools::install_github("git://github.com/rstudio/rmarkdown"))
In tufte-common.def do the following:
Add this line
\typeoutbool{xelatex}{#tufte#pdf}
uncomment this line
\typeoutbool{xelatex}{#tufte#xetex} remember % is used to uncomment latex
Add the following lines in tufte-handout.tex:
% UTF encoding
\usepackage[utf8]{inputenc}
When I tried to compile a document I still got the following error (! Font \XeTeXLink#font=pzdr at 0.00002pt not loadable: Metric (TFM) file or ins talled font not found.), I tackled it by installing texlive-fonts-recommended:
sudo apt-get install texlive-fonts-recommended
I had a similar problem. Telling knitr where to find the pdf-engine was necessary even though I had it on the windows path. Here is the header of the knitr.Rmd-document, that solved the problem for me:
---
title: "XXX"
author: "XXX"
date: '2016-11-28'
output:
pdf_document:
keep_tex: yes
pandoc_args:
- --latex-engine
- C:/Program Files/MiKTeX 2.9/miktex/bin/x64/pdflatex.exe
toc: yes
---
I am on OSX Mavericks and have the newest version of RStudio (0.98.994), R (3.1.1) and MacTex 2014 (25 May 2014). All R packages have been updated. When I try to preview a markdown file as a PDF, I get the following error:
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc README.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output README.pdf --template /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable geometry:margin=1in
pandoc: Error producing PDF from TeX source.
Error: pandoc document conversion failed with error 43
Execution halted
I don't know what I have done wrong but this simply doesn't work.
I was getting this same error while trying to use a markdown template, papaja, on a mac (OS X), even though I had the full version of MacTex installed.
What ultimately fixed the problem for me was installing pandoc on my computer: https://github.com/jgm/pandoc/releases/
As soon as I installed it, I was able to knit the markdown file into a PDF. Hopefully, this solution works for you, too!
You might need to install framed latex package. see the following links
PDF rendering in Rmarkdown2/
https://github.com/rstudio/rmarkdown/issues/39