rstudio / bookdown-demo

A minimal book example using bookdown
https://bookdown.org/yihui/bookdown-demo
Creative Commons Zero v1.0 Universal
504 stars 1.34k forks source link

`bookdown-demo_files/figure-latex/nice-fig-1' not found #3

Closed melindahiggins2000 closed 8 years ago

melindahiggins2000 commented 8 years ago

I am having good luck getting both HTML and EPUB formats to work when running "Build Book" for the bookdown-demo. However, when compiling to PDF, I get the following errors (shown in the Build Book window). My sessionInfo() is also listed below. I am running RStudio Version 0.99.1128 on Windows-10 with MiKTeX v2.9.

Note: when compiling to HTML I do get the "nice-fig-1.png" figure created into my ".._book\bookdown-demo_files\figure-html\" directory just fine.

Any help is appreciated.

Thank you, Melinda Higgins

----- Build Book errors -----------------------------------------------------------
latexmk.exe: MiKTeX encountered an internal error.
! LaTeX Error: File `bookdown-demo_files/figure-latex/nice-fig-1' not found.

Error: Failed to compile bookdown-demo.tex. See bookdown-demo.log for more info.
In addition: Warning messages:
1: running command '"C:\PROGRA~2\MIKTEX~1.9\miktex\bin\latexmk.exe" -pdf -latexoption=-halt-on-error -interaction=batchmode -pdflatex="pdflatex" "bookdown-demo.tex"' had status 1 
2: running command '"C:\PROGRA~2\MIKTEX~1.9\miktex\bin\latexmk.exe" -v' had status 1 
Execution halted

Exited with status 1.
----- Session Info -------------------------------------------
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

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

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

other attached packages:
[1] knitr_1.12.3    devtools_1.10.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.4       bookdown_0.0.60   withr_1.0.1      
 [4] digest_0.6.9      mime_0.4          R6_2.1.2         
 [7] xtable_1.8-2      git2r_0.13.1      httr_1.1.0       
[10] curl_0.9.5        miniUI_0.1.1      rmarkdown_0.9.5.8
[13] tools_3.2.3       shiny_0.13.2      httpuv_1.3.3     
[16] yaml_2.1.13       rsconnect_0.4.2.2 memoise_1.0.0    
[19] htmltools_0.3.5
yihui commented 8 years ago

@melindahiggins2000 It is safe to ignore these warnings.

@mikebirdgeneau I really cannot figure out what was wrong in your case. Here is probably my last blind attempt:

devtools::install_github('yihui/rmarkdown@windows-shell')

If this still does not fix your issue, the only possible way to figure out a solution is to chat with you with screensharing. You may also try to upgrade R/RStudio to the latest versions, and reinstall MikTeX.

melindahiggins2000 commented 8 years ago

@yihui Sounds good. I have updated all of my packages in MiKTeX 2.9 (64bit) and installed the latest version of Perl from ActiveState (after removing Strawberry Perl). I still get the same warning messages when I build the PDF book, but the PDF output looks fine, so I'll ignore the messages. This is along the same lines as the issue thread at https://github.com/rstudio/bookdown/issues/121. I have every faith the latexmk issue will be sorted out for the bookdown::pdf_book build on windows eventually. Thanks again.

mikebirdgeneau commented 8 years ago

Here's the progress I've made:

  1. Installed the latest version of Rstudio Preview
  2. Uninstalled MiKTeX.
  3. Reinstalled MiKTeX in a directory that avoids any ~ expansion for example: C:\PROGRA~1\...\ so I just used C:\miktex\ when installing.
  4. in the MiKTeX package manager, I installed the graphics-def package, because it is needed for xetex.def.
  5. Put the location of ...\perl\bin\ in my windows environment PATH variable.
  6. Installed the latest versions of rmarkdown & bookdown
devtools::install_github('rstudio/rmarkdown')
devtools::install_github('rstudio/bookdown')

Once I do this, I'm able to build the PDF without any issues, when using the command:

bookdown::render_book("index.Rmd", "bookdown::pdf_book",clean = TRUE)

I'm not sure which of these actually resolved my problem, but I can render a PDF now without any moving of *.tex files and separate rendering commands.


The only other thing I've noted through all of this is that I've got code in another bookdown project I'm working on that is as follows (in index.Rmd):

#```{r global_options, include=FALSE}
#knitr::opts_chunk$set(fig.width=8, fig.height=4, out.width = "90%", echo=FALSE, warning=FALSE, #message=FALSE,fig.align = 'center',dev = 'png', fig.ext = "png")
# ```

With all the recent changes, I'm now getting unexpected output showing-up in my PDF -- items that I would have thought are removed by echo=FALSE. It looks like this global opts_chunk isn't working for me. If I wrap the offending code in `invisible({...})``` then it solves it , but I was hoping to avoid having to type this - is there a different argument I should be adding?

I've got the chapter Rmd files, but I also reference sub documents using syntax like:

#```{r child="./subcontent/subdocument01.Rmd"}
#``` 

Great work on this package! It's shaping up nicely. Hope this helps.

yihui commented 8 years ago

@mikebirdgeneau You probably mean results = 'hide' instead of echo = FALSE. The latter means hiding the R source code.

mikebirdgeneau commented 8 years ago

Thanks @yihui - I've tried that, I'm trying to use knitr::kable to output some tables. I'm using the data.table package to manipulate some data, and I believe the := statements are showing up in the output.

Here's an example:

invisible({
  table.data <- subset(dt,select=c(col1,col2,col3))
  table.data[,col4:=round(col1+col2/col3,0),]
knitr::kable(table.data,caption = "Example Table",booktabs = TRUE)

So I don't want to hide results, but I don't want the intermediate output from data.table showing up either. Wrapping the code in invisible seems to solve the problem. It's just not elegant.

I'm really happy the compilation is working now! This package is great. :+1:

yihui commented 8 years ago

Okay, this issue is specific to data.table then. I have seen this issue come and go in the past. I don't understand the magic in data.table, and you need to seek help from Matt.

znmeb commented 8 years ago

I'm coming in late, but I've got the "Perl must be installed and put on PATH for latexmk to work" issue. I installed the whole MikTeX 64-bit package; I assumed it had a copy of Perl if it needed it. I've got two versions of Perl on my machine - LyX carries one and Git for Windows carries one. Both seem to be 5.22. So I think it's just a matter of setting the Windows PATH variable. But if MikTeX needs Perl its installer should set that up ... this certainly isn't a Bookdown issue.

yihui commented 8 years ago

MikTeX does not require Perl or bundle Perl with it. It is latexmk that requires Perl.

znmeb commented 8 years ago

How does latexmk get installed? Via the MikTeX installer?

yihui commented 8 years ago

Yes, but I don't think it is unreasonable for MikTeX not to install Perl for latexmk. It is just like when an R package depends on an external program, and install.packages() won't install the external system dependency. latexmk is essentially a Perl script, so you have to make sure Perl is accessible. Anyway, it is only a warning message, and you can safely ignore it. rmarkdown has a fallback method to compile LaTeX documents when latexmk cannot be used.

znmeb commented 8 years ago

Ah ... OK ... as long as the PDF gets created somehow.

datapoesy commented 8 years ago

Hi all,

I have been following this thread as well... get the following error while trying to Build Book from build options.

Sorry, but C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\xelatex.exe did not succeed.

The log file hopefully contains the information to get MiKTeX going again:

C:/Users/Sreekumar/AppData/Local/MiKTeX/2.9/miktex/log/xelatex.log``

And the log says:

2016-08-04 12:20:16,802+0530 FATAL xelatex - GUI framework cannot be initialized. 2016-08-04 12:20:16,803+0530 FATAL xelatex - Info: 2016-08-04 12:20:16,803+0530 FATAL xelatex - Source: Libraries\MiKTeX\UI\Qt\mikuiqt.cpp 2016-08-04 12:20:16,803+0530 FATAL xelatex - Line: 45

Would really appreciate your assistance. I have been on this for the last couple of days.

yihui commented 8 years ago

@sreejimalayil In this case you can try to change the option for automatically installing missing LaTeX packages: http://docs.miktex.org/manual/autoinstall.html I think the default is to ask you whether to install them. Change the option to either never ask or don't automatically install from Start menu -> MikTeX -> a certain menu for MikTeX options.

adamcduncan commented 8 years ago

Thanks to all in this thread. I have been following along. I am having the same issue with creating the pdf from an rmarkdown Tufte handout template. I am on a Windows platform and have followed the the steps outlined by @mikebirdgeneau to reinstall MikTeX and the graphics-def package.

The rMarkdonw error reads: Sorry, but C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\xelatex.exe did not succeed.

The log file hopefully contains the information to get MiKTeX going again:

C:/Users/aduncan/AppData/Local/MiKTeX/2.9/miktex/log/xelatex.log

You may want to visit the MiKTeX project page, if you need help.

Output created: factor_model_markdown.pdf Error in tools::file_path_as_absolute(output_file) : file 'factor_model_markdown.pdf' does not exist Calls: -> In addition: There were 14 warnings (use warnings() to see them) Execution halted

The xelatex.log file contains similar messages to @sreejimalayil shown here:

2016-08-07 07:47:45,484-0400 INFO xelatex - going to create file: xelatex.fmt 2016-08-07 07:47:47,255-0400 FATAL xelatex - GUI framework cannot be initialized. 2016-08-07 07:47:47,256-0400 FATAL xelatex - Info: 2016-08-07 07:47:47,256-0400 FATAL xelatex - Source: Libraries\MiKTeX\UI\Qt\mikuiqt.cpp 2016-08-07 07:47:47,256-0400 FATAL xelatex - Line: 45 2016-08-07 07:47:47,828-0400 FATAL xelatex - GUI framework cannot be initialized. 2016-08-07 07:47:47,828-0400 FATAL xelatex - Info: 2016-08-07 07:47:47,828-0400 FATAL xelatex - Source: Libraries\MiKTeX\UI\Qt\mikuiqt.cpp 2016-08-07 07:47:47,828-0400 FATAL xelatex - Line: 45 ...

Not really sure where to go

Session Info: R version 3.3.1 (2016-06-21) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

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

loaded via a namespace (and not attached): [1] Rcpp_0.12.5 tufte_0.2 lattice_0.20-33 tidyr_0.5.1 digest_0.6.9
[6] psych_1.6.6 dplyr_0.5.0 assertthat_0.1 grid_3.3.1 R6_2.1.2
[11] plyr_1.8.4 nlme_3.1-128 DBI_0.4-1 magrittr_1.5 evaluate_0.9
[16] stringi_1.1.1 reshape2_1.4.1 rmarkdown_1.0.9002 tools_3.3.1 stringr_1.0.0
[21] broom_0.4.1 yaml_2.1.13 parallel_3.3.1 rsconnect_0.4.3 mnormt_1.5-4
[26] htmltools_0.3.5 knitr_1.13 tibble_1.1

adamcduncan commented 8 years ago

Sorry, accidentally posted before i could say thanks, Yihui, and before I could style the comment. Any guidance is super appreciated.

yihui commented 8 years ago

@gtog The message GUI framework cannot be initialized indicates that your current setting is to make MikTeX ask whether to install the missing packages, and you need to change this setting (either automatically install, or just do not install and fail).

adamcduncan commented 8 years ago

I figured as much from your earlier comments above. I'll turn that off and manually note and install all the latex packages it cries about and see if that works to compile the pdf. If that resolves the issue, I'll comment here. Thanks, Yihui.

datapoesy commented 8 years ago

Yihui,

I finally managed to get this running.
My version of Miktek wouldn't update packages automatically; so had to go through the painful process of updating one by one manually. Much thanks to all respondents in this thread.

znmeb commented 8 years ago

@sreejimalayil You can change the "Update-on-the-fly" setting:

  1. In the Windows Start menu, start "MiKTeX 2.9 → Maintenance (Admin) → Settings (Admin)"
  2. You'll see drop-downs for on-the-fly packages and paper size. Change the on-the-fly setting to "Yes".
tinu-schneider commented 8 years ago

Thanks to everybody for their work so far!

Today I still encountered the following warnings after creating a pdf_book. error

BUT -- I have MikTex 2.9 (two.nine, NOT 1.9) installed. So - perhaps someone tries to find latexmk.exe in MikTex 1.9 and doesn't find it there?

Unfortunately I can't help any further - I have no idea, what -- or if at all -- this means...

yihui commented 8 years ago

@tinu-schneider Don't be confused by 1.9 -- it is just part of the short path name in the 8.3 format https://support.microsoft.com/en-us/kb/142982 The actual path, I believe, is 2.9.

It is safe to ignore these warnings, and actually I have removed these warnings in rmarkdown. You can install the development version via

devtools::install_github('rstudio/rmarkdown')
melindahiggins2000 commented 8 years ago

Thank you. This cleans up my Build output using bookdown::pdf_output.

tinu-schneider commented 8 years ago

Thank you @yihui. So I ignore the warnings as the generated book is OK.

chinsoon12 commented 7 years ago

Problem: I had the GUI framework cannot be initialized problem even though my MiKTeX option was Install missing packages on-the-fly: Yes.

Soln: I had to open the Windows command prompt to bookdown-demo-master\_book and run the following: %PATH_TO_XELATEX_EXE%\xelatex.exe bookdown-demo.tex

Cause of problem: And found that I need to authenticate for the http proxy even though that has been explictly updated in my MiKTeX Package Manager earlier. weird...

danxfreeman commented 1 year ago

I fixed this by deleting knitr::opts_chunk$set(dev = "svg") in my Rmd file

Takdrift commented 1 year ago

I fixed this by deleting knitr::opts_chunk$set(dev = "svg") in my Rmd file

me too, thanks guy