[英]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.