pandoc:生成 PDF 时出错
pandoc: Error producing PDF
目标
实现一个 PDF 函数(网页上的一个按钮),该函数生成一个 PDF,其中包含由 R 创建的绘图,这些绘图在网页上显示为 markdown/knitr,如本教程所示:http://rprogramming.net/create-html-or-pdf-files-with-r-knitr-miktex-and-pandoc/
设置
- Ubuntu 服务器
- 已为 Ubuntu 安装 MiKTeX:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys
D6BC243565B2087BC3F897C9277A7293F59E4889
echo "deb http://miktex.org/download/ubuntu xenial universe" | sudo
tee /etc/apt/sources.list.d/miktex.list
sudo apt-get update
sudo apt-get install miktex
- 已安装 Pandoc
R-code
# 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
问题
我一直在网上寻找,无法找到解决此错误的方法。
MiKTeX 最初是 Windows-only 的 TeX 发行版。它最近被移植到 Linux,其网页显示 "Please beware that MiKTeX for Linux is still in an experimental stage"。
您可能应该使用更主流的 TeX。我不使用 Ubuntu 所以我不确定是哪个发行版,但我猜它是 TeX Live,http://tug.org/texlive/.
目标 实现一个 PDF 函数(网页上的一个按钮),该函数生成一个 PDF,其中包含由 R 创建的绘图,这些绘图在网页上显示为 markdown/knitr,如本教程所示:http://rprogramming.net/create-html-or-pdf-files-with-r-knitr-miktex-and-pandoc/
设置
- Ubuntu 服务器
- 已为 Ubuntu 安装 MiKTeX:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D6BC243565B2087BC3F897C9277A7293F59E4889
echo "deb http://miktex.org/download/ubuntu xenial universe" | sudo tee /etc/apt/sources.list.d/miktex.list
sudo apt-get update
sudo apt-get install miktex
- 已安装 Pandoc
R-code
# 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
问题 我一直在网上寻找,无法找到解决此错误的方法。
MiKTeX 最初是 Windows-only 的 TeX 发行版。它最近被移植到 Linux,其网页显示 "Please beware that MiKTeX for Linux is still in an experimental stage"。
您可能应该使用更主流的 TeX。我不使用 Ubuntu 所以我不确定是哪个发行版,但我猜它是 TeX Live,http://tug.org/texlive/.