簡體   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