rstudio / bookdown-demo

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

search tool doesn´t work #61

Open carloslederman opened 4 years ago

carloslederman commented 4 years ago

Xie recommends to execute remotes::install_github('rstudio/bookdown'); next recommended step: bookdown::serve_book() the file is rendered and the search tool works fine BUT the generated HTML doesn´t. (and I still have to move the html to github) any suggestion please?

cderv commented 4 years ago

Hi @carloslederman ,

I am sorry but I don"t understand your issue.

the search tool works fine BUT the generated HTML doesn´t.

What is the issue exactly ? What do you expect ?

We really don't have much information to help you here.

FYI, serve_book() will allow you to preview the book. You still need to build the book when you are ready to get the complete HTML book.

carloslederman commented 4 years ago

Dear Mr Christophe Dervieux, I need to have the search tool working (operational) inside the html that will reside into github. When I use the "build book" I am getting one error related to a png reference that knits fine but when building the book generates the error "! Illegal unit of measure (pt inserted)." I am trying to have one finished html file with the search tool AND the png picture operating correctly, and I have observed that serve_book generates all .Rmd as html files inside the _book folder, but unfortunately the search function that works fine after "remotes::install_github('rstudio/bookdown')" do not preserves the search tool operation. In summary: "Buid book" is stucking me. I can´t go ahead without using the png picture and having the search tool operational. Thank you,

cderv commented 4 years ago

I need to have the search tool working (operational) inside the html that will reside into github.

what does this mean ? Are you using Github pages ? The resulting book folder needs to be hosted on a server somewhere, all the folder HTML files and dependencies.

I am getting one error related to a png reference that knits fine but when building the book generates the error "! Illegal unit of measure (pt inserted)."

How are you build the book ? Is this a R error ? Where does it show this ? Is it the only message ?

the search function that works fine after "remotes::install_github('rstudio/bookdown')" do not preserves the search tool operation.

What does this mean ? do you need the dev version specifically ? CRAN version does not work ?

We really need more detailed information. I can't guess what you have done, or what your book is, or how you tried to render the book.

Are you using RStudio IDE ? Do the Build Book > bookdown::gitbook() button works ? image

carloslederman commented 4 years ago

Dear Mr Christophe Derview many thanks for your deep attention. 1) I need to have the search tool working (operational) inside the html that will reside into github. what does this mean ? Are you using Github pages ? Yes, I am using Github pages and all my html files and all dependencies reside in the docs folder under the root of my repo

2) The resulting book folder needs to be hosted on a server somewhere, all the folder HTML files and dependencies. I don´t have another host or server somewhere , except github (what you are saying is that github is unable to be used as a repo for by book in html?)

3) I am getting one error related to a png reference that knits fine but when building the book generates the error "! Illegal unit of measure (pt inserted)." How are you build the book ? I use the button build book as you have illustrated below, my RStudio IDE version is

version _
platform x86_64-w64-mingw32 arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.1
year 2020
month 06
day 06
svn rev 78648
language R
version.string R version 4.0.1 (2020-06-06) nickname See Things Now

4) Is this a R error ? Where does it show this ? Is it the only message ? The error comes from RStudio; the complete message is: ! Illegal unit of measure (pt inserted).

p l.92 ...nter}\includegraphics[width=600px]{capa11} \end{center}

Erro: LaTeX failed to compile p02inhata.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See p02inhata.log for more info. Execu��o interrompida Error in gzfile(file, "rb") : n�o � poss�vel abrir a conex�o Calls: ... unlist -> lapply -> FUN -> -> readRDS -> gzfile Al�m disso: Warning message: In gzfile(file, "rb") : n�o foi poss�vel abrir o arquivo comprimido 'C:\Users\amb02\AppData\Local\Temp\Rtmp44UB7H\file12f83aed4b71.rds', motivo prov�vel 'No such file or directory' Execu��o interrompida

Exited with status 1.

5) the search function that works fine after "remotes::install_github('rstudio/bookdown')" do not preserves the search tool operation. What does this mean ? do you need the dev version specifically ? CRAN version does not work ? This means that when I execute at the RStudio console the command "remotes::install_github('rstudio/bookdown')" ( after install.packages("remotes") and library(remotes) ) and after " bookdown::serve_book()" it is presented one knited version of the book; when I click into the "magnification glass" tool it is presented one search field that allows searching into the entire book. Remember: I am using this "remotes" because I found just one user saying that the search tool was working after that. 6) We really need more detailed information. I can't guess what you have done, or what your book is, or how you tried to render the book. Mr Christophe I am very very interested in having my book that now is totally inside Rmd files into a folder created with file / new project / new directory / book project using bookdown. Again many thanks for your time and interest.

Are you using RStudio IDE ? Do the Build Book > bookdown::gitbook() button works ?

cderv commented 4 years ago

(what you are saying is that github is unable to be used as a repo for by book in html?)

If you are using github pages, it is a hosting service so this is ok. It is just "reside into github" is confusing because it is a git remote repository in the first place. If you use the hosting service Github page, it should be ok.

