Sam_9090
Sam_9090

Reputation: 321

how to insert citation in a footnote of table generated with kable?

I was trying to add citation in a footnote (or even in any text in the table) but it's not working, the citation text appears as it is. I thought I need to change the format table to markdown instead of latex and using bookdown::pdf_document2 but both did not solve the problem. another attempt was to create a citation text outside kable with a separate code chunk and then paste it inside the footnote also didn't work. this is my code:

---
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:

I would be very thankful for any useful information.

Upvotes: 1

Views: 1326

Answers (3)

Juan David Leongomez
Juan David Leongomez

Reputation: 135

If you are creating a PDF document, a simple option is to use LaTeX to insert the citation. For example:

footnote(general ="The source is \\\\cite{Burg_2019}.")

Upvotes: 0

Tom Cotter
Tom Cotter

Reputation: 19

You could possible try adding in a caption using css -> kable_styling(extra_css = ..) so you could modify its styling properties? Just a thought.

Upvotes: 0

Sam_9090
Sam_9090

Reputation: 321

well, after many attempts it worked with the conventional cross referencing here. so in case someone else is having same issue, I just did this:

(ref:caption) The source is [@Burg_2019] outside the the chunk and then inside the footnote footnote(general ="A general footnote",alphabet = "(ref:caption)" )

Upvotes: 4

Related Questions