Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to: A scenebreak in bookdown

Tags:

I'm trying to write a novel using bookdown: HTML, EPUB, as well as PDF (pdfLaTeX). I'm using the indent mode, so paragraphs begin with an indent. I have the following custom LaTeX command, called \scenebreak, which:

  1. Leaves an empty line between paragraphs when the scene changes within a chapter.
  2. Introduces a ding, if the scene break is at the end of a page, or the beginning of a page.
  3. Resets indent for the paragraph that follows the break (the paragraph that follows the break starts flush left).

Here's the LaTeX:

% scene breaks
\renewcommand{\pfbreakdisplay}{%
\scriptsize\ding{86}}
\newcommand{\scenebreak}{\pfbreak*\noindent}
\newcommand{\forceindent}{\leavevmode{\indent}}

When introducing the scenebreak in LaTeX, I call it so

Text here

\scenebreak

New scene begins here.

In HTML, this is how I've done it:

<div style='text-align:center;'>&#8226;</div>

I'm aware that a block in bookdown is like a LaTeX environment.

Is a similar setup possible with commands/macros?

like image 378
Ram Iyer Avatar asked Nov 12 '17 19:11

Ram Iyer


People also ask

How do you break a story into a scene?

There are several common ways of indicating a scene break within a chapter in a book. Perhaps the most common is to simply add an extra blank line between paragraphs: Here, the blank line between paragraphs shows the reader that a shift has occurred (in this case, we skip forward to the next day).

How do you separate scenes in a chapter?

For scene breaks within a chapter, insert one line with three asterisks centered. Don't use underlines or boldface anywhere in the text of your story. Use italics sparingly.

How many scene breaks in a chapter?

Variable Number of Scenes Per Chapter: You must have at least one scene per chapter. It may only be one word or one sentence, but it still counts as a scene.

Is a scene the same as a chapter?

In book terms, a scene is an important point in your story where a character tries to accomplish a goal but faces obstacles. A chapter is a pause in a novel, usually demarcated by a page break and new heading. Scenes are essential to the plot, whereas chapters just help to break up the narrative and control the pace.


1 Answers

I don't really understand your question, but if you are trying to write out different content depending on the different output format, here is what you could do:

```{r echo=FALSE}
knitr::asis_output(if (knitr:::is_latex_output()) {
  "\\scenebreak"
} else {
  "<div style='text-align:center;'>&#8226;</div>"
})
```

If you have to do this multiple times, create a function and call the function instead, e.g., insert this code chunk in the beginning of your book:

```{r, include=FALSE}
scenebreak = function() {
  knitr::asis_output(if (knitr:::is_latex_output()) {
    "\\scenebreak"
  } else {
    "<div style='text-align:center;'>&#8226;</div>"
  })
}
```

Then use the function scenebreak() where a break is needed:

```{r echo=FALSE}
scenebreak()
```
like image 96
Yihui Xie Avatar answered Sep 22 '22 12:09

Yihui Xie