1.5 Some tips

Typesetting under the paging constraint (e.g., for LaTeX/PDF output) can be an extremely tedious and time-consuming job. I’d recommend you not to look at your PDF output frequently, since most of the time you are very unlikely to be satisfied: text may overflow into the page margin, figures may float too far away, and so on. Do not try to make things look right immediately, because you may be disappointed over and over again as you keep on revising the book, and things may be messed up again even if you only made some minor changes (see http://bit.ly/tbrLtx for a nice illustration).

If you want to preview the book, preview the HTML output. Work on the PDF version after you have finished the content of the book, and are very sure no major revisions will be required.

If certain code chunks in your R Markdown documents are time-consuming to run, you may cache them by adding the chunk option cache = TRUE in the chunk header, and you are recommended to label such code chunks as well, e.g.,

```{r important-computing, cache=TRUE}

In Chapter 5, we will talk about how to quickly preview a book as you edit . In short, you can use the preview_chapter() function to render a single chapter instead of the whole book. The function serve_book() makes it easy to live-preview HTML book pages: whenever you modify an Rmd file, the book can be recompiled and the browser can be automatically refreshed accordingly.