微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何减小 kableExtra (LaTeX) 中脚注的大小

如何解决如何减小 kableExtra (LaTeX) 中脚注的大小

我使用 kableExtra 包在 Rmarkdown 中创建了下表。我正在寻找一种方法来减小脚注的大小。在 size = 1 参数中添加 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,size = 7)

解决方法

您可以添加一些 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",width = '5cm') %>% 
  footnote(general = "\\\\footnotesize{*This is what I want my footnote to be}",escape = F)
```

```{r footnote}
library(tidyverse)
library(kableExtra)

data <- structure(list(Category = c("Internally Managed",width = '5cm') %>% 
  footnote(general = "*This is what I want my footnote to be",escape = F)
```

-输出

enter image description here

您可以关注this

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。