3

I'm trying to create custom blocks for use in my book, written in bookdown. Unfortunately clicking Build Book in RStudio produces no output for the block. That is, the block does not appear in the output HTML but everything else in the book does.

I don't really know anything about CSS so decided to copy code from the bookdown book as a starting point. All the files below are located in the root folder of my book.

My style.css file looks like this:

.rmdcaution, .rmdimportant, .rmdnote, .rmdtip, .rmdwarning {
  padding: 1em 1em 1em 4em;
  margin-bottom: 10px;
  background: #f5f5f5 5px center/3em no-repeat;
}
.boo {
  padding: 1em 1em 1em 4em;
  margin-bottom: 10px;
  background: #f5f5f5;
  position:relative;
}
div.boo:before {
    content: "\f518";
    font-family: FontAwesome;
    left:10px;
    position:absolute;
    top:0px;
    font-size: 45px;
 }
p.caption {
  color: #777;
  margin-top: 10px;
}
p code {
  white-space: inherit;
}
pre {
  word-break: normal;
  word-wrap: normal;
}
pre code {
  white-space: inherit;
}

The first style block was copied from the bookdown book and the second was based on the SO example here.

Next, my _output.yml file looks like this:

bookdown::gitbook:
  css: [style.css, fontawesome.min.css]
  config:
    toc:
      before: |
        <li><a href="./">Surviving Statistics</a></li>
      after: |
        <li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
    edit: https://github.com/rstudio/bookdown-demo/edit/master/%s
    download: ["pdf", "epub"]

Finally, I call the blocks in my rmd file thus:

```{block, type='boo'}
Some text for this block. Some text for this block. Some text for this block. Some text for this block. Some text for this block. Some text for this block.
```

```{block2, type='rmdnote'}
If you are planning on printing your book to PDF, you will need a LaTeX distribution. We recommend that you install TinyTeX (which includes XeLaTeX): <https://yihui.name/tinytex/>.
```

As you can see, the first is a copy of the SO example above and the second is a copy of the bookdown book itself.

Any help much appreciated!

suknat
  • 335
  • 2
  • 7
  • 1
    I'm not sure yet if my problem has resolved itself, but the blocks seem to have appeared after a system restart. The Build Book button has disappeared (so I used plain old Knit) which makes me suspect that I was working in a different instance of RStudio! Anyway, I will post again if the problem persists. – suknat Jun 07 '18 at 11:24
  • I'm having this same problem right now. Do you have any advice other than a pc reset? Thanks – Luis Feb 20 '21 at 23:06

0 Answers0