2017-05-06 90 views
2

我遇到很多問題,試圖用bookdown編譯pdf。 Html和Word格式完美無瑕。我正在運行Windows 10 64位。r bookdown pdf格式不起作用

我安裝了MiKTeX的最新完整版本。我也嘗試過基本版,但沒有解決問題。

這裏是我的會話信息:

Session info -------------------------------------------------------------------------------------------- 
setting value      
version R version 3.3.2 (2016-10-31) 
system x86_64, mingw32    
ui  RStudio (1.0.143)   
language (EN)       
collate Spanish_Spain.1252   
tz  Europe/Paris     
date  2017-05-06     

Packages ------------------------------------------------------------------------------------------------ 
package * version date  source       
backports 1.0.5 2017-01-18 CRAN (R 3.3.2)     
base64enc 0.1-3 2015-07-28 CRAN (R 3.3.2)     
bitops  1.0-6 2013-08-17 CRAN (R 3.3.2)     
bookdown 0.3.14 2017-03-19 Github (rstudio/[email protected]) 
caTools  1.17.1 2014-09-10 CRAN (R 3.3.2)     
digest  0.6.12 2017-01-27 CRAN (R 3.3.2)     
evaluate 0.10 2016-10-11 CRAN (R 3.3.2)     
highr  0.6  2016-05-09 CRAN (R 3.3.2)     
htmltools 0.3.6 2017-04-28 CRAN (R 3.3.3)     
jsonlite 1.4  2017-04-08 CRAN (R 3.3.3)     
knitr  1.15.1 2016-11-22 CRAN (R 3.3.2)     
magrittr 1.5  2014-11-22 CRAN (R 3.3.2)     
markdown 0.8  2017-04-20 CRAN (R 3.3.3)     
mime  0.5  2016-07-07 CRAN (R 3.3.2)     
Rcpp  0.12.10 2017-03-19 CRAN (R 3.3.2)     
rmarkdown 1.5  2017-04-26 CRAN (R 3.3.3)     
rprojroot 1.2  2017-01-16 CRAN (R 3.3.2)     
stringi  1.1.5 2017-04-07 CRAN (R 3.3.3)     
stringr  1.2.0 2017-02-18 CRAN (R 3.3.3)     
yaml  2.1.14 2016-11-12 CRAN (R 3.3.2) 

以下是錯誤:

> bookdown::render_book("index.Rmd", "bookdown::pdf_document2") 


processing file: index.rmd 
    |................................         | 50% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |.................................................................| 100% 
    ordinary text without R code 


output file: index.knit.md 



processing file: confidential-statement.Rmd 
    |................................         | 50% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |.................................................................| 100% 
    ordinary text without R code 


output file: confidential-statement.knit.md 



processing file: signature-page.Rmd 
    |................             | 25% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |................................         | 50% 
    ordinary text without R code 

    |.................................................    | 75% 
label: unnamed-chunk-2 (with options) 
List of 2 
$ echo  : logi FALSE 
$ out.width: chr "100%" 

    |.................................................................| 100% 
    ordinary text without R code 


output file: signature-page.knit.md 



processing file: abbreviations.Rmd 
    |................             | 25% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |................................         | 50% 
    ordinary text without R code 

    |.................................................    | 75% 
label: tab1 (with options) 
List of 3 
$ echo : logi FALSE 
$ message: symbol F 
$ warning: symbol F 

    |.................................................................| 100% 
    ordinary text without R code 


output file: abbreviations.knit.md 



processing file: background.Rmd 
    |................             | 25% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |................................         | 50% 
    ordinary text without R code 

    |.................................................    | 75% 
label: unnamed-chunk-2 (with options) 
List of 1 
$ echo: logi FALSE 

    |.................................................................| 100% 
    inline R code fragments 


output file: background.knit.md 



processing file: objectives.Rmd 
    |......................           | 33% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |...........................................      | 67% 
label: unnamed-chunk-2 (with options) 
List of 1 
$ echo: logi FALSE 

    |.................................................................| 100% 
    inline R code fragments 


output file: objectives.knit.md 



processing file: data.Rmd 
    |...........              | 17% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |......................           | 33% 
    ordinary text without R code 

    |................................         | 50% 
label: unnamed-chunk-2 (with options) 
List of 1 
$ echo: logi FALSE 

    |...........................................      | 67% 
    inline R code fragments 

    |......................................................   | 83% 
label: tab2 (with options) 
List of 3 
$ echo : logi FALSE 
$ message: symbol F 
$ warning: symbol F 

    |.................................................................| 100% 
    ordinary text without R code 


output file: data.knit.md 



processing file: overview.Rmd 
    |................             | 25% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |................................         | 50% 
    ordinary text without R code 

    |.................................................    | 75% 
label: unnamed-chunk-2 (with options) 
List of 1 
$ echo: logi FALSE 

    |.................................................................| 100% 
    ordinary text without R code 


output file: overview.knit.md 



processing file: reporting.Rmd 
    |................................         | 50% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |.................................................................| 100% 
    ordinary text without R code 


output file: reporting.knit.md 



processing file: quality.Rmd 
    |................................         | 50% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |.................................................................| 100% 
    ordinary text without R code 


output file: quality.knit.md 



processing file: references.Rmd 
    |................................         | 50% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |.................................................................| 100% 
    ordinary text without R code 


output file: references.knit.md 



processing file: appendix1.Rmd 
    |................             | 25% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |................................         | 50% 
    ordinary text without R code 

    |.................................................    | 75% 
label: tab3 (with options) 
List of 3 
$ echo : logi FALSE 
$ message: symbol F 
$ warning: symbol F 

    |.................................................................| 100% 
    ordinary text without R code 


output file: appendix1.knit.md 



processing file: appendix2.Rmd 
    |................................         | 50% 
