从R Markdown创建PDF文件时出错(失败,错误43)

时间:2017-09-08 15:27:45

标签: r rstudio r-markdown

我正在尝试使用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

```

1 个答案:

答案 0 :(得分:1)

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

  1. 安装Miktex
  2. 创建一个文件夹来安装Miktex软件包,例如: " C:\ miktex_pkgs"
  3. 转到 CTAN package archive 并下载以下.tar.lzma文件:
  4. -fancyvrb
    -framed
    -microtype
    -miktex-zzdb1-2.9
    -miktex-zzdb2-2.9
    -mptopdf
    -titling
    -upquote
    -url

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

      • " Miktex设置" - 这是一个应用程序
      • 点击套餐
      • 将包存储库更改为" C:\ miktex_pkgs"
    3. 转到" Miktex Package Manager"右键单击应用程序并安装以下软件包:

      • 列表项
      • fancyvrb
      • 成帧
      • microtype
      • mptopdf
      • 字幕
      • upquote
      • URL