Question

I'm trying to create a report that can be run yearly with as little change to the code as possible. I want the year of the report to be included in the title of the tables however cannot figure out how to insert the object into the caption.

\documentclass{article}

\begin{document}

<<year,echo=TRUE>>=
Year <- "2012-2013"
@
Year: \Sexpr{return(Year)}
<<makedata,echo=TRUE,results='asis'>>=
library(xtable)
dat <- matrix(round(rnorm(9, 20, 10)), 6, 3)
colnames(dat) <- c("Column 1","Column 2","Column 3")
print (xtable(dat, caption="Title"), caption.placement="top")
@

\end{document}

I want to insert the object Year before "Title".

Was it helpful?

Solution

Use paste()

print (xtable(dat, caption=paste(Year,"Title")), caption.placement="top")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top