2014-03-03 146 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合作。