我正在尝试使用 bookdown 写一本小说:HTML、EPUB 以及 PDF (pdfLaTeX)。我使用的是缩进模式,因此段落以缩进开头。我有以下自定义 LaTeX 命令,名为 \scenebreak
,其中:
- 当场景在章节内发生变化时,在段落之间留下空行。
- 如果场景中断位于页面末尾或页面开头,则引入叮叮声。
- 重置分行符后面的段落的缩进(分行符后面的段落开始向左对齐)。
这是 latex :
% scene breaks
\renewcommand{\pfbreakdisplay}{%
\scriptsize\ding{86}}
\newcommand{\scenebreak}{\pfbreak*\noindent}
\newcommand{\forceindent}{\leavevmode{\indent}}
在LaTeX中介绍scenebreak时,我这样调用它
Text here
\scenebreak
New scene begins here.
在 HTML 中,我是这样做的:
<div style='text-align:center;'>•</div>
我知道 bookdown 中的 block
就像一个 LaTeX 环境。
可以使用命令/宏进行类似的设置吗?
最佳答案
我不太明白你的问题,但如果你试图根据不同的输出格式写出不同的内容,你可以这样做:
```{r echo=FALSE}
knitr::asis_output(if (knitr:::is_latex_output()) {
"\\scenebreak"
} else {
"<div style='text-align:center;'>•</div>"
})
```
如果您必须多次执行此操作,请创建一个函数并调用该函数,例如,将此代码块插入到本书的开头:
```{r, include=FALSE}
scenebreak = function() {
knitr::asis_output(if (knitr:::is_latex_output()) {
"\\scenebreak"
} else {
"<div style='text-align:center;'>•</div>"
})
}
```
然后在需要中断的地方使用函数scenebreak()
:
```{r echo=FALSE}
scenebreak()
```
关于r - 如何: A scenebreak in bookdown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47253228/