繁体   English   中英

字幕长度加宽表Kable Extra +乳胶

[英]Caption length widening table kable extra + latex

问题:我用精美的kableExtra包构建的表如下所示:

在此处输入图片说明

如果有必要,如何将标题调整为几行,以调整到表格的最小宽度,而不是相反?

carbon_benefits%>%
  set_names(c("Year","Date","Canary","Total","Date","Canary","Total"))%>%
kable(
    caption = "\\label{tab:carbon_costs}Carbon sequestration values over time.",
    booktabs = T,
    escape = F,
    linesep= "") %>%
  kable_styling(latex_options = c("hold_position"))%>%
  add_header_above(c("","Lower"=3,"Higher"=3))%>%
  footnote(general=paste("Combining the totals for all years for both species yields a lower bound of ",round(sum(carbon_benefits$total_lower),digits=0)," and a higher bound of ",round(sum(carbon_benefits$total_upper),digits=0),".",sep = ""),
           footnote_as_chunk = T)

reprex软件包 (v0.2.0)于2018-07-18创建。

您可以使用str_wrap包中的stringr将文本包装为合理的stringr

footnote(general=
  stringr::str_wrap(paste0("Combining the totals for all years for both species yields a lower bound of ",round(sum(carbon_benefits$total_lower),digits=0)," and a higher bound of ",round(sum(carbon_benefits$total_upper),digits=0),"."), 
    width=txtwidth), 
  footnote_as_chunk = T)

然后,可以根据预期的列数将txtwidth设置为合理长度的计算值。 这取决于您的数据结构。 在这种情况下,每列大约需要5-6个字符,所以35-40个字符?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM