【问题标题】:Short caption in knitr::kable()knitr::kable() 中的短标题
【发布时间】:2018-10-14 07:53:23
【问题描述】:

如何在kable 中创建短标题?

library(dplyr)
library(knitr)
library(kableExtra)

df <- data.frame( X = sample(letters, 10), y = runif(10), z = sample(10:20, 10))

kable(df,
      booktabs = TRUE,
      caption = "This caption is way too long and doesnt look good when formatted in the Table of Contents.  What you really need here is a much shorter caption so that your eyes dont go crazy trying to figure out what information the author is trying to convey.  Often there is too much information in the caption anyway so why not shorten it?.",
      escape = FALSE,
      format = 'latex') %>%
  kable_styling(latex_options = c("striped", "hold_position"))

【问题讨论】:

  • 我投票结束这个问题,因为“这不是一个问题”。
  • 欢迎来到 Stack Overflow!不幸的是,目前的这个问题将被关闭,因为它不是一个可以回答的问题。如果您想记录信息以供其他人查看,正确的做法是在“问题”字段中发布您的问题,然后将解决方案发布为self-answer。否则,我们感谢您添加到 Stack Overflow 的整体知识库中!
  • 我完全同意@gparyani。当前的帖子是一个很好的问答,唯一的问题是问答是在一起的。如果你能把它们分开就完美了!并感谢 Caddisfly 分享知识!顺便说一句,对于那些不赞成这篇文章的人:我只想说可能有更好的方法来帮助 OP...

标签: r knitr kable


【解决方案1】:

我为kable 找到了这个选项的一个非常模糊的reference

要使您的标题简短,只需使用例如caption.short = "This is a short caption"

library(dplyr)
library(knitr)
library(kableExtra)
df <- data.frame( X = sample(letters, 10), y = runif(10), z = sample(10:20, 10))

kable(df,
      booktabs = TRUE,
      caption = "This caption is way too long and doesnt look good when formatted in the Table of Contents.  What you really need here is a much shorter caption so that your eyes dont go crazy trying to figure out what information the author is trying to convey.  Often there is too much information in the caption anyway so why not shorten it?.",
      caption.short = "This is a shorter caption.",
      escape = FALSE,
      format = 'latex') %>%
  kable_styling(latex_options = c("striped", "hold_position"))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-20
    • 1970-01-01
    • 1970-01-01
    • 2022-01-19
    • 2017-06-20
    • 2019-04-10
    • 2021-12-20
    • 2016-10-11
    相关资源
    最近更新 更多