if(any(commandArgs()=='mdToTex')) {
# if you'll be converting md to tex, can use the following
  knitr::knit_hooks$set(plot=knitr::hook_plot_tex)  
  knitr::opts_chunk$set(
    out.width='0.45\\textwidth', 
    dev='pdf', fig.align='center')
  mdToTex = TRUE
} else {
  knitr::knit_hooks$set(plot=Pmisc::hook_plot_mdsubfig)
  knitr::opts_chunk$set(dev='png')
  mdToTex = FALSE
}

knitr::knit_hooks$set(
  margins = Pmisc::hook_plot_margins
)

knitr::opts_chunk$set(
  echo=FALSE, prompt=TRUE, comment=NA,
  margins=1, fig.cap=' ', fig.pos='ht',
  fig.width=5.5, fig.height=4, 
  tidy=TRUE, tidy.opts=list(indent=2, width.cutoff=55)
)


options(width=80)

bibFile = 'myDocBib.bib'
cat('
    @article{lindgren2011explicit,
    title={An explicit link between {G}aussian fields and {G}aussian {M}arkov random fields the stochastic partial differential equation approach},
    author={Lindgren, Finn and Rue, Haavard and Lindstrom, Johan},
    journal={Journal of the Royal Statistical Society B},
    volume={73},
    number={4},
    pages={423-498},
    year={2011},
    publisher={Wiley}
    }
    ', file=bibFile, encoding='UTF8')
Pmisc::markdownHeader(
  title="Example of a simple R markdown document with subfigures",      
  author='Patrick Brown',
  bibliography = bibFile,
  geometry='margin=1in'
)

Introduction {#sec:intro}

@lindgren2011explicit is a very good paper, but Figure [@fig:aplot] is dull. There are some formulas in this document, from ([@eq:myeqn]) we can see nothing useful. If you are unsure of which Section we are in, be aware that this is Section [@sec:intro].

$$ \begin{aligned} f(x) = &x + \int_0^\infty \exp(-\theta u^2) du\ \rho(x_1 \ldots x_N) = & \sum_i x^i \end{aligned} $$ {#eq:myeqn}

Now some plots.

plot(1:10)

plot(1:10+2)


plot(1:10-4)


plot(1:10+4)
for(D in knitr::opts_current$get()$fig.subcap) {
  hist(runif(100), main='')
}

Below one will find Table [@tbl:theTable]

mytable = as.data.frame(matrix(runif(6),,3))
names(mytable) = month.name[1:ncol(mytable)]

Pmisc::mdTable(x=mytable, digits=3,
  caption = 'the table', caption.loc='bottom', 
  where = 'htb')

References



Try the Pmisc package in your browser

Any scripts or data that you put into this service are public.

Pmisc documentation built on Feb. 14, 2024, 3 a.m.