1

I'm preparing an R Markdown script to make a pdf (using tinytex). I have a table from kableextra with a footnote() that I'd like to have the hyperlinked URL.

I know how to bold, italicize, strikethrough text in tex, but hyperlinked URLs?

Here is an example:

enter image description here

The footnote can be linked but does not appear blue and not inline with the "Source" title.

OK - since this is markdown I'll post differently:

YAML:

output: pdf_document
header-includes:
   - \usepackage{hyperref}
   - \hypersetup{
        colorlinks=true,
        urlcolor=cyan}

Setup

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

Section with kableextra with a footnote() URL

## URL in Text Chunk
This a URL <http://rmarkdown.rstudio.com>.

Section table and URL in footnote

## URL in `kableExtra()` Footnote
```{r, echo=FALSE, warning=FALSE}
library(kableExtra)

kable(head(mtcars),
    booktabs = T, 
    linesep = "") %>%
  footnote(general="http://rmarkdown.rstudio.com", general_title = "Source: ") %>%
  kable_styling(latex_options = c("striped","hold_position"))

enter image description here

jsirgo
  • 156
  • 8
  • 1
  • Does this answer your question? [kableExtra: Hyperlink in footnote of a table](https://stackoverflow.com/questions/46140973/kableextra-hyperlink-in-footnote-of-a-table) – bttomio Mar 11 '21 at 19:00
  • Updated my post with an example. See that the footnote in the table is not blue (but can be clicked on when hovering) and it not inline with the "Source:" title. – jsirgo Mar 11 '21 at 19:26
  • 1
    It's not an example in the sense that SO expects, although it does illustrate what you are observing as a problem. Pictures of data (or input in yopur case) do not lend themselves to immediately start coding. Read [MCVE] carefully. – IRTFM Mar 11 '21 at 19:36
  • I've modified my post as best I could given the markdown - and included a snapshot of the pdf. – jsirgo Mar 11 '21 at 19:57
  • Can you combine all your code fragments into a single code block we can copy&paste to reproduce the problem? – samcarter_is_at_topanswers.xyz Mar 11 '21 at 20:13

1 Answers1

3

I figured it out.

I needed to change:

footnote(general="http://rmarkdown.rstudio.com", general_title = "Source: ")

to: footnote(general="\\\\url{http://rmarkdown.rstudio.com}", general_title = "Source: ", footnote_as_chunk = T, escape=F)

Thanks all

jsirgo
  • 156
  • 8