18
0

Compare commits

...

5 Commits

Author SHA1 Message Date
Jeremy Foote
ee4ba6c2b4 Changing to Rtex 2018-08-30 15:45:19 -05:00
54c07cb9f5 Merge branch 'master' into knitr
- copied over the new scripts
2018-08-04 11:22:33 -07:00
5526efbaee Merge branch 'master' into knitr
- merged in CDSC branding from the master branch
2018-08-04 11:12:16 -07:00
ce30e1ac61 hand-merged knitr material
- branch is now knitrified
- added material to the gitignore for tex files
2018-08-04 11:10:39 -07:00
c46fe4b78e rename tex to Rnw as part of knitr branch 2018-08-04 11:10:31 -07:00
6 changed files with 80 additions and 12 deletions

View File

@@ -16,7 +16,7 @@ then
# get rid of paper_template subdir # get rid of paper_template subdir
mv "$TMPDIR" "$1" mv "$TMPDIR" "$1"
cd "$1"; cd "$1";
mv "text.Rnw" "$1.Rnw" mv "text.Rtex" "$1.Rtex"
else else
echo "specifiy a directory where the template should go"; echo "specifiy a directory where the template should go";
fi fi

View File

@@ -13,3 +13,5 @@
/*.ttt /*.ttt
/*.bcf /*.bcf
/*.run.xml /*.run.xml
/figures/*
/*.tex

View File

@@ -1,11 +1,9 @@
#!/usr/bin/make #!/usr/bin/make
all: $(patsubst %.tex,%.pdf,$(wildcard *.tex)) all: $(patsubst %.Rtex,%.pdf,$(wildcard *.Rtex))
# use the following section for Rnw/knitr documents %.tex: %.Rtex
# all: $(patsubst %.Rnw,%.pdf,$(wildcard *.Rnw)) Rscript -e "library(knitr); knit('$<')"
# %.tex: %.Rnw
# Rscript -e "library(knitr); knit('$<')"
%.pdf: %.tex %.pdf: %.tex
latexmk -f -pdf $< latexmk -f -pdf $<
@@ -15,9 +13,9 @@ clean:
rm -f *.tmp *.run.xml rm -f *.tmp *.run.xml
rm -f vc rm -f vc
rm -f *.bbl rm -f *.bbl
# the following lines are useful for Rnw/knitr # the following lines are useful for Rtex/knitr
# rm -rf cache/ figure/ rm -rf cache/ figure/
# rm -f *.tex rm -f *.tex
viewpdf: all viewpdf: all
evince *.pdf evince *.pdf
@@ -27,4 +25,4 @@ vc: resources/vc-git
pdf: all pdf: all
.PHONY: clean all .PHONY: clean all
# .PRECIOUS: %.tex .PRECIOUS: %.tex

Binary file not shown.

View File

@@ -0,0 +1,50 @@
bold <- function(x) {paste('{\\textbf{',x,'}}', sep ='')}
gray <- function(x) {paste('{\\textcolor{gray}{',x,'}}', sep ='')}
wrapify <- function (x) {paste("{", x, "}", sep="")}
# load("knitr_data.RData"); now broken up into small files so we'll bring 'em all in together
r <- do.call("c", lapply(paste("knitr_rdata/", list.files("knitr_rdata"), sep=""),
function (x) {load(x); return(r)}))
attach(r)
f <- function (x) {formatC(x, format="d", big.mark=',')}
format.percent <- function(x) {paste(f(x*100),"\\%",sep='')}
format.day.ordinal <- function(x) {
day <- format(x,format="%d")
daylast <- substr(day,nchar(day),nchar(day))
dayfirst <- substr(day,1,1)
if(dayfirst == '0')
day = daylast
if( daylast == "1")
day <- paste0(day,"st")
else if(daylast == "2")
day <- paste0(day,"nd")
else if (daylast == "3")
day <- paste0(day,"rd")
else
day <- paste0(day,"th")
return(day)
}
format.month <- function(x){
return( format(x,format='%B %Y'))
}
format.date <- function(x) {
return(paste(format(x,format = '%B'),format.day.ordinal(x),format(x,format='%Y'),sep=' '))
}
format.pvalue <- function (x, digits=3) {
threshold <- 1*10^(-1*digits)
x <- round(x, digits)
if (x < threshold) {
return(paste("p<", threshold, sep=""))
} else {
return(paste("p=", x, sep=""))
}
}

View File

@@ -9,6 +9,17 @@
\usepackage[utf8]{inputenc} \usepackage[utf8]{inputenc}
\usepackage{wrapfig} \usepackage{wrapfig}
<<init, echo=FALSE>>=
knit_hooks$set(document = function(x) {
sub('\\usepackage[]{color}',
'\\usepackage[usenames,dvipsnames]{color}', x, fixed = TRUE)
})
opts_chunk$set(fig.path="figures/knitr-")
source("resources/preamble.R")
@
\usepackage[T1]{fontenc} \usepackage[T1]{fontenc}
\usepackage{textcomp} \usepackage{textcomp}
\usepackage[garamond]{mathdesign} \usepackage[garamond]{mathdesign}
@@ -25,9 +36,7 @@
% \usepackage{endfloat} % \usepackage{endfloat}
% import and customize urls % import and customize urls
\usepackage[usenames,dvipsnames]{color}
\usepackage[breaklinks]{hyperref} \usepackage[breaklinks]{hyperref}
\hypersetup{colorlinks=true, linkcolor=Black, citecolor=Black, filecolor=Blue, \hypersetup{colorlinks=true, linkcolor=Black, citecolor=Black, filecolor=Blue,
urlcolor=Blue, unicode=true} urlcolor=Blue, unicode=true}
@@ -134,6 +143,15 @@ brown fox jumps over the lazy dog. The quick brown fox jumps over the
lazy dog. The quick brown fox jumps over the lazy dog. The quick brown lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
fox jumps over the lazy dog \citep{989866}. fox jumps over the lazy dog \citep{989866}.
\begin{table}
\centering
<<test_table, echo=FALSE>>=
kable(form.copy, format="latex")
@
\caption{This is a test table. There are \Sexpr{f(nrow(form.copy))} rows in the table.}
\label{tab:test}
\end{table}
The quick brown fox jumps over the lazy dog. The quick brown fox jumps The quick brown fox jumps over the lazy dog. The quick brown fox jumps
over the lazy dog. The quick brown fox jumps over the lazy dog. The over the lazy dog. The quick brown fox jumps over the lazy dog. The
quick brown fox jumps over the lazy dog. The quick brown fox jumps over quick brown fox jumps over the lazy dog. The quick brown fox jumps over