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
Related
Related to this question IPython/Jupyter Problems saving notebook as PDF
On macOS,
jupyter nbconvert example.ipynb --to latex
works just fine. pandoc is on my path at /usr/local/bin/pandoc.
However, within the running notebook, "File: Download as: Latex" results in an error.
500 : Internal Server Error
The error was:
nbconvert failed: Pandoc wasn't found.
Please check that pandoc is installed:
http://pandoc.org/installing.html
Is there a path variable I should be setting somewhere?
output file: test.knit.md
! pdflatex: warning: running with administrator privileges
! Sorry, but C:\Users\jjw11\AppData\Local\Programs\MIKTEX~1.9\miktex\bin\x64\pdflatex.exe did not succeed.
! The log file hopefully contains the information to get MiKTeX going again:
! C:\Users\jjw11\AppData\Local\MiKTeX\2.9\miktex\log\pdflatex.log
Error: Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info.
Execution halted
I got this error message while I was trying to generate pdf file using r markdown.
How can I solve this? I installed tinytex using install.packages("tinytex")
I also tried tinytex::reinstall_tinytex(). But I got this error message
tinytex::reinstall_tinytex()
Error in system2("tlmgr", args, ...) : '"tlmgr"' not found
In addition: Warning message:
In tlmgr(c("info", "--list", "--only-installed", "--data", field, :
TeX Live does not seem to be installed. See https://yihui.name/tinytex/.
I installed tinytex using "tinytex::install_tinytex()".
When I installed tinytex using "tinytex::install_tinytex()", I got warning which implies other Latex distribution was already installed.
I tried to generate pdf file after I installed tinytex using "tinytex::install_tinytex()".
But this time I got this error message.
output file: test.knit.md
"C:/PROGRA~1/Pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template "C:\PROGRA~1\R\R-35~1.3\library\RMARKD~1\rmd\latex\DEFAUL~3.TEX" --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes"
! Package inputenc Error: Unicode character ??(U+B144)
(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 https://bookdown.org/yihui/rmarkdown/pdf-document.html
Error: Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info.
In addition: Warning message:
In grepl("==> Fatal error occurred", x[i], fixed = TRUE) :
input string 1 is invalid in this locale
Execution halted
Do I have to uninstall other Latex distributions?
Then, how can I uninstall other Latex distributions?
I've solved my problem.
First, I had to install Tex distribution.
I could install Tex distribution by using tinytex::install_tinytex().
Second, I was using CJK(Chinese, Japanese, Korean) characters.
so I had to use different latex engine.
In addition, I had to set mainfont which contains my language(korea) in the YAML header.
I attach YAML header which solved my problem.
title: "Untitled"
author: "jjw"
date: "2019년 10월 17일"
output:
pdf_document :
latex_engine : xelatex
mainfont : NanumGothic
I was getting the same error after installing MikTex. I then re-started RStudio and it worked for me.
I also had the same error but it was fixed after I used the following code
tinytex::install_tinytex() it was fixed.
But first I had Miktex installed which gave a total different error so I unstaulted it first then I run the code above and problem solved.
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
---