如何在用kable生成的表格的脚注中插入引文?

时间:2020-04-24 19:53:56

标签: r-markdown kable

我试图在脚注(甚至表中的任何文本)中添加引文,但没有用,引文原样显示。我以为我需要将格式表更改为markdown而不是latex并使用bookdown::pdf_document2,但是两者都不能解决问题。另一尝试是在kable外部用单独的代码块创建引文,然后在pastefootnote对其无效。 这是我的代码:

---
title: "scientific report"
output:
  pdf_document:
   fig_caption: true
   keep_tex: true
   number_sections: yes
   latex_engine: xelatex
csl: elsevier-with-titles.csl
bibliography: citations.bib
link-citations: true
linkcolor: blue
---



# This is an exaample


the number of the table below is [\ref{do}]

P.S. I wrote the superscript (a) manually in the xlsx file.

```{r  echo=FALSE }
library(knitr)
library(kableExtra)
library("readxl")

dfdf <-  read_excel("dyss_count.xlsx")
df <- as.data.frame(dfdf)

options(knitr.kable.NA = '')

kable(df, "latex", longtable = T, booktabs = T,escape = F ,caption = 'dosage \\label{do}',align = "c") %>%
  kable_styling(latex_options = c('repeat_header'), font_size = 7) %>%

 footnote(general ="A general footnote",


           alphabet = 'the source is @Burg_2019',

           general_title = "General: ", number_title = "Type I: ",
           alphabet_title = "Type II: ", 
           footnote_as_chunk = T, title_format = c("italic", "underline")
           )


result is:

非常感谢您提供任何有用的信息。

2 个答案:

答案 0 :(得分:2)

好吧,经过多次尝试,它可以与常规的交叉引用here一起使用。所以 万一别人有同样的问题,我就是这样做的:

(ref:caption) The source is [@Burg_2019],然后在脚注footnote(general ="A general footnote",alphabet = "(ref:caption)" )

答案 1 :(得分:0)

您可以尝试使用css-> kable_styling(extra_css = ..)添加标题,以便修改其样式属性?只是一个想法。