带有粘贴脚注文本的双脚注

Double footnotes with pasted footnotetext

我正在尝试将一些表格编成 pdf。

如果在 kable 中添加 add_footnote 并粘贴来自函数变量的文本,则脚注在 LaTeX 中会加倍。 我的 Test.Rnw:

\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}

The Result looks like the attached Picture.

来自苏黎世的问候 本

这是 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}