generated from anovabr/gitbook-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathediting_the_book.Rmd
40 lines (24 loc) · 2.15 KB
/
editing_the_book.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Editing the book
The contents of the book are written in **RMarkdown**. You can use any formatting code that Pandoc's Markdown supports, e.g., a math equation $a^2 + b^2 = c^2$. Moreover, you can include chunks of R-code, like this:
<pre><code>```{r}
print("This is an R-command!")
```</code></pre>
The results of these chunks can be rendered to the GitBook:
```{r, echo = FALSE}
print("This is an R-command!")
```
To edit the book, you can change the text in the `.Rmd` files. Each Rmd file should contain **one and only one** chapter. A chapter is defined by the first-level heading `#`, e.g., `# Editing the book`.
Any sub-headings within the chapter are indicated with several `#` signs, e.g., `##` (level 2) and `###` (level 3).
## Creating new chapters
To create a new chapter, you must follow two steps: 1) Create the file, and 2) Include it in the list of chapters.
First, to create the file for a new chapter in Rstudio, click `File > New File > Text file`. At the top of the file, write your chapter heading, as explained above. Then, click `File > Save`. Save the file as `.Rmd`, without spaces in the file name, e.g.: `editing_the_book.Rmd`.
Second, to include it in the list of chapters, open the file `_bookdown.yml` (click it in the Files explorer in the bottom right of Rstudio). This file has a list of `.Rmd` files to be included in the book. In this example, the list looks like this:
```{r, results = "asis"}
tmp <- readLines("_bookdown.yml")
cat(tmp[grep("^rmd_files", tmp):grep("references\\.Rmd", tmp)], sep = "\n")
```
Insert the file name of your new chapter in the desired position in this list.
## Linking across chapters
You can label chapter and section titles using `{#label}` after them. The labels can be used as cross-references. For example, we can link to Chapter \@ref(figtab). If you do not manually label chapters, there will be automatic labels anyway, e.g., Chapter \@ref(examples).
## Advanced editing
The convenient [Rmarkdown Cheat Sheet](https://rstudio.com/wp-content/uploads/2016/03/rmarkdown-cheatsheet-2.0.pdf) by Rstudio covers most of the knowledge required for advanced Rmarkdown editing. You can print it out and stick it to your wall!