【问题标题】:PDF Docs from RMarkdown来自 RMarkdown 的 PDF 文档
【发布时间】:2017-08-11 22:11:26
【问题描述】:

一段时间以来,我一直在尝试从 Rstudio 中的 Rmarkdown 制作 PDF 文档时遇到很多麻烦。我的目标是创建“Journal of Statistical Software”格式,当我运行提供的示例脚本时,出现错误。

脚本:

---
author:
  - name: FirstName LastName
    affiliation: University/Company
    address: >
      First line
      Second line
    email: name@company.com
    url: http://rstudio.com
  - name: Second Author
    affiliation: Affiliation
title:
  formatted: "A Capitalized Title: Something about a Package \\pkg{foo}"
  # If you use tex in the formatted title, also supply version without
  plain:     "A Capitalized Title: Something about a Package foo"
  # For running headers, if needed
  short:     "\\pkg{foo}: A Capitalized Title"
abstract: >
  The abstract of the article.
keywords:
  # at least one keyword must be supplied
  formatted: [keywords, not capitalized, "\\proglang{Java}"]
  plain:     [keywords, not capitalized, Java]
preamble: >
  \usepackage{amsmath}
output: rticles::jss_article
---

# Introduction

This template demonstrates some of the basic latex you'll need to know to create a JSS article.

## Code formatting

Don't use markdown, instead use the more precise latex commands:

* \proglang{Java}
* \pkg{plyr}
* \code{print("abc")}

# R code

Can be inserted in regular R markdown blocks.

```{r}
x <- 1:10
x
```

这样做时我的错误是:

pandoc.exe: pdflatex not found. pdflatex is needed for pdf output.
Error: pandoc document conversion failed with error 41
In addition: Warning message:
running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Untitled.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output Untitled.pdf --template "C:\Users\OPTIMA~1\DOCUME~1\R\WIN-LI~1\3.3\rticles\RMARKD~1\TEMPLA~1\JSS_AR~1\RESOUR~1\template.tex" --highlight-style tango --latex-engine pdflatex' had status 41 
Execution halted

我知道这与下载 MikTex 有关,但我无法找到一种简单的分步下载方法,以便从 RStudio 在 RMarkdown 中运行 PDF 文档。

任何帮助都会很棒,如果您知道任何直接从 R 执行此操作的方法,而不是从 Web 下载内容,那么这将是我认为的最简单的解决方案。

谢谢!

【问题讨论】:

  • pandoc 需要 pdflatex 来创建 pdf。在 Windows 下你可以使用 miktex,你可以在这里找到 miktex.org/download
  • 我在将它复制并粘贴到一个新的 Rmd 文件时遇到了同样的错误,但是使用 RStudio 对话框打开模板编织很好。错误,我猜。
  • 这行得通@Wolfgang 不知道为什么过去行不通,但对现在开始创建 PDF 感到兴奋!谢谢
  • 如果你能把你的解释写下来作为答案,我可以给你信用。

标签: r pdf r-markdown pandoc miktex


【解决方案1】:

pandoc 使用 pdflatex 创建 pdf 输出,因此必须安装。

在 Windows 下,您可以使用 miktex,您可以在 https://miktex.org/download 下找到它

【讨论】:

    猜你喜欢
    • 2023-04-07
    • 2021-07-20
    • 2021-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多