字幕长度加宽table kable extra + latex
Caption length widening table kable extra + latex
问题: 我的 table 是用美妙的 kableExtra
包构建的,看起来像这样:
如果需要调整到 table 的最小宽度而不是相反,如何强制标题为多行?
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 创建于 2018-07-18
包 (v0.2.0).
您可以使用 stringr
包中的 str_wrap
将文本包装成合理的行长:
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 个字符?
问题: 我的 table 是用美妙的 kableExtra
包构建的,看起来像这样:
如果需要调整到 table 的最小宽度而不是相反,如何强制标题为多行?
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 创建于 2018-07-18 包 (v0.2.0).
您可以使用 stringr
包中的 str_wrap
将文本包装成合理的行长:
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 个字符?