从r markdown创建PDF文件的错误(错误43)



我正在尝试使用R Markdown创建PDF文件。运行时我收到错误43。我尝试使用R Markdown创建Word文件和HTML,并且效果很好。只有PDF文件不起作用。

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

我在r markdown上的代码如下。

---
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
```

我花了几个小时尝试解决这个问题。我安装了Miktex,但由于坐在防火墙后面,无法直接从包装管理器中获取包裹。我终于能够使用以下步骤解决此问题:

  1. 安装miktex
  2. 创建一个文件夹以安装Miktex软件包,例如" c: miktex_pkgs"
  3. 转到 CTAN软件包存档并下载以下.tar.lzma文件:

-Fancyvrb
-framed
-microtype
-Miktex-Zzdb1-2.9
-Miktex-Zzdb2-2.9
-ptopdf
-Titling
- 称呼
-url

  1. 将上述.tar.lzma文件移动到" C: miktex_pkgs"文件夹
  2. 将您的软件包设置为从本地存储库下载:" C: miktex_pkgs"。为此,请转到:

    • " Miktex设置" - 这是一个应用程序
    • 单击软件包
    • 将软件包存储库更改为" c: miktex_pkgs"
  3. 转到" Miktex软件包管理器"应用程序,然后通过右键单击安装以下软件包,安装:

    • 列表项目
    • fancyvrb
    • 框架
    • 微型
    • mptopdf
    • 标题
    • upquote
    • url

相关内容

最新更新