2017-10-05 85 views
1

目標 實現一個PDF功能(在網頁上的按鈕):http://rprogramming.net/create-html-or-pdf-files-with-r-knitr-miktex-and-pandoc/pandoc:產生包含/由R創建曲線被示於與降價網頁knitr一個PDF如圖本教程錯誤產生PDF

設置

  • Ubuntu的服務器
  • 安裝MIKTEX對Ubuntu:

sudo易於關鍵進階--keyserver HKP://keyserver.ubuntu.com:80 --recv密鑰 D6BC243565B2087BC3F897C9277A7293F59E4889

回聲 「的deb http://miktex.org/download/ubuntu xenial宇宙」 |須藤 三通/etc/apt/sources.list.d/miktex.list

sudo易於得到更新

命令和apt-get安裝是MiKTEX

  • 安裝Pandoc

R代碼

# Set working directory 
setwd("/var/www/html/test_Knitr") 

# Create .md, .html, and .pdf files 
print("Debug1: packages loaded") 

setwd("/var/www/html/DATA/test") 
knit("/var/www/html/test_Knitr/reporting_style.Rmd") 
print("Debug2: knit succesfull") 

setwd("/var/www/html/DATA/test") 
print("Debug3: setwd successfull") 

markdownToHTML('/var/www/html/DATA/test/reporting_style.md', '/var/www/html/DATA/test/reporting_style.html', options=c("use_xhml")) 
print("Debug4: markdownToHTML succesfull") 

system("pandoc -s /var/www/html/DATA/test/reporting_style.html -o /var/www/html/DATA/test/reporting_style.pdf") 
print("Debug5: pandoc succesfull") 

reporting_style.Rmd

--- 
title: "Reporting template" 
output: html_document 
--- 


## R Markdown 

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. 

問題 功能完美地運行,直到它到達的最後一部分system("pandoc.." 在這裏,我收到一條錯誤消息:

Sorry, but pdflatex did not succeed. 

You may want to visit the MiKTeX project page, if you need help. 
terminate called after throwing an instance of 'MiKTeX::Core::MiKTeXException' 
    what(): MiKTeX encountered an internal error. 

pandoc: Error producing PDF 

問題 我一直在看遍各地的互聯網,無法找到解決這個錯誤。

回答

2

MiKTeX最初是TeX的Windows分發版本。它最近已被移植到Linux上,其網頁上寫着「請注意,MiKTeX for Linux仍處於試驗階段」。

你應該使用更主流的TeX。我不使用Ubuntu,所以我不確定哪種發行版,但我猜這是TeX Live,http://tug.org/texlive/

+0

謝謝你的回答。你會推薦我用什麼來創建一個在Ubuntu上顯示R圖的網頁上的PDF? – Andrie

+0

我不使用Ubuntu,但您採取的一般方法看起來不錯:R加上RMarkdown加上Pandoc plus TeX。 – user2554330

+1

我已通過刪除miktex並安裝texlive解決了該問題! – Andrie