inset \\footnote{} into header with xtable and tabular.environment

心不动则不痛 提交于 2019-12-04 07:46:50

I think you can't manipulate the header using the add.to.row argument.

But why not to sanitize?

Here my solution : The idea is to put a tag in the header (footnote here) and to change it using sanitize option.

x <- matrix(rnorm(60), ncol = 10)
x.big <- xtable(x,label='tabbig', caption='Example of longtable')
names(x.big) <- LETTERS[1:10]
names(x.big)[9] <- paste('I','footnote')    # I put the tag on I letter 
print(x.big,tabular.environment='longtable',floating=FALSE,
      sanitize.text.function=function(str)gsub("footnote","\\footnote{my tricky footnote !!}",str,fixed=TRUE))

You can easily extend the solution to many footnots by using many tags.

Update , case of multiple footnote

You can easily use thes ame trick for multiple notes, like this :

names(x.big)[1] <- paste('A','footnote1')    # I put the tag on A letter 
names(x.big)[9] <- paste('I','footnote2')    # I put the tag on I letter 
print(x.big,floating=FALSE,
      sanitize.text.function=function(str){
        str <- gsub("footnote1","\\footnote{my tricky footnote 1 !!}",str,fixed=TRUE)
        str <- gsub("footnote2","\\footnote{my tricky footnote 2 !!}",str,fixed=TRUE)
      }
        )

The idea is to assign the same string after the regular expression substitution.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!