How can I create a short caption in kable
?
library(dplyr)
library(knitr)
library(kableExtra)
df <- data.frame( X = sample(letters, 10), y = runif(10), z = sample(10:20, 10))
kable(df,
booktabs = TRUE,
caption = "This caption is way too long and doesnt look good when formatted in the Table of Contents. What you really need here is a much shorter caption so that your eyes dont go crazy trying to figure out what information the author is trying to convey. Often there is too much information in the caption anyway so why not shorten it?.",
escape = FALSE,
format = 'latex') %>%
kable_styling(latex_options = c("striped", "hold_position"))
10.1 The function knitr::kable() The kable() function in knitr is a very simple table generator, and is simple by design. It only generates tables for strictly rectangular data such as matrices and data frames. You cannot heavily format the table cells or merge cells.
The kableExtra package (Zhu 2021) is designed to extend the basic functionality of tables produced using knitr::kable() (see Section 10.1).
Upon installing, inserttable registers a new RStudio Addin (Insert Table) that can be used to easily insert a table in a Rmd document. To use it, open a Rmd or R document and select “Addins –> Insert Table”.
I found a very obscure reference to this option for kable
.
To make your caption short simply use e.g., caption.short = "This is a short caption"
.
library(dplyr)
library(knitr)
library(kableExtra)
df <- data.frame( X = sample(letters, 10), y = runif(10), z = sample(10:20, 10))
kable(df,
booktabs = TRUE,
caption = "This caption is way too long and doesnt look good when formatted in the Table of Contents. What you really need here is a much shorter caption so that your eyes dont go crazy trying to figure out what information the author is trying to convey. Often there is too much information in the caption anyway so why not shorten it?.",
caption.short = "This is a shorter caption.",
escape = FALSE,
format = 'latex') %>%
kable_styling(latex_options = c("striped", "hold_position"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With