Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
137 lines (98 sloc) 4.11 KB
---
title: "Your Awesome Title"
author: "Author One and Author Two"
date: '`r format(Sys.time())`'
output:
bookdown::pdf_document2:
includes:
before_body: ../template/doc_prefix.tex
in_header: ../template/preamble.tex
keep_tex: yes
latex_engine: pdflatex
number_sections: no
toc: no
bookdown::html_document2:
number_sections: no
theme: readable
toc: yes
bookdown::tufte_html2:
number_sections: no
toc: yes
bookdown::word_document2: null
fontsize: 12pt
linestretch: 1.5
link-citations: yes
csl: https://raw.githubusercontent.com/citation-style-language/styles/master/ecology.csl
bibliography: ../template/ref.bib
---
```{r knitr_options, echo=FALSE}
library(knitr)
# rstudio will set the folder where .Rmd file seats as work directory
# set it back to the folder where .Rproj seats
opts_knit$set(root.dir = normalizePath("../"))
opts_chunk$set(fig.align='center', cache=F, warning = FALSE, message = T, echo = FALSE)
options(digits = 3, width = 88)
# download template files if not available
tpl_1 = 'https://raw.githubusercontent.com/daijiang/workflow_demo/master/template/preamble.tex'
tpl_2 = 'https://raw.githubusercontent.com/daijiang/workflow_demo/master/template/doc_prefix.tex'
# bib_1 = 'https://raw.githubusercontent.com/daijiang/workflow_demo/master/template/ref.bib'
# change directory accordingly
if(!file.exists(tpl_1f <- '../template/preamble.tex')) download.file(tpl_1, tpl_1f)
if(!file.exists(tpl_2f <- '../template/doc_prefix.tex')) download.file(tpl_2, tpl_2f)
```
**Running headline**: Environment and species richness
**Abstract**: Your awesome abstract here.
\clearpage
# Introduction
Here is your introduction. It should describe clearly the rationale for the study being done and the previous work related with the study. It should also tell readers about your specific hypothese/questions being addressed. Citations will be like this [@adair_single-pool_2010], or [e.g., @clark_loss_2008], or [@eriksson_seed_1993; @williamson_dissolved_1999]
Here is the second paragraph of the introduction.
# Methods
Here is the method section. You can include equations easily. For inline equations, use $\text{var}(X) = p(1-p)$. For display equation, use
$$\text{var}(X) = p(1-p)$$
## Results
#### Tables
Insert tables by `kable` in knitr package in R. Then cross-reference it back with: see Table \@ref(tab:tableName).
```{r tableName,results='asis',echo=FALSE, message=F, warning=F}
source("R/rcode.R")
knitr::kable(sprich, booktabs = T, caption = "Caption here.")
```
Put results inline, e.g. the mean species richness is `r meansprich`.
#### Insert tables by `xtable` package in R
Show as Table. \ref{t:anova}:
```{r echo=F,results='asis',warning=F,message=F}
library(xtable)
envi.summ = xtable(summary(envi.aov),label = "t:anova", caption = "Caption here")
print(envi.summ,
caption.placement = "top",
floating=T,
hline.after=NULL,
comment = FALSE,
add.to.row=list(pos=list(-1,0, nrow(envi.summ)),
command=c(
'\\toprule\n',
'\\midrule\n',
'\\bottomrule\n')))
```
#### Insert tables by hand
Show as Table. \@ref(tab:byhand):
Table: (#tab:byhand) Caption here.
Col A Col B Col C Col D
------------ ------- ------------------ ------------------
row 1 190 $112 \pm 2$ $233 \pm 3$
$\eta$ 0.13 0.12 0.12
$\eta^2$ 0.14 0.13 0.50
$\eta^3$ 0.15 0.31 0.52
#### Figures
Insert figure by code chunk. And cross-ref it back as Figure \@ref(fig:figName).
```{r figName, fig.width=7, fig.asp=1, fig.cap="Your caption here."}
ggplot(data = envi.sprich, aes(x = value, y = sprich)) +
geom_point() + geom_smooth(method = "lm") +
facet_wrap(~envi, scales = "free_x") + theme_bw()
```
Or if you already have the figure:
And cite it as Figure \@ref(fig:fig2).
```{r fig2, out.width='70%', fig.cap="Caption here."}
knitr::include_graphics(path = paste0(normalizePath(getwd()), "/Figs/plot.pdf"))
```
More details can be found at [here](https://bookdown.org/yihui/bookdown/).
# References