r - bookdown 自定义块无法编译
问题描述
我正在尝试创建自定义块以在我的书中使用,用 bookdown 编写。不幸的是,在 RStudio 中单击 Build Book 不会产生该块的输出。也就是说,该块不会出现在输出 HTML 中,但本书中的其他所有内容都会出现。
我对 CSS 真的一无所知,所以决定从 bookdown 书中复制代码作为起点。以下所有文件都位于我的书的根文件夹中。
我的style.css
文件如下所示:
.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;
}
第一个样式块是从 bookdown 书中复制的,第二个是基于此处的 SO 示例。
接下来,我的_output.yml
文件如下所示:
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"]
最后,我这样调用 rmd 文件中的块:
```{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/>.
```
如您所见,第一个是上面 SO 示例的副本,第二个是 bookdown 书本身的副本。
非常感谢任何帮助!
解决方案
推荐阅读
- c# - Drive API v3,C# - 文件夹层次结构
- reactjs - 如何在 React 中重构 switch 语句的代码?
- amazon-web-services - 如何将 AWS 弹性搜索迁移到 Azure 弹性搜索服务?
- kubernetes - 从 EOF metric-server kubernetes 获取 TLS 握手错误
- regex - 如何从perl中的文本文件中提取动态生成的访问令牌?
- angular - 运行Angular模板时VS中的dist目录在哪里?
- c++ - 挂钩 WH_GETMESSAGE 消息
- r - R对连续重复的奇数列表求和并删除除第一个列表之外的所有列表
- php - 如何删除具有重复列值的子数组?
- google-apps-script - 如何在谷歌表格中打开带有超链接的隐藏表格?