我正在尝试使用knitr + kableextra + pack_rows在表中添加脚注,该行跨越多列
在搜索解决方案时,除了“请确保您使用escape = F”类型的解决方案外,我已经空了。另外,我编织到pdf还是html似乎都没有关系。两者似乎都插入了脚注字符串,但尚不清楚是否只是未正确转义它,还是其他原因。
最小的可复制示例...
---
title: "Footnote Test"
output:
html_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidyverse)
library(knitr)
library(kableExtra)
```
```{r cars}
dt <- mtcars[1:5, 1:6]
```
## Footnote Example
This works just fine!
```{r cars-footnote}
dt_footnote <- dt
names(dt_footnote)[2] <- paste0(names(dt_footnote)[2],
footnote_marker_symbol(1))
row.names(dt_footnote)[4] <- paste0(row.names(dt_footnote)[4],
footnote_marker_alphabet(1))
kable(dt_footnote, align = "c",
# Remember this escape = F
escape = F) %>%
kable_styling(full_width = F) %>%
footnote(alphabet = "Footnote A; ",
symbol = "Footnote Symbol 1; ",
alphabet_title = "Type II: ", symbol_title = "Type III: ",
footnote_as_chunk = T)
```
## Footnote on Span
```{r cars-footnote-scan}
dt_span <- dt %>%
arrange(cyl) %>%
select(cyl, everything())
prlabel <- paste0("Six-Cylinder",
footnote_marker_alphabet(1))
kable(dt_span, align = "c", escape = FALSE) %>%
kable_styling(full_width = FALSE) %>%
pack_rows(prlabel, 2, 4) %>%
footnote(alphabet = "Footnote A", footnote_as_chunk = T, escape = FALSE)
```
根据输出判断,脚注符号会添加到正确的位置。我不知道这是一个错误还是需要设置一个参数。
任何帮助将不胜感激。