library(xtable) texprint<-new.env(parent=.GlobalEnv) texprint$print<-function(x, ...){ UseMethod("texprint") } texprint$texprint.default <- function(x, ...){ UseMethod("print") } texprint$texprint.data.frame <- function(x, ...){ args<-list(...) xtable.arg.names <- intersect(names(args),setdiff(names(formals(xtable)),'...')) xtable.args <- args[xtable.arg.names] print.arg.names <- setdiff(names(args), xtable.arg.names) xt <- do.call(xtable, append(list(x=x), xtable.args)) print.args <- args[print.arg.names] do.call(xtable:::print.xtable, append(list(x=xt), print.args)) } data(cars) mtcars with(texprint, print(mtcars)) with(texprint, print(mtcars, caption='mtcars dataset from base R.'))