label: unnamed-chunk-1 (with options) 
List of 2 
$ include: logi FALSE 
$ cache : logi FALSE 

    |.................................................................| 100% 
    ordinary text without R code 


output file: appendix2.knit.md 

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS _main.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output _main.tex --table-of-contents --toc-depth 2 --template "C:\Users\Mario\Documents\R\win-library\3.3\rmarkdown\rmd\latex\default-1.17.0.2.tex" --number-sections --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable tables=yes --standalone 

====================================================================== 
starting package maintenance... 
installation directory: C:\Users\Mario\AppData\Roaming\MiKTeX\2.9 
package repository: ftp://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/ 
visiting repository ftp://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/... 
repository type: remote package repository 
loading lightweight database... 
downloading ftp://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/miktex-zzdb1-2.9.tar.lzma... 
166037 bytes, 188.54 KB/Sec 
lightweight database digest: caad893b956d1cfa62503ece5da1dbab 
going to download 324623 bytes 
going to install 24 file(s) (1 package(s)) 
downloading ftp://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/latexmk.tar.lzma... 
324623 bytes, 780.82 KB/Sec 
extracting files from latexmk.tar.lzma... 
====================================================================== 

Latexmk, John Collins, 19 Jan. 2017. Version 4.52c 

Output created: _book/_main.pdf 
Error in tools::file_path_as_absolute(output_file) : 
    file '_book/_main.pdf' does not exist 
In addition: Warning messages: 
1: running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\latexmk.exe" -v' had status 1 
2: The LaTeX package latexmk was not correctly installed. 
3: running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\latexmk.exe" -v' had status 1 
4: running command '"pdflatex" -halt-on-error -interaction=batchmode "_main.tex"' had status 1 
5: running command '"bibtex" "_main.aux"' had status 1 
6: running command '"pdflatex" -halt-on-error -interaction=batchmode "_main.tex"' had status 1 
7: running command '"pdflatex" -halt-on-error -interaction=batchmode "_main.tex"' had status 1 

我真的不明白爲什麼它說latexmk.exe安裝不正確。

它位於此目錄中:C:\ Program Files文件\ MIKTEX 2.9 \是MiKTEX \ BIN \ 64 \ latexmk.exe

此外,當我運行:

bookdown::render_book("index.Rmd", "bookdown::pdf_document2") 
R中

, latexmk似乎工作。這是從位於latexmk.log文件的輸出:C:\用戶\馬里奧\應用程序數據\本地\ MIKTEX \ 2.9 \是MiKTEX \日誌

2017-05-06 06:41:14,090+0200 INFO latexmk - starting with command line: C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\latexmk.exe -v 
2017-05-06 06:41:14,092+0200 INFO latexmk - running 'initexmf --enable-installer --quiet --update-fndb' to refresh the file name database 
2017-05-06 06:41:21,041+0200 INFO latexmk - running 'initexmf --enable-installer --quiet --mklangs' to refresh language.dat 
2017-05-06 06:41:21,413+0200 INFO latexmk - starting with command line: latexmk -v 
2017-05-06 06:41:21,428+0200 INFO latexmk - installing package latexmk triggered by scripts\latexmk\latexmk.pl 
2017-05-06 06:41:22,651+0200 INFO latexmk - mpm: starting package maintenance... 
2017-05-06 06:41:22,651+0200 INFO latexmk - mpm: installation directory: C:\Users\Mario\AppData\Roaming\MiKTeX\2.9 
2017-05-06 06:41:22,651+0200 INFO latexmk - mpm: package repository: ftp://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/ 
2017-05-06 06:41:22,651+0200 INFO latexmk - mpm: visiting repository ftp://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/... 
2017-05-06 06:41:22,651+0200 INFO latexmk - mpm: repository type: remote package repository 
2017-05-06 06:41:22,651+0200 INFO latexmk - mpm: loading lightweight database... 
2017-05-06 06:41:22,651+0200 INFO latexmk - mpm: downloading ftp://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/miktex-zzdb1-2.9.tar.lzma... 
2017-05-06 06:41:23,513+0200 INFO latexmk - mpm: 166037 bytes, 188.54 KB/Sec 
2017-05-06 06:41:23,667+0200 INFO latexmk - mpm: lightweight database digest: caad893b956d1cfa62503ece5da1dbab 
2017-05-06 06:41:23,667+0200 INFO latexmk - mpm: going to download 324623 bytes 
2017-05-06 06:41:23,667+0200 INFO latexmk - mpm: going to install 24 file(s) (1 package(s)) 
2017-05-06 06:41:23,667+0200 INFO latexmk - mpm: downloading ftp://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/latexmk.tar.lzma... 
2017-05-06 06:41:24,082+0200 INFO latexmk - mpm: 324623 bytes, 780.82 KB/Sec 
2017-05-06 06:41:24,082+0200 INFO latexmk - mpm: extracting files from latexmk.tar.lzma... 
2017-05-06 06:41:31,696+0200 INFO latexmk - starting with command line: C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\latexmk.exe -v 
2017-05-06 06:44:20,358+0200 INFO latexmk - starting with command line: latexmk.exe 
2017-05-06 06:45:03,011+0200 INFO latexmk - starting with command line: "C:\Program Files\MiKTeX 2.9\miktex\bin\x64\latexmk.exe" 

任何建議或想法?

由於提前,

馬里奧

回答

1

雖然我仍不能確定的根本原因,但我發現system2('pdflatex', 'foo.tex', stdout = FALSE)與OP調試時沒有工作。我在rmarkdown程序包on Github中提供了一個修復程序,當stdout = FALSE不起作用時,它基本上回落到system2('pdflatex', 'foo.tex')。似乎重定向到/dev/null在某些Windows平臺上不起作用。