-
DescriptionDescriptionI have encountered some outliers in the output of my analysis. As a result, I need to add footnotes below a table to provide a simple description of the outliers. When I use the knitr kable alone, the output tables are well-organized without any page breaks. However, once I load the kableExtra package, numerous page breaks occur. Below is the code provided for reproducibility. If anyone knows how to add footnotes without causing page breaks, I would greatly appreciate your input. It is also acceptable if the kableExtra package is not used. Thank you in advance! reproducible code
outputkable outputkableExtra output |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
It seems to be an issue with what |
Beta Was this translation helpful? Give feedback.
-
One important thing to understand is that
Doc is here and you should really read it before using kableExtra : https://haozhu233.github.io/kableExtra/ Now you understand the difference, you need to understand that Quarto will do some processing to make Tables looks good, and this works for Markdown tables. Doc is here: https://quarto.org/docs/authoring/tables.html When you output a LaTeX table from your R chunk, it will already be formatted by kableExtra and we don't parse this Tables. It is left asis.
So just use this as this is how it supposed to work. This would get you the same type of output ```{r, kableExtra_chunk}
library(kableExtra)
head(iris,50) |> kable(booktabs=TRUE, longtable = TRUE) |> footnote(general = "the footnote test" ) |> kable_styling(latex_options = c("repeat_header"))
```
Some advice to improve
If you want to use other tools, you also have the gt package which has great footnote support as you can target specific cells and it support a syntax to place the footnote on a value
Hope it helps |
Beta Was this translation helpful? Give feedback.
-
Thank you for your suggestion, @mcanouil . After reading your response, I realized that I had not fully understood the process of rendering and generating output. Your suggestion provided me with some clues on how to address the overlooked aspects. Thank you, @cderv , for your incredibly helpful response. Understanding the suggestion provided by @mcanouil was challenging, but thanks to your detailed guidance, I now have a better grasp of how quarto, markdown, and the kableExtra package work. This opportunity has allowed me to learn specific methods for understanding and utilizing the given resources (quarto, markdown, package) to increase the flexibility in implementing the desired output. Thanks to both, I feel that my capabilities in R and quarto have advanced to a higher level. Your support in catching fish and teaching how to fish and excel in fishing is greatly appreciated! |
Beta Was this translation helpful? Give feedback.
One important thing to understand is that
knitr::kable()
will output Markdown by default, unless you specify some options. You can see that by usingkeep-md: true
to see the intermediary file.When you are using
kableExtra
package, you are forcing HTML or LaTeX table forkable()
. This is in the doc:Doc is here and you should really read it before using kableExtra : https://haozhu233.github.io/kableExtra/
Now you understand the difference, you need to understand that Quarto will do some processing to make Tables looks good, a…