Markdown which previously rendered nicely in html simply using the Rstudio 'knit' button now will not. This is windows, R3.4.1, and updated knitr and rmarkdown, and the whole worked fine last week. I have minimal .rprofile, and have no packages loaded prior to knitting the minimal doc below. A 'manual' knit as follows works ie the gvisTable and also mathjax is properly rendered in html, so this should not be a problem with my internet connection today (I also tried an alternative connection but no different):
knitr::knit(in,out=md)
markdown::markdownToHTML(md,ht)
However the following (which I believe is what the 'knit' button does, borrowed from What does “Knit HTML” do in Rstudio 0.98?) throws an error
rmarkdown::render(pp, 'html_document', 'new_titel.html')
The error message in the is rather long so I append it now, URLs censored because I lack reputation. I have tried googling, SO etc but no result. Help appreciated.
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS tmp1.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output new_titel.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "censored" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "censored" --mathjax --variable "censored"
pandoc.exe: Could not fetch censored
HttpExceptionRequest Request {
host = "www.google.com"
port = 443
secure = True
requestHeaders = []
path = "/jsapi"
queryString = "?callback=displayChartTableID1d98417f33e7"
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
}
(InternalException (HandshakeFailed Error_EOF))
Warning: running command '"" +RTS -K512m -RTS tmp1.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output new_titel.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "censored" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "censored" --mathjax --variable "mathjax-url:censored-not-enough-reputation"' had status 67
Error: pandoc document conversion failed with error 67
---------------the minimal document, which renders fine if I comment out the gvisTable line or use the markdown route described above and not rmarkdown:
---
title: "Untitled"
output:
html_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
####title
body
$x=y$
```{r , echo=FALSE, results='asis'}
require(knitr)
kable(mtcars[1:2,])
require(googleVis)
gvisTable(mtcars)
```
I was having the same problem since a few days with a Markdown file which previously rendered fine.
I am having Windows 7 x64 SP1, R version 3.4.1, googleVis 0.6.2, rmarkdown 1.6, knitr 1.17.
There are two workarounds which solved the issue for me:
1)
Running the script with
---
title: "Untitled"
output:
html_document:
self_contained: false
---
worked, though the output is no longer a standalone HTML file but has dependencies in external files.
This is not an option for me since I need to be able to share the HTML file with colleagues.
2)
The only other fix I found was to use a newer Pandoc version. I was previously having pandoc 1.17.2 and am now running pandoc 2.0.
You can check your pandoc version in
C:\Program Files\RStudio\bin\pandoc
by running the command pandoc --version in the command prompt.
The way I updated Pandoc was to
download the nightly-build pandoc-windows-7c20fab3.zip from
https://github.com/pandoc-extras/pandoc-nightly/releases/tag/hash-7c20fab3
unzip and replace the pandoc.exe and pandoc-citeproc.exe in
C:\Program Files\RStudio\bin\pandoc
with their newer versions (while keeping the old ones as backup).
Running the Markdown script with the updated Pandoc first yielded an error (pandoc document conversion failed with error 2) but this was resolved with
---
title: "Untitled"
output:
html_document:
smart: false
---
Probably not the most elegant solution, but so far the only one that worked for me.
Related
Using
- RStudio Version 1.2.1335
- R version
I am able to knit the R markdown file to HTML and Word, but fail with PDF. I keep receiving the same error message telling me that it is unable to locate the "Palatino" font.
The file is successfully processed (all chunks run).
I have tried re-installing and resetting Miktex and Tinytex, as well as R itself. I am pretty new to this, so I am unsure how to proceed. Should I install TexLive?
This is the header of the file I am trying to run:
--
title: "Assignment 1"
fontsize: 11pt
header-includes: \usepackage{fancyhdr}
geometry: "left=.5in,right=.5in,top=1in,bottom=1in"
output:
pdf_document:
latex_engine: xelatex
md_extensions: +inline_notes
number_sections: no
word_document: default
mathfont: Palatino
monofont: Courier
mainfont: Palatino
sansfont: Helvetica
subtitle: \textbf{Due Wednesday, 11 September 2019 (beginning of class)}
fontfamily: mathpazo
---
And this is the error I continue to receive, without rendering of a PDF file:
output file: PBHLTH252-Assignment-1_post.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS PBHLTH252-Assignment-1_post.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+inline_notes --output PBHLTH252-Assignment-1_post.tex --template "C:\Users\UYser\Documents\R\win-library\3.6\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --pdf-engine xelatex --variable graphics=yes --lua-filter "C:/Users/UYser/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --variable "compact-title:yes"
tlmgr search --file --global "/Palatino."
! Package fontspec Error: The font "Palatino" cannot be found.
! kpathsea: Running mktextfm Palatino
! The command name is C:\Users\UYser\AppData\Roaming\TinyTeX\bin\win32\mktextfm
! kpathsea: Appending font creation commands to missfont.log.
Error: Failed to compile PBHLTH252-Assignment-1_post.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See PBHLTH252-Assignment-1_post.log for more info.
In addition: Warning message:
In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
Failed to find a package that contains Palatino.
Execution halted
I tried following this thread, https://github.com/yihui/tinytex/issues/81, with no success:
Running this suggested code
tinytex::tlmgr_search("/Palatino[.](tfm|afm|mf|otf)")
results in:
package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable)
Running this one
tinytex::tlmgr_install("multirow")
gives me the following error:
tlmgr install Palatino.
'afm' is not recognized as an internal or external command,
operable program or batch file.
tlmgr update --self
tlmgr.pl: package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr.pl: no self-updates for tlmgr available.
tlmgr install Palatino.
'afm' is not recognized as an internal or external command,
operable program or batch file.
Any help is appreciated!
It looks like you got the template from a Mac user while you are on Windows. The fontnames are different there. Instead of Palatino you could use Palatino Linotype. I am not sure if Helvetica and Courier will work. If not, you could use Arial and Courier New.
However, that sounds like a rather ugly font combination. Palatino is a very fine font, but neither Helvertica/Arial nor Courier (New) fit well. Besides, I don't think that normal Palatino fonts are set-up to be used for math. You could use Asana Math instead, which comes with MikTeX/TinyTeX.
I used to have similar problems. My solution sounds naive (or silly), but it worked perfectly for me. Instead of debugging, in RStudio:
install rticles package
start a new R Markdown file
choose one of journal article templates such as PNAS Journal Article, Springer Journal Article, or Elsevier Journal Article...
knit the template.
Then, it will be trying to automatically install missing LaTeX packages...
You may want to try a few journal templates. It worked for me, and I hope this will solve your problem as well. Enjoy it!
In a previous question knitr2pdf eclipse : how to configure?, I tried to set up eclipse to work with knitr2pdf, Yihui Xie was kind enough to give me a very prompt answer . Now I'm stuck one step further.
here is my file
---
title: "knit2pdf test"
author: "cedric"
date: "27/10/2017"
output: pdf_document
---
```{r}
plot(rnorm(1:10))
```
When running this file, I get the following answer
knit2pdf(input= "C:/workspace/p/example_scripts/test_knit2pdf.Rmd")
processing file: C:/workspace/p/example_scripts/test_knit2pdf.Rmd
|................................ | 50%
ordinary text without R code
|.................................................................| 100%
label: unnamed-chunk-1
output file: test_knit2pdf.md
Error: running 'texi2dvi' on 'test_knit2pdf.md' failed
LaTeX errors:
! Emergency stop
*** (job aborted, no legal \end found)
! ==> Fatal error occurred, no output PDF file produced!
! ==> Fatal error occurred, no output PDF file produced!
In addition: Warning message:
running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texify.exe" --quiet --pdf "test_knit2pdf.md" --max-iterations=20 -I "C:/Program Files/R/R-3.4.2/share/texmf/tex/latex" -I "C:/Program Files/R/R-3.4.2/share/texmf/bibtex/bst"' had status 1
I've tried to find questions reporting a similar problem, Using knit2pdf with Rmd files the answer was to try to use render instead of knit2pdf which is not what I want. This is not a problem with eclipse, but me failing to run the knit2pdf properly. Manually running the command knit2pdf("test_knit2pdf.Rmd") gets the same error. Again, maybe someone will have run into a similar problem and will be able to help me, is my file badly formed, have I missed something ?
To process a Rmd document using rmarkdown::render() the following steps are necessary
Install pandoc
Edit windows path, system environment variables, copy path to pandoc which is located there C:\Users\me\AppData\Local\Pandoc
Go to eclipse, Run > External Tools > External Tools Configurations
Click on wikitext + R document processing
In the dropdown menu, topright, named load Preset example, click the PDF using Rmarkdown, single steps. In 2/ produce output everything is configured to produce pdf as output.
I followed this excellent post https://www.r-bloggers.com/processing-rmarkdown-documents-with-eclipse-and-statet/ which helped me a lot.
Now I can run by clicking on the render_markdown button in eclipse and get
rmarkdown::render(input= "C:\\workspace\\p\\example_scripts\\testmd.Rmd", output_format= "pdf_document", output_file= "C:\\workspace\\p\\example_scripts\\testmd.pdf", encoding= "UTF-8")
processing file: testmd.Rmd
|...................... | 33%
ordinary text without R code
|........................................... | 67%
label: unnamed-chunk-1
|.................................................................| 100%
ordinary text without R code
output file: testmd.knit.md
"C:/Users/me/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS testmd.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc2806c2b6c59.pdf --template "C:\PROGRA~1\R\R-34~1.2\library\RMARKD~1\rmd\latex\DEFAUL~3.TEX" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"
Output created: C:\workspace\p\example_scripts\testmd.pdf
I am trying to create a PDF file using R Markdown. I received error 43 when I ran it. I tried create word file and HTML using R Markdown and it works fine. Only the PDF file does not work.
processing file: Test_New.Rmd
|...................... | 33%
ordinary text without R code
|........................................... | 67%
label: unnamed-chunk-1 (with options)
List of 1
$ tidy: logi TRUE
|.................................................................| 100%
ordinary text without R code
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS
Test_New.utf8.md --to latex --from
markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --
output Test_New.pdf --template/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine /usr/local/bin/pdflatex --variable graphics=yes --variable 'geometry:margin=1in'
output file: Test_New.knit.md
dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/pdflatex
Reason: image not found
pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted
My code on R Markdown is the following.
---
title: "Test R Markdown"
author: "Sam Ng"
date: "September 1, 2017"
output:
pdf_document: default
html_document: default
word_document: default
---
# 1. R commands
Testing R commands
```{r,tidy=TRUE}
vector=c(1,2,3) # Create a new vector with three entries
max(vector) # Returns the maximum of a vector
min(vector) # Returns the minimum of a vector
```
I spent hours trying to resolve this. I installed Miktex, but was unable to get the packages directly from the package manager due to sitting behind a firewall at work. I finally was able to resolve this using the following steps:
Install Miktex
Create a folder to install Miktex packages, e.g. "C:\miktex_pkgs"
Go to the CTAN package archive and download the following .tar.lzma files:
-fancyvrb
-framed
-microtype
-miktex-zzdb1-2.9
-miktex-zzdb2-2.9
-mptopdf
-titling
-upquote
-url
Move the above .tar.lzma files to the "C:\miktex_pkgs" folder
Set your packages to download from the local repository: "C:\miktex_pkgs". To do this, go to:
"Miktex Settings" - this is an application
Click Packages
Change Package Repository to "C:\miktex_pkgs"
Go to "Miktex Package Manager" application and install the following packages by right-click, install:
List item
fancyvrb
framed
microtype
mptopdf
titling
upquote
url
I was trying to produce a PDF file with the knitr in RStudio but I encountered a problem. I have read a lot of solutions found on stack overflow and google but they are not very helpful. Could anyone please help me with this? Much obliged!
The error is shown as below:
output file: final_project.knit.md
"C:/Users/JOHNL_~1/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS final_project.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output final_project.pdf --template "E:\R\R-3.2.3\library\rmarkdown\rmd\latex\default-1.15.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"
! Package inputenc Error: Unicode char 骞?(U+5E74)
(inputenc) not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H for immediate help.
...
l.128 \maketitle
Try running pandoc with --latex-engine=xelatex.
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/Users/JOHNL_~1/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS final_project.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output final_project.pdf --template "E:\R\R-3.2.3\library\rmarkdown\rmd\latex\default-1.15.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43
Execution halted
Specification:
Window 8.1 64
RStudio version: 0.99.891 Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) rstudio Safari/538.1 Qt/5.4.1
MikTeX: version 2.9.5840 (basic)
pandoc
Others
I have tried most solutions I can find from stack overflow and it did not work.
So I am afraid solutions like adding latex_engine: xelatex will also fail to solve this.
Could anyone please help me? Thanks a lot!
Best
I have figured out what the problem is, that you have to choose WINDOWS-1252 as your text encoding.
If you have set other types as default, change it at tools> global options > code > saving, choose [Ask] in the default text encoding.
Hope that works for you.
I do not think that it is workable way by switching something or set something.
Just carefully check your code, particularly the part you copy from somewhere, not type it by your self.
I have the same problem recently.
I show you How I solve this problem.
I remove the code from the R markdown part by part to find which part caused this problem. Finally, I found the below part that resulted in the error in my code.
### Platform:Affymetrix A-AFFY-2-Affymetrix GeneChip Arabidopsis Genome [ATH1-121501].
I remember I copy this information from webpage. So I delete them and type this part by myself. It can run and generate the pdf file without any error.
To be clear, I show you the difference between the copy version and the version of my typing:
This is just one example I think. I want to point out that it is always problematic when you copy something from an unknown resource file into your code.
Hope this can help you and other people who were frustrated by this problem.
I have the following R code in one of my RMarkdown scripts:
install.packages("dplyr", repos="http://cran.us.r-project.org")
install.packages("tidyr", repos="http://cran.us.r-project.org")
install.packages("ggplot2", repos="http://cran.us.r-project.org")
library(dplyr)
library(tidyr)
library(ggplot2)
library(scales)
options(scipen = 999)
source("classify.r")
When I "knit" the Markdown to HTML with Shift+Ctrl+K, the packages are successfully installed and loaded. However, when I re-knit it, the packages are installed from scratch, every time - although I already have them, and that takes a while.
I am using RStudio.
How can I circumvent this without having to comment the respective lines?
Since "require returns (invisibly) a logical indicating whether the required package is available" you can conveniently use it for programming to either load the package or, if it's not available, (try to) install it and load it afterwards. So you could modify your code along the lines of:
if (!require(dplyr)) {
install.packages("dplyr")
require(dplyr)
}
This should load the package if it's already available or if not, try to install it and load it afterwards.
```{r chunkNameHere, cache=TRUE}
install.packages("dplyr", repos="REPOLINK")
install.packages("tidyr", repos="REPOLINK")
install.packages("ggplot2", repos="REPOLINK")
library("dplyr")
library("tidyr")
library("ggplot2")
```
The 'cache' flag should ensure the packages aren't reinstalled each time.
Here is the output from the first time I knit:
|................................ | 50%
ordinary text without R code
|.................................................................| 100%
label: chunkNameHere (with options)
List of 1
$ cache: logi TRUE
processing file: Untitled.Rmd
trying URL 'REPOLINK'
Content type 'application/x-gzip' length 3870896 bytes (3.7 Mb)
opened URL
==================================================
downloaded 3.7 Mb
trying URL 'REPOLINK'
Content type 'application/x-gzip' length 72424 bytes (70 Kb)
opened URL
==================================================
downloaded 70 Kb
trying URL 'REPOLINK'
Content type 'application/x-gzip' length 2671874 bytes (2.5 Mb)
opened URL
==================================================
downloaded 2.5 Mb
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc Untitled.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Untitled.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/l2/qcrxbd0s36x7jkk4k2szc9dr0000gn/T//Rtmpcy2bZL/rmarkdown-str8c75262f5f18.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.1/Resources/library/rmarkdown/rmd/h/highlight
output file: Untitled.knit.md
Output created: Untitled.html
And here it is when I run it a second time:
|................................ | 50%
ordinary text without R code
|.................................................................| 100%
label: chunkNameHere (with options)
List of 1
$ cache: logi TRUE
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc Untitled.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Untitled.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/l2/qcrxbd0s36x7jkk4k2szc9dr0000gn/T//Rtmp0WIDxR/rmarkdown-str8c8a542dd362.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.1/Resources/library/rmarkdown/rmd/h/highlight
processing file: Untitled.Rmd
output file: Untitled.knit.md
Output created: Untitled.html