Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build PDF book from inst/examples/index.Rmd #440

Closed
N0rbert opened this issue Aug 12, 2017 · 11 comments
Closed

Unable to build PDF book from inst/examples/index.Rmd #440

N0rbert opened this issue Aug 12, 2017 · 11 comments
Milestone

Comments

@N0rbert
Copy link

N0rbert commented Aug 12, 2017

I have installed Preview Release 1.1.331 of RStudio IDE on Ubuntu 16.04.3 LTS.
Installed devtools and bookdown as decribed on getting-started page.

I have installed texlive-xetex package on my system.
I can produce HTML, PDF and EPUB from rstudio/bookdown-demo.git.

Then I cloned rstudio/bookdown.git to build PDF of your great book.
I opened inst/examples/index.Rmd from RStudio.
I ran this file with <Ctrl+Alt+R> and clicked Knit. It compiled HTML version, but buttons PDF, EPUB and MOBI open empty white windows (there are no such files in _book directory).
So I tried to build PDF and EPUB with _render.R script as described in Makefile - I opened _render.R and clicked Source in the editor.
Here I got error message:

output file: bookdown.knit.md

Error: Functions that produce HTML output found in document targeting latex output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:

  always_allow_html: yes

Note however that the HTML output will not be visible in non-HTML formats.

Please delete bookdown.Rmd after you finish debugging the error.
Execution halted
Error in eval(expr, envir, enclos) : 
  Failed to compile the book to bookdown::pdf_book

If I run make from terminal in the inst/examples/ folder I get another error:

$ make
Rscript --quiet _render.R "bookdown::pdf_book"
Error: Functions that produce HTML output found in document targeting latex output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:

  always_allow_html: yes

Note however that the HTML output will not be visible in non-HTML formats.

In addition: Warning message:
In verify_rstudio_version() :
  Please install or upgrade Pandoc to at least version 1.17.2; or if you are using RStudio, you can just install RStudio 1.0+.
Please delete bookdown.Rmd after you finish debugging the error.
Execution halted
Error: Failed to compile the book to bookdown::pdf_book
Execution halted
Makefile:2: recipe for target 'pdf' failed
make: *** [pdf] Error 1

I have pandoc 1.16.0.2 installed in my system (from official repository).
Removing bookdown.Rmd does not help.

Debug and version info:

> devtools::session_info('bookdown')
Session info ------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.3 (2015-12-10)
 system   x86_64, linux-gnu           
 ui       RStudio (1.1.331)           
 language en_US                       
 collate  en_US.UTF-8                 
 tz       W-SU                        
 date     2017-08-12                  

Packages ----------------------------------------------------------------------------------------------------------------------------------
 package   * version date       source                           
 backports   1.1.0   2017-05-22 cran (@1.1.0)                    
 base64enc   0.1-3   2015-07-28 cran (@0.1-3)                    
 bitops      1.0-6   2013-08-17 cran (@1.0-6)                    
 bookdown    0.4.2   2017-08-12 Github (rstudio/bookdown@2741261)
 caTools     1.17.1  2014-09-10 cran (@1.17.1)                   
 digest      0.6.12  2017-01-27 CRAN (R 3.2.3)                   
 evaluate    0.10.1  2017-06-24 cran (@0.10.1)                   
 highr       0.6     2016-05-09 cran (@0.6)                      
 htmltools   0.3.6   2017-04-28 cran (@0.3.6)                    
 jsonlite    1.5     2017-06-01 CRAN (R 3.2.3)                   
 knitr       1.17    2017-08-10 cran (@1.17)                     
 magrittr    1.5     2014-11-22 cran (@1.5)                      
 markdown    0.8     2017-04-20 cran (@0.8)                      
 methods   * 3.2.3   2016-01-14 local                            
 mime        0.5     2016-07-07 CRAN (R 3.2.3)                   
 Rcpp        0.12.12 2017-07-15 cran (@0.12.12)                  
 rmarkdown   1.6     2017-06-15 cran (@1.6)                      
 rprojroot   1.2     2017-01-16 cran (@1.2)                      
 stats     * 3.2.3   2016-01-14 local                            
 stringi     1.1.5   2017-04-07 cran (@1.1.5)                    
 stringr     1.2.0   2017-02-18 cran (@1.2.0)                    
 tools       3.2.3   2016-01-14 local                            
 utils     * 3.2.3   2016-01-14 local                            
 yaml        2.1.14  2016-11-12 cran (@2.1.14)                   

> rmarkdown::pandoc_version()
[1] ‘1.19.2.1’

> system('pdflatex --version')
pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian)
kpathsea version 6.2.1
Copyright 2015 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.6.17; using libpng 1.6.17
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with poppler version 0.41.0

I got this bug with stable versions of RStudio 1.0.153 and bookdown 0.4 too.

How to compile PDF of your book? Is it a bug? What am I doing wrong?

@N0rbert
Copy link
Author

N0rbert commented Aug 13, 2017

Upgrading R to 3.4.1-2xenial0 does not help.

@N0rbert
Copy link
Author

N0rbert commented Aug 14, 2017

I installed all needed fonts with apt-get install texlive-fonts-extra and from fontsquirel (source-code-pro and alegreya) with font-manager.
I added "always_allow_html: yes" to index.Rmd. Here is a patch to be applied:

--- /tmp/bookdown-master-org/inst/examples/index.Rmd
+++ /tmp/bookdown-master/inst/examples/index.Rmd
@@ -18,6 +18,7 @@
url: 'https\://bookdown.org/yihui/bookdown/'
github-repo: rstudio/bookdown
cover-image: images/cover.jpg
+always_allow_html: yes
---

```{r setup, include=FALSE}

@N0rbert N0rbert closed this as completed Aug 14, 2017
@yihui
Copy link
Member

yihui commented Aug 18, 2017

I should have provided instructions on how to build this particular book since it is not very straightforward. You need to install the webshot package in R and also PhantomJS: https://bookdown.org/yihui/bookdown/html-widgets.html You should not add always_allow_html: yes to YAML.

@yihui yihui added this to the v0.5 milestone Aug 18, 2017
@N0rbert
Copy link
Author

N0rbert commented Aug 21, 2017

Thank you, Yihui!
It works!

@Kenkleinman
Copy link

Is this a general fix-it for this message, for books patterned on your book? It also worked for me. (I am converting a book with many collaborators, and had not been aware of html output.)

@yihui
Copy link
Member

yihui commented Aug 29, 2017

@Kenkleinman Yes, it is a general fix.

@ganga537
Copy link

ganga537 commented Sep 3, 2018

HI @yihui

As mentioned here https://bookdown.org/yihui/bookdown/html-widgets.html

I installed
install.packages("webshot")
webshot::install_phantomjs()

But still I am facing the same issue "Error: Functions that produce HTML output found in document targeting latex output."

This is what my YAML loooks like

df_print: paged
output:
pdf_document: default
html_document: default
smooth_scroll: no
theme: flatly
collapsed: yes
toc_depth: 3
toc_float: null
allow_html_dependencies: true

Any clues, what I am missing ?

@yasirs
Copy link
Contributor

yasirs commented Sep 6, 2018

I get an error;

Error in base_format(toc = toc, number_sections = number_sections, fig_caption = fig_caption,  : 
  unused argument (always_allow_html = TRUE)
Calls: <Anonymous> -> create_output_format -> do.call -> <Anonymous>
Execution halted

This is the YAML header:

output:
  bookdown::pdf_book:
    always_allow_html: yes
    keep_tex: yes
    toc: yes
    toc_depth: 4

@ganga537
Copy link

ganga537 commented Sep 7, 2018

Yes, got it working using webshot and PhantomJS
https://github.com/wch/webshot
rmdshot("document.rmd", "document.pdf")

@chrisdane
Copy link

chrisdane commented Feb 1, 2019

Hi

Unfortunately, I still have the Error: Functions that produce HTML output found in document targeting latex output. by either running render_book('index.Rmd', "bookdown::pdf_book") or make pdf.

With render_book('index.Rmd', "bookdown::gitbook") or make gitbook, however, I can build the book successfully.

Adding always_allow_html: yes to index.Rmd produces the same error as noted by @yasirs above.

Note that building the bookdown-minimal and bookdown-demo books as pdf works well.

Thanks a lot for help!

> devtools::session_info('bookdown')
─ Session info ───────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.5.2 (2018-12-20)
 os       Arch Linux                  
 system   x86_64, linux-gnu           
 ui       X11                         
 language de_DE                       
 collate  C                           
 ctype    de_DE.UTF-8                 
 tz       Europe/Berlin               
 date     2019-02-01                  

─ Packages ───────────────────────────────────────────────────────────────────
 package   * version date       lib source                           
 base64enc   0.1-3   2015-07-28 [1] CRAN (R 3.5.2)                   
 bookdown    0.9.1   2019-02-01 [1] Github (rstudio/bookdown@44af2c0)
 digest      0.6.18  2018-10-10 [1] CRAN (R 3.5.2)                   
 evaluate    0.12    2018-10-09 [1] CRAN (R 3.5.2)                   
 glue        1.3.0   2018-07-17 [1] CRAN (R 3.5.2)                   
 highr       0.7     2018-06-09 [1] CRAN (R 3.5.2)                   
 htmltools   0.3.6   2017-04-28 [1] CRAN (R 3.5.2)                   
 jsonlite    1.6     2018-12-07 [1] CRAN (R 3.5.2)                   
 knitr       1.21    2018-12-10 [1] CRAN (R 3.5.2)                   
 magrittr    1.5     2014-11-22 [1] CRAN (R 3.5.2)                   
 markdown    0.9     2018-12-07 [1] CRAN (R 3.5.2)                   
 mime        0.6     2018-10-05 [1] CRAN (R 3.5.2)                   
 Rcpp        1.0.0   2018-11-07 [1] CRAN (R 3.5.2)                   
 rmarkdown   1.11    2018-12-08 [1] CRAN (R 3.5.2)                   
 stringi     1.2.4   2018-07-20 [1] CRAN (R 3.5.2)                   
 stringr     1.3.1   2018-05-10 [1] CRAN (R 3.5.2)                   
 tinytex     0.10    2019-01-10 [1] CRAN (R 3.5.2)                   
 xfun        0.4     2018-10-23 [1] CRAN (R 3.5.2)                   
 yaml        2.2.0   2018-07-25 [1] CRAN (R 3.5.2)     

> packageVersion("webshot")
[1] ‘0.5.1’

> system('phantomjs --version')
2.1.1

@github-actions
Copy link

github-actions bot commented Nov 6, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants