【问题标题】:Can xtable produce \captionof instead of \caption?xtable 可以产生 \captionof 而不是 \caption 吗?
【发布时间】:2014-12-01 08:49:44
【问题描述】:

阅读了文档后,我认为这不太可能,但还是决定询问一下。

我正在写一张海报,tabular 必须留在 center 环境中,而不是 table 环境中。 (table 环境是一个浮点数,不能在海报的框内工作)。

这导致需要\captionof 而不是\caption 将标题放在center 环境中。 xtable有这种能力吗?

【问题讨论】:

    标签: r latex xtable


    【解决方案1】:

    \caption 是硬编码的。查看print.xtable.R的来源。

    if (tabular.environment == "longtable" && caption.placement == "top") {
                if (is.null(short.caption)){
                    BCAPTION <- "\\caption{"
                } else {
                    BCAPTION <- paste("\\caption[", short.caption, "]{", sep = "")
                }
    

    解决方法是在将结果传递给解释器之前对结果执行gsub。类似于gsub("\\caption", "\captionof", x)

    【讨论】:

    • gsub 的好主意,但我应该在什么时候插入呢?我在做print(xtable(my.df), file="my_table.tex")
    • print 语句保存到一个变量中,通过它运行gsub,然后导出到.tex(例如使用cat(..., file = "my_table.tex")
    • @Heisenberg -- Here's an example 使用 capture.output()gsub()cat() 完成此类事情。
    猜你喜欢
    • 2011-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-08
    • 2016-01-09
    • 2011-11-24
    相关资源
    最近更新 更多