我正在尝试在我的R Markdown文档的脚注中包含小图标(保存为.png文件),该文档将被转换为PDF文件。我希望这些图标在脚注中提供额外的视觉信息,但我在实现这一点时遇到了困难。
我尝试使用HTML标签和LaTeX的\includegraphics包,但图标在PDF输出中无法正确显示。有没有人可以提供指导,如何成功地将这些图标包含在从R Markdown生成的PDF的脚注中?
提前感谢您的帮助!
# Load the required libraries
library(kableExtra)
library(dplyr)
# Create example data
data <- data.frame(
Category = c("Toyota", "Honda", "Ford", "Nissan"),
Count = c(50, 60, 45, 55),
Minimum = c(100, 110, 95, 105),
Maximum = c(200, 210, 195, 205)
)
# Define a vector with image links and descriptions in a footnote
footnote_text <- c(
"Decreasing < -5% ",
"Slightly Decreasing -5 to -1% ",
"Stagnant -1 to +1% ",
"Slightly Increasing +1 to +5% ",
"Increasing > +5% "
)
# Create the table with adjusted column names
table <- kbl(data, booktabs = TRUE, col.names = c("Category", "Count", "Min", "Max")) %>%
kable_styling(latex_options = c("striped"), font_size = 10, position = "center") %>%
add_header_above(c(" " = 1, "(n)" = 1, "in Dollars" = 2)) %>%
add_header_above(c(" " = 1, "Count" = 1, "Values" = 2))%>%
add_footnote(footnote_text, notation="none")
# Display the table
table
1条答案
按热度按时间k3fezbri1#
这个应该可以了提供存储在
Images
文件夹中的图像。基本上你必须传递png图像作为
<img>
属性。然后将字符串显示为html,即add_footnote(..., escape = F)
。