2014-03-03 148 views
3

我想我有一个MikTeX问题。在RStudio中,我点击了Knit PDF按钮并收到此错误消息。使用RStudio将* .md转换为* .pdf

这是pdfTeX的版本3.1415926-2.3-1.40.12(MIKTEX 2.9 64位)
pdflatex:内存转储文件可能不会被发现。
pdflatex:数据:pdflatex.fmt

我再接着的第一个指令在http://docs.miktex.org/manual/formats.html 然后我重新启动我的电脑。

此时我不知道是否需要添加内存转储文件,如果有,详细说明如何操作。

然后,我试了编织字,并且工作得很漂亮,生成了一个Word 2007文档。

我正在使用RStudio。我有一个R标记文件Ira.Rmd。它产生了文件Ira.md和Ira.html。我想保存为Ira.pdf。我下载并在命令行上运行了pandoc:

pandoc Ira.md –o Ira.pdf. 

我收到以下错误消息。

Pandoc:从TeX源代码生成PDF时出错。 这是pdfTeX,版本3.1415926-2.3.1.40.12 Pdflatex:无法找到内存转储文件。 Pdflatex:Data:pdflatex.fmt

有人可以用简单的术语解释我可以如何执行此文件转换吗? 我正在使用以下内容。

Windows 7的 [R版本:3.0.2 RStudio版本:0.98.684

我看过https://github.com/rstudio/rmarkdown,但我还是不明白怎么我的文件转换。

UPDATE我在编辑我的问题。

我想将R标记文件转换为PDF。我在R Studio中创建了RMD文件。点击一个按钮,我成功生成了填充R代码的HTML文件。

我,使用R版本3.0.2

我使用RStudio版本0.98.684

我不知道下面是相关的。

我的.Rprofile文件包含以下行。

setwd("C:/Users/Ira/Documents/Statistics") 

我跑以下

> getwd() 
[1] "C:/Users/Ira/Documents/Statistics" 

我尝试所有的建议。谢谢。但是,尝试转换为PDF时,我仍然收到错误消息。我最近的帖子试图发布错误消息。

真正的Rmarkup文件是:IraAppliedStats。Rmd

单击编织生成所需的HTML文件。

我成功运行的命令:

install.packages("devtools"); devtools::install_github("rstudio/rmarkdown") 

library(rmarkdown) 

从我跑到下面的命令控制台,但是我收到一个错误。

render(input = "toPDF2.rmd", output_format = "pdf_document", output_file = "toPDF2.pdf") 

我观察了显示器。在生成几个块之后,我在几个块完成后开始看到如下所示的多个消息。 (out_format(c(“latex”,“sweave”,“listings”,“markdown”)))sanitize_fn else str_c)(路径: 图中路径中的点用_(“ IraAppliedStats_Rmd_files /数字 - 胶乳/无名-块-10" )*

而且每个数据块具有以下消息。

无R代码普通文本

多的文档为R码,当我生成HTML文件时出现相同的行。

错误消息的本质似乎是。

pandoc.exe:从TeX源生成PDF时出错。 这是pdfTeX,版本3.1415926-2.3-1.40.12(MiKTeX 2.9 64位) pdflatex:无法找到内存转储文件。

使用记事本,然后将以下两行添加到IraAppliedStats.md文件的顶部。

*标题:IraAppliedStats.md 输出:pdf_document *

我关闭记事本。

我再次运行该命令。

render(input = "IraAppliedStats.Rmd", output_format = "pdf_document", output_file = "IraAppliedStats.Rmd.pdf") 

这似乎没有帮助,因为我再次收到错误消息,并且没有生成PDF文件。

加完/编辑

+0

看看['pander'](http://rapporter.github.io/pander/) - 可能会让生活更轻松。 – jbaums

+1

我看了一下。有没有可用于进行转换的命令? – user2738483

+1

编织.Rmd,然后使用'Pandoc.convert'。但是你的问题可能会持续下去。也许[this](http://tex.stackexchange.com/questions/114248/error-when-compiling-pdflatex),[this](http://tex.stackexchange.com/questions/81739/the-memory- dump-file-could-be-found)或[this](http://tex.stackexchange.com/questions/36543/error-pdflatex-exe-the-memory-dump-file-could-not-be发现)可能会有所帮助。 – jbaums

回答

4

使用rmarkdown package(包含RStudio版本0.98.682,the current preview release)这是非常简单的RMD转换为PDF格式,有一个单一的功能,将做转换:render

这里是我的markdown文件(在RStudio中启动一个新的Rmd时创建的示例文件),假设它被称为Untitled.Rmd并保存在工作目录中(并且假设您的LaTeX发行版完全更新,并且你有最新版本的Pandoc的):

--- 
title: "Untitled" # you must have lines similar to these in your Rmd file 
output: pdf_document # this is how R knows to convert this file to a PDF 
--- 

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. Click the **Help** toolbar button for more details on using R Markdown. 

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: 

```{r} 
summary(cars) 
``` 

You can also embed plots, for example: 

```{r, echo=FALSE} 
plot(cars) 
``` 

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. 

然后我在控制台中运行:

library(rmarkdown) 
render("Untitled.Rmd") # you could also use "Untitled.md" 

然后我在我的工作目录得到Untitled.pdf,它看起来像这样:

enter image description here

另外,这里是长手的方式来做到这一点,如果你不能使用该版本RStudio的,或不希望在您的降价那些代码title:output:线:

我使用这个
# Load packages. 
    require(knitr) 
    require(markdown) 

    # Process your .Rmd and generate a .pdf file 
    # (including smart punctuation and grey background of code blocks) 
    # For this step you'll need to have two other programs installed on your computer 
    # 1. Pandoc: http://johnmacfarlane.net/pandoc/installing.html 
    # 2. LaTeX: follow the instructions on the Pandoc download page 

    filen <- my_rmd_filename # name of the markdown file without .Rmd suffix 
    knit(paste0(filen,".Rmd")) 
    system(paste0("pandoc -s ", paste0(filen,".md"), " -t latex -o ", paste0(filen,".pdf"), " --highlight-style=tango -S")) 

    # Now find the location on your computer where the PDF file was created: 
    getwd() 

更多关于软件包的详细&版本:

> sessionInfo() 
R version 3.0.2 (2013-09-25) 
Platform: x86_64-w64-mingw32/x64 (64-bit) 

locale: 
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C       
[5] LC_TIME=English_United States.1252  

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] rmarkdown_0.1.4 

loaded via a namespace (and not attached): 
[1] evaluate_0.5.1 formatR_0.10 knitr_1.5  stringr_0.6.2 tools_3.0.2 yaml_2.1.10 
+0

如何下载rmarkdown库? > library(rmarkdown) library(rmarkdown)中的错误:没有名为'rmarkdown'的软件包 – user2738483

+1

使用以下代码行:'install.packages(“devtools”); devtools :: install_github(“rstudio/rmarkdown”)'我认为它也被引入到我引用的RStudio版本中。 – Ben

+0

@ user2738483您必须在markdown文件中具有以'title:Ira.md'和'output:output:pdf_document'开头的行。 – Ben

-2

你必须出师表后安装RStudio与MikTek合作。