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.
Related
When I try to render an R Markdown file to pdf, I get the following error:
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS PC_final_proj.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output PC_final_proj.tex --template /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' --variable 'compact-title:yes' --include-in-header /var/folders/95/jvthp8r158q50jv8qjwy75j80000gn/T//RtmpIPFCYS/rmarkdown-str66203f066768.html
output file: PC_final_proj.knit.md
! Package inputenc Error: Unicode character 😎 (U+1F60E)
(inputenc) not set up for use with LaTeX.
Try other LaTeX engines instead (e.g., xelatex) if you are using pdflatex. For R Markdown users, see this
Error: Failed to compile PLSC_final_proj.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See PLSC_final_proj.log for more info.
Execution halted
I have tried the following to resolve the issue but I cannot work around it;
{r message=FALSE}
in all the r chunks, and, changed the line latex_engine: xelatex to the YAML header
title: "Document 6"
output:
pdf_document:
latex_engine: xelatex
Any help is appreciated. Thanks
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 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
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