如何:书本中的场景分解
How to: A scenebreak in bookdown
我正在尝试使用 bookdown 写小说:HTML、EPUB 以及 PDF (pdfLaTeX)。我正在使用缩进模式,因此段落以缩进开头。我有以下自定义 LaTeX 命令,称为 \scenebreak
,其中:
- 当场景在一章中发生变化时,在段落之间留空行。
- 如果场景中断位于页面末尾或页面开头,则引入一个 ding。
- 重置分隔符后段落的缩进(分隔符后的段落从左对齐开始)。
这是 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 环境。
是否可以使用 commands/macros 进行类似的设置?
我不太明白你的问题,但如果你想根据不同的输出格式写出不同的内容,你可以这样做:
```{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()
```
我正在尝试使用 bookdown 写小说:HTML、EPUB 以及 PDF (pdfLaTeX)。我正在使用缩进模式,因此段落以缩进开头。我有以下自定义 LaTeX 命令,称为 \scenebreak
,其中:
- 当场景在一章中发生变化时,在段落之间留空行。
- 如果场景中断位于页面末尾或页面开头,则引入一个 ding。
- 重置分隔符后段落的缩进(分隔符后的段落从左对齐开始)。
这是 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 环境。
是否可以使用 commands/macros 进行类似的设置?
我不太明白你的问题,但如果你想根据不同的输出格式写出不同的内容,你可以这样做:
```{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()
```