r语言 - 带有粘贴脚注文本的双脚注



我试图将一些表格编织成pdf。

如果在 kable 中添加add_footnote并粘贴函数变量中的文本,则脚注在 LaTeX 中加倍。 我的测试:

documentclass{article}
usepackage{threeparttable}
usepackage{booktabs}
begin{document}
<<echo=F,warning=F, message=F>>=
library(knitr)
library(tidyverse)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
fun_tab <- function(V, Title, Question, Measure){V <- enquo(V)
return(
kable(dt, format = "latex", booktabs = TRUE, caption = Title)
%>% add_footnote(c(paste0("Question (", V ,"): ", Question), Measure), threeparttable = T) # I have tried: str_c, paste, paste0
)}
fun_tab(cars, Title = "Lot of Cars", Question = "What do you know about cars?", Measure = "Nominal")
@
end{document}

结果类似于附加的图片。

来自苏黎世的问候 本

这是Markouski在github上的解决方案:

documentclass{article}
usepackage{threeparttable}
usepackage{booktabs}
begin{document}
<<echo=F,warning=F, message=F>>=
library(knitr)
library(tidyverse)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
fun_tab <- function(V, Title, Question, Measure){
V <- rlang::get_expr(enquo(V)) ## the important part of the solution
return(
kable(dt, format = "latex", booktabs = TRUE, caption = Title)
%>% add_footnote(c(paste0("Question (", V ,"): ", Question), Measure), threeparttable = T) # I have tried: str_c, paste, paste0
)}
fun_tab(cars, Title = "Lot of Cars", Question = "What do you know about cars?", Measure = "Nominal")
@
end{document}

相关内容

  • 没有找到相关文章

最新更新