Skip to content

Commit

Permalink
Create Book
Browse files Browse the repository at this point in the history
  • Loading branch information
danielparthier committed Oct 28, 2019
0 parents commit 7532668
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
21 changes: 21 additions & 0 deletions 01-intro.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Introduction {#intro}

You can label chapter and section titles using `{#label}` after them, e.g., we can reference Chapter \@ref(intro). If you do not manually label them, there will be automatic labels anyway, e.g., Chapter \@ref(methods).

Figures and tables with captions will be placed in `figure` and `table` environments, respectively.

```{r nice-fig, fig.cap='Here is a nice figure!', out.width='80%', fig.asp=.75, fig.align='center'}
par(mar = c(4, 4, .1, .1))
plot(pressure, type = 'b', pch = 19)
```

Reference a figure by its code chunk label with the `fig:` prefix, e.g., see Figure \@ref(fig:nice-fig). Similarly, you can reference tables generated from `knitr::kable()`, e.g., see Table \@ref(tab:nice-tab).

```{r nice-tab, tidy=FALSE}
knitr::kable(
head(iris, 20), caption = 'Here is a nice table!',
booktabs = TRUE
)
```

You can write citations, too. For example, we are using the **bookdown** package [@R-bookdown] in this sample book, which was built on top of R Markdown and **knitr** [@xie2015].
3 changes: 3 additions & 0 deletions 02-literature.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Literature

Here is a review of existing methods.
3 changes: 3 additions & 0 deletions 03-method.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Methods

We describe our methods in this chapter.
7 changes: 7 additions & 0 deletions 04-application.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Applications

Some _significant_ applications are demonstrated in this chapter.

## Example one

## Example two
3 changes: 3 additions & 0 deletions 05-summary.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Final Words

We have finished a nice book.
3 changes: 3 additions & 0 deletions 06-references.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
`r if (knitr::is_html_output()) '
# References {-}
'`
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a minimal example of a book based on R Markdown and **bookdown** (https://github.com/rstudio/bookdown). Please see the page "Get Started" at https://bookdown.org/ for how to compile this example.
13 changes: 13 additions & 0 deletions Thesis.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
5 changes: 5 additions & 0 deletions _bookdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
book_filename: "Thesis"
delete_merged_file: true
language:
ui:
chapter_name: "Chapter "
16 changes: 16 additions & 0 deletions _output.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bookdown::gitbook:
css: style.css
config:
toc:
before: |
<li><a href="./">A Minimal Book Example</a></li>
after: |
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
download: ["pdf", "epub"]
bookdown::pdf_book:
includes:
in_header: preamble.tex
latex_engine: xelatex
citation_package: natbib
keep_tex: yes
bookdown::epub_book: default
10 changes: 10 additions & 0 deletions book.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@Book{xie2015,
title = {Dynamic Documents with {R} and knitr},
author = {Yihui Xie},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2015},
edition = {2nd},
note = {ISBN 978-1498716963},
url = {http://yihui.name/knitr/},
}
34 changes: 34 additions & 0 deletions index.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "A Minimal Book Example"
author: "Yihui Xie"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
description: "This is a minimal example of using the bookdown package to write a book. The output format for this example is bookdown::gitbook."
---

# Prerequisites

This is a _sample_ book written in **Markdown**. You can use anything that Pandoc's Markdown supports, e.g., a math equation $a^2 + b^2 = c^2$.

The **bookdown** package can be installed from CRAN or Github:

```{r eval=FALSE}
install.packages("bookdown")
# or the development version
# devtools::install_github("rstudio/bookdown")
```

Remember each Rmd file contains one and only one chapter, and a chapter is defined by the first-level heading `#`.

To compile this example to PDF, you need XeLaTeX. You are recommended to install TinyTeX (which includes XeLaTeX): <https://yihui.name/tinytex/>.

```{r include=FALSE}
# automatically create a bib database for R packages
knitr::write_bib(c(
.packages(), 'bookdown', 'knitr', 'rmarkdown'
), 'packages.bib')
```
1 change: 1 addition & 0 deletions preamble.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\usepackage{booktabs}
14 changes: 14 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
p.caption {
color: #777;
margin-top: 10px;
}
p code {
white-space: inherit;
}
pre {
word-break: normal;
word-wrap: normal;
}
pre code {
white-space: inherit;
}

0 comments on commit 7532668

Please sign in to comment.