## FUNCTION TO OUTPUT LATEX CODE

# All backslash \ must be written as double backslash \\
# Values from R objects should be framed by << >>
tex<-function(code, file) {
  split.code.1<-unlist(strsplit(code,">>"))
  split.code<-strsplit(split.code.1,"<<")
  if (length(split.code[[1]])<2) {split.code[[1]]<-c('""',split.code[[1]])}
  if (length(split.code[[length(split.code)]])<2) {split.code[[length(split.code)]]<-c(split.code[[length(split.code)]],'""')}
  split.code<-matrix(unlist(split.code),byrow=TRUE,ncol=2)
  split.code[,2]<-sapply(split.code[,2],execute)
  write(t(split.code),file=file,sep="",ncolumns=nrow(split.code)*ncol(split.code))
}
