forked from HanOostdijk/rmd_pdf_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup1.rmd
36 lines (32 loc) · 1.11 KB
/
setup1.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
```{r setup, include=FALSE, cache=FALSE,warning=FALSE,message=FALSE}
library(knitr)
now_latex = identical(knitr:::pandoc_to(), 'latex')
now_html = identical(knitr:::pandoc_to(), 'html')
opts_chunk$set(fig.show='hold',tidy=FALSE,
fig.width=8,fig.height=8,fig.align="center",fig.scap=NA,highlight = T,
fig.cap='figmmain0',fig.subcap=c('figsub1','figsub2'),fig.pos='!htbp')
if ( now_latex ) {
knit_hooks$set(plot = hook_plot_tex)
opts_chunk$set( out.width="3in",out.height="3in")
}
if ( now_html ) knit_hooks$set(plot = hook_plot_html)
options(replace.assign=TRUE,width=90,xtable.comment = F)
def_tab <- function (label_name,label_tekst)
{ if ( now_latex ) {
paste0(label_tekst,"\\label{table:",label_name,"}")
} else {""}
}
ref_tab <- function (label_name,table=T,add_page=T,prefix='in') {
if (!now_latex) return("")
if (table==T) {
obj1 = 'Table' ; obj2 = 'table' ;
} else {
obj1 = 'Figure' ; obj2 = 'fig' ;
}
t = sprintf('%s %s \\ref{%s:%s}',prefix, obj1, obj2, label_name)
if (add_page == T) {
t =paste(t,'on page',sprintf('\\pageref{%s:%s}',obj2, label_name))
}
return(t)
}
```