-
-
Save baptiste/6184584 to your computer and use it in GitHub Desktop.
Minimal example of a Rmd file that can be processed to produce both pdf and html output through pandoc, using two different file formats for the figures.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/Rscript | |
require(knitr) | |
lf <- commandArgs(trailingOnly = TRUE) | |
if(!length(lf)) | |
lf = list.files(pattern="\\.rmd") | |
for (f in lf) | |
try(knit(f)) | |
md = paste0(sub("\\.[[:alnum:]]*$", "", lf), ".md") | |
for (f in md){ | |
try({ | |
knitr::pandoc(f, c("html", "latex")) | |
}) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%knitr template | |
%baptiste Auguié | |
%`r format(Sys.time(), "%d %B, %Y")` | |
<!--pandoc | |
s: | |
S: | |
toc: | |
number-sections: | |
format: html | |
mathjax: | |
default-image-extension: png | |
format: latex | |
latex-engine: xelatex | |
default-image-extension: pdf | |
--> | |
```{r setup, echo=FALSE,results='hide',cache=FALSE} | |
library(knitr) | |
opts_chunk$set(cache=TRUE, fig.width=c(10, 8), | |
dev=c('png','pdf'), echo=FALSE, | |
warning=FALSE, error=TRUE, message=FALSE, tidy=FALSE) | |
opts_knit$set('upload.fun' = function(x) sub("\\.[[:alnum:]]*$", "", x) ) | |
``` | |
# First section | |
_Lorem ipsum dolor sit amet, mea enim exerci deserunt in. Zril legimus at vel. His ut nusquam fabellas, vero suscipit eos in, per an quem apeirian explicari. Sea ex prompta fastidii consetetur. Ut eos nostrud definiebas, ut probatus singulis vel, sed an errem ponderum elaboraret._ | |
## Markdown features | |
- first item | |
- second item | |
$$ | |
\frac{\alpha}{\infty} = \int_0^\beta f(x) dx | |
$$ | |
# Plots | |
```{r} | |
plot(1:10, cumsum(runif(10))) | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment