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