How can I put link in caption in pdf output of Rmarkdown

I am trying to convert my html output to pdf output in rmarkdown using the rticles package. I changed a lot of things in the .Rmd file and everything worked except this one thing on which I am stuck. I have a table in the Rmarkdown file which has a caption that has a link to a website as a footnote. That chunk is not working and I am getting an error. I have already tried getting the text reference in the caption but that also didn't work for me (I guess because I'm not using bookdown) Here is the code chunk:

X1=inflation_data$exp[!is.na(inflation_data$exp)&inflation_data$date<="2018-11-02"]-100
X2=inflation_data$exp[!is.na(inflation_data$exp)&inflation_data$date>="2019-01-01"]-100
Y1=inflation_data$inf_yy[inflation_data$date<="2018-11-02"]
Y2=inflation_data$inf_yy[inflation_data$date>="2019-01-01"]
df1<-DTW(X1,Y1)%>%setNames(c('x','Fixed ER regime'))
df2<-DTW(X2,Y2)%>%setNames(c('x','Managed ER regime'))
list_df=list(df1,df2)
df1122 <- list_df %>% reduce(inner_join, by='x')
colnames(df1122)[1]=''
knitr::kable(df1122,digits = 2, caption = 'Pan has been folRate regfixed) togram. Ogram was making ER flnto the IMF program.^[https://www.imf.org/05/12/pr19157-IF-Rhes-Sff-Lel-Ant-on-Emic-Poies-wh-Wn-for-a-Thee-Ye-EF]')%>%kable_classic("striped",font_size=10)%>%row_spec(0,bold=T)

And I am getting the following error:

! Missing inserted. <inserted text> l.621 ...cies-with-Pakistan-for a-Three-Year-EFF]}

Try to find the following text in elsevier.Rmd:
...cies-with-Pakistan-for a-Three-Year-EFF]}

You may need to add around a certain inline R expression r in
elsevier.Rmd (see the above hint). See
Inline R expression don't work when using scientific notation (pdf_document) · Issue #385 · rstudio/rmarkdown · GitHub for more info. Error:
LaTeX failed to compile elsevier.tex. See
The R package tinytex - Helper Functions to Manage TinyTeX, and Compile LaTeX Documents - Yihui Xie | 谢益辉 for debugging tips. See
elsevier.log for more info. Execution halted

If I remove ^[https://www.imf.org/05/12/pr19157-IF-Rhes-Sff-Lel-Ant-on-Emic-Poies-wh-Wn-for-a-Thee-Ye-EF] from my code it works fine without any error.

Also, the YAML part:

---
title: "My title"
author:
  - name: My name            
    email: my.name@google.com        
    affiliation: My Department, My Company        
    correspondingauthor: true
    footnote: 1
address:
  - code: My department   
    organization: My organization
    addressline: 1 my adress
    city: My city   
    state: My state
    postcode: 14000
    country: My country
footnote:
  - code: 1
    text: "This is the first author footnote."
abstract: |
  This is my long abstract. This is my long abstract. This is my long abstract. This is my long abstract. This is my long abstract. This is my long abstract. This is my long abstract. This is my long abstract. This is my long abstract. This is my long abstract. This is my long abstract. 
keywords: 
  - keyword1
  - keyword2
  - keyword3
journal: "An awesome journal"
date: "`r Sys.Date()`"
classoption: preprint, 3p, authoryear
bibliography: references.bib
linenumbers: false
numbersections: true
# Use a CSL with `citatssssssssssssssssssssssion_package = "default"`
# csl: https://www.zotero.org/styles/elsevier-harvard
output: 
  rticles::elsevier_article:
    latex_engine: xelatex
    keep_tex: true
    citation_package: natbib
fontsize: 12pt
---

I had no trouble knitting this as the text using the provided YAML , and the code in Issue #385 also works without modification. Is what you're looking for is that the URL in the footnote be clickable?

but it's giving me the error. I dont know why

caption in kable won't be parse as markdown. You need to either pass directly LaTeX as your caption text.

Or use some tricks to achieve conversion from Markdown to output format

I would try passing raw LaTeX maybe

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.