DreamHunter
DreamHunter

Reputation: 75

bookdown table in footnote

Is it possible to put a table in the footnote in bookdown? I tried the following code and the table can not be correctly rendered.

This is footnote^[
|A   |B   |C   |
|:---|:---|:---|
|1   |4   |1   |
|2   |5   |1   |
|3   |6   |0   |
].

Upvotes: 1

Views: 851

Answers (1)

eipi10
eipi10

Reputation: 93801

This is just a start. The examples below show how to get a table in a footnote using kable from knitr and using cat to generate a hard-coded markdown table as in your example. The formatting of the footnotes doesn't look all that great, and will require some tweaking.

---
title: "Untitled"
author: "eipi10"
date: "7/12/2017"
output: bookdown::pdf_document2
---

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

This is a footnote.[^1]

[^1]: `r kable(mtcars[1:3,1:4])`


Here's another footnote.[^2]

```{r, results="asis"}
cat("[^2]:","|A   |B   |C   |
|:---|:---|:---|
|1   |4   |1   |
|2   |5   |1   |
|3   |6   |0   |", sep="\n")
```

Here's the output document with some white space excluded:

enter image description here

enter image description here

And here's the output with with bookdown::html_book as the output type:

enter image description here

Upvotes: 1

Related Questions