p l.92 ...nter}\includegraphics[width=600px]{capa11} \end{center} Erro: LaTeX failed to compile p02inhata.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See p02inhata.log for more info. Execu��o interrompida Error in gzfile(file, "rb") : n�o � poss�vel abrir a conex�o Calls: ... unlist -> lapply -> FUN -> -> readRDS -> gzfile Al�m disso: Warning message: In gzfile(file, "rb") : n�o foi poss�vel abrir o arquivo comprimido 'C:\Users\amb02\AppData\Local\Temp\Rtmp44UB7H\file12f83aed4b71.rds', motivo prov�vel 'No such file or directory' Execu��o interrompida

Exited with status 1.

This is a LATEX error, so you are building in PDF. Do you want the PDF too ? You talked about HTML only before.

Are you using RStudio IDE ? Do the Build Book > bookdown::gitbook() button works ?

Did you try that ? Building the book only for HTML output ?

Command line should be

bookdown::render_book("index.Rmd", "bookdown::gitbook")

but just select the gitbook format from the menu I have shown above.

I believe when you click on the Build button currently, this will build all the formats that you have defined in _output.yml file. From you error, there is a pdf_book format used, so it will try to render the book to PDF too. Currently your book have an issue with PDF rendering. For HTML, it should be fine unless you have an error too.

I let you try the above.

carloslederman commented 4 years ago

Many thanks Mr. Christophe, I have pressed the buttons Build Book > bookdown::gitbook() button and worked fine. In the environment pane comes the message "Output created: _book/preliminar.html" and the book is automaticaly presented; the search tool works fine on that presentation, it opens a box in the upper leftmost corner where I can put the word I am looking for, works fine. Looking to the output created, preliminar.html, inside the _book folder, when clicking over it, it comes 2 options: open in editor and view in web browser; when I choose "view in web browser", the book appears but the search tool shown is inoperant, when I click over it does nothing; if I copy this preliminar.html to the github pages repo, the effect is the same; if possible, please take a look into the link https://carloslederman.github.io/Glossario-ATS/preliminar.html Again many thanks for your time and attention!

cderv commented 4 years ago

When the book is built, the book leave in the _book directory. You should publish the all directory to github pages.

You could start fresh to be sure to have a clean state by using clean_book() - this would remove the _book folder that would be recreate next time you render your book.

You cannot take only one file of the book to mix it up with old files.

The workflow is :

See the documentation about how this works: https://bookdown.org/yihui/bookdown/build-the-book.html

If you want to preview the book live in the IDE, you need to use serve_book() as you did

carloslederman commented 4 years ago

Again, many thanks Mr. Christophe! Reproduced your instructions and now the html book on github is working fine, including the "find text" tool and the left/right "carousel" arrows. Now I need to obtain the PDF output. As I have mentioned before, I have one comand that knits fine (to present the book cover picture). It is: {r, echo=FALSE, out.width="600px",fig.align = 'center'} knitr::include_graphics("capa11.png") (Important to say that removing these 2 lines above the pdf book is totally generated .) When I ask to buil book > bookdown::pdf._book I receive one latex error message, the same sent before: ! Illegal unit of measure (pt inserted).

p l.92 ...nter}\includegraphics[width=600px]{capa11} \end{center} Erro: LaTeX failed to compile p02inhata.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See p02inhata.log for more info. Execu��o interrompida Exited with status 1. On that message there is one debugging link (https://yihui.org/tinytex/r/#debugging) that presents 3 options to be executed one after the other, in case of not resolving the issue. The package tinytex was installed and updated, but the error persists. Till this error message, it is generated one pdf with 4 pages One more question: I am trying to remove the word "Contents" generated by buildbook into the pdf as well as the pages in blank , please take a look into the link https://github.com/carloslederman/Glossario-ATS-pdf/blob/main/docs/p02inhata.pdf and download the file to see the blank pages and the title Contents I need to remove. Thank you!
cderv commented 4 years ago

All these are not issues with the package. You should really ask those kind of issues in https://community.rstudio.com. There will be a broader range of people to help you get started with the tools.

To build the pdf book, you need to know a bit latex. I believe your issue may lie in the fact that you specify out.width in px which is a HTML unit and not sure it is handle by Latex. Using % would work with both format. See the options help page for out.width: https://yihui.org/knitr/options/ but most of all look at the documentation of the tool you are using "Bookdown book": https://bookdown.org/yihui/bookdown/figures.html

we can specify the output size of plots via the chunk options out.width and out.height. The possible value of these two options depends on the output format of the document. For example, out.width = '30%' is a valid value for HTML output, but not for LaTeX/PDF output. However, knitr will automatically convert a percentage value for out.width of the form x% to (x / 100) \linewidth, e.g., out.width = '70%' will be treated as .7\linewidth when the output format is LaTeX. This makes it possible to specify a relative width of a plot in a consistent manner. Figure 2.2 is an example of out.width = 70%.

This is just a hint but I believe this could be it.

carloslederman commented 4 years ago

Dear Mr Christophe , many thanks again for your help, finally the first version of the pdf output was got. Best Regards,

cderv commented 4 years ago

Glad it works. You could close this issue now right ?

Next time, please follow the issue guide and ask on QA website like https://community.rstudio.com