문제

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".

도움이 되었습니까?

해결책

Use paste()

print (xtable(dat, caption=paste(Year,"Title")), caption.placement="top")
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top