【问题标题】:How to reduce size of footnote in kableExtra (LaTeX)如何减小 kableExtra (LaTeX) 中脚注的大小
【发布时间】:2021-03-04 09:44:01
【问题描述】:

我在 Rmarkdown 中使用 kableExtra 包创建了下表。我正在寻找一种减小脚注大小的方法。在 footnote 参数中添加 size = 1 作为参数似乎不起作用。有什么想法吗?

library(tidyverse)
library(kableExtra)

data <- structure(list(Category = c("Internally Managed", "Externally Managed", 
"Asset Swaps", "Total"), Percent = c("44.1%", "32.5%", "23.4%", 
"100%")), row.names = c(NA, -4L), class = c("tbl_df", "tbl", 
"data.frame"))

data %>%
 kable(format='latex',booktabs=TRUE, align = 'lr',
        caption="Breakdown \\label{Table3}") %>% 
  kable_styling(latex_options = c("HOLD_position", full_width = T), font_size = 9) %>% 
  row_spec(0,bold=T,color = 'white', background = '#7c3042') %>% 
  row_spec(1:4, hline_after = T) %>% 
  row_spec(4, bold = T) %>% 
  column_spec(1:2, width = '5cm') %>% 
  footnote(general = "*This is what I want my footnote to be", threeparttable = TRUE, size = 7)

【问题讨论】:

    标签: r latex kableextra


    【解决方案1】:

    您可以添加一些 LaTeX 代码并转义 (escape = F) 以在脚注上实现更小的字体。

    一个可重现的例子:

    ---
    title: "Footnote"
    author: "bttomio"
    output: pdf_document
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
    ```
    
    ```{r evensmallerfootnote}
    library(tidyverse)
    library(kableExtra)
    
    data <- structure(list(Category = c("Internally Managed", "Externally Managed", 
    "Asset Swaps", "Total"), Percent = c("44.1%", "32.5%", "23.4%", 
    "100%")), row.names = c(NA, -4L), class = c("tbl_df", "tbl", 
    "data.frame"))
    
    data %>%
     kable(format='latex',booktabs=TRUE, align = 'lr',
            caption="Breakdown \\label{Table3}") %>% 
      kable_styling(latex_options = c("HOLD_position", full_width = T), font_size = 9) %>% 
      row_spec(0,bold=T,color = 'white', background = '#7c3042') %>% 
      row_spec(1:4, hline_after = T) %>% 
      row_spec(4, bold = T) %>% 
      column_spec(1:2, width = '5cm') %>% 
      footnote(general = "\\\\tiny{*This is what I want my footnote to be}", threeparttable = TRUE, escape = F)
    ```
    
    
    ```{r smallerfootnote}
    library(tidyverse)
    library(kableExtra)
    
    data <- structure(list(Category = c("Internally Managed", "Externally Managed", 
    "Asset Swaps", "Total"), Percent = c("44.1%", "32.5%", "23.4%", 
    "100%")), row.names = c(NA, -4L), class = c("tbl_df", "tbl", 
    "data.frame"))
    
    data %>%
     kable(format='latex',booktabs=TRUE, align = 'lr',
            caption="Breakdown \\label{Table3}") %>% 
      kable_styling(latex_options = c("HOLD_position", full_width = T), font_size = 9) %>% 
      row_spec(0,bold=T,color = 'white', background = '#7c3042') %>% 
      row_spec(1:4, hline_after = T) %>% 
      row_spec(4, bold = T) %>% 
      column_spec(1:2, width = '5cm') %>% 
      footnote(general = "\\\\footnotesize{*This is what I want my footnote to be}", threeparttable = TRUE, escape = F)
    ```
    
    ```{r footnote}
    library(tidyverse)
    library(kableExtra)
    
    data <- structure(list(Category = c("Internally Managed", "Externally Managed", 
    "Asset Swaps", "Total"), Percent = c("44.1%", "32.5%", "23.4%", 
    "100%")), row.names = c(NA, -4L), class = c("tbl_df", "tbl", 
    "data.frame"))
    
    data %>%
     kable(format='latex',booktabs=TRUE, align = 'lr',
            caption="Breakdown \\label{Table3}") %>% 
      kable_styling(latex_options = c("HOLD_position", full_width = T), font_size = 9) %>% 
      row_spec(0,bold=T,color = 'white', background = '#7c3042') %>% 
      row_spec(1:4, hline_after = T) %>% 
      row_spec(4, bold = T) %>% 
      column_spec(1:2, width = '5cm') %>% 
      footnote(general = "*This is what I want my footnote to be", threeparttable = TRUE, escape = F)
    ```
    

    -输出

    你可以关注this

    【讨论】:

      猜你喜欢
      • 2011-06-16
      • 1970-01-01
      • 2021-10-26
      • 2011-09-03
      • 2016-01-17
      • 2011-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多