Written and maintained by CASRAI Editorial Board
Published
On this page
kableExtra is an R package that adds styling, grouping, footnotes and layout controls to tables produced by kable() from knitr, so one table definition can be rendered as an HTML or a LaTeX (PDF) table in an R Markdown report. It does not generate tables itself: the package README states that it is not a table-generating package but one that adds features to a kable() output using pipes. The current CRAN release is version 1.4.1, published 2026-07-08, under an MIT license.
What kableExtra is used for in research
Research reports usually need tables that base kable() cannot produce alone: a header row spanning grouped columns, rows grouped under labels, notes below the table that explain abbreviations or sources, and striped or condensed styling that fits a journal or thesis template. kableExtra provides these as small functions chained after kable() or kbl(). The package author describes the intended division of labour as follows: use base kable() for simple tables, use kableExtra for most complex tables in HTML or LaTeX, and write raw HTML or LaTeX only for the remainder.
The main reason analysts choose it for reproducible reporting is the unified interface. If you set the output format in kable(), or globally through the knitr.table.format option, the kableExtra functions pick the matching HTML or LaTeX implementation automatically. A call such as kable(...) %>% kable_styling(position = "left") works in both outputs, according to the README. That lets a methods or results table live once in an .Rmd source and appear in both a web version and a PDF. If your workflow also needs Word output, see the alternatives section below and our guide to flextable, which targets Word and PowerPoint as well. For the surrounding document workflow, the R Markdown cheat sheet covers chunk and output basics.
Who maintains it and what it depends on
The CRAN page lists Hao Zhu as author and maintainer, R (>= 3.1.0) as the minimum R version, and imports including knitr (>= 1.33), magrittr, stringr, xml2, rmarkdown (>= 1.6.0), scales, viridisLite, htmltools, rstudioapi, digest and svglite. Suggested packages include testthat, magick, tinytex, formattable, sparkline and webshot2. Bugs are reported through the project’s GitHub issue tracker. The README cites the Zenodo DOI 10.5281/zenodo.1035917, and CRAN lists the package DOI 10.32614/CRAN.package.kableExtra, which you can use when citing the software in a methods section.
Install or access
Install the released version from CRAN with install.packages("kableExtra"). The README also documents a development version from GitHub: devtools::install_github("haozhu233/kableExtra"). Load it with library(kableExtra). For PDF output you also need a working LaTeX installation; the README notes that kableExtra can load the LaTeX packages it needs automatically in a vanilla R Markdown document, but if you use a custom template you must load those LaTeX packages yourself. CRAN lists tinytex under suggested packages, which is one way to obtain a LaTeX distribution from within R.
Step-by-step: build a grouped, footnoted table
The steps below follow the package’s README and its HTML vignette. The data are R’s built-in mtcars data set, used only as an illustrative stand-in for your own results; no study is implied.
- Create a small data frame:
dt = mtcars[1:5, 1:4]. - Turn it into a table with
kbl(dt, caption = "Demo Table"). The README introduceskbl()as an alternative tokable()with better documentation and format detection. For LaTeX output the README example addsbooktabs = T. - Apply a theme with
kable_styling(bootstrap_options = "striped", full_width = F). The HTML vignette lists further bootstrap options such as"hover","condensed"and"responsive", plus the standalone themeskable_classic(),kable_classic_2()andkable_paper(). - Add a spanning header with
add_header_above(c(" " = 1, "Group 1" = 2, "Group 2" = 1)). Each name is followed by the number of columns it covers; a blank name leaves a column ungrouped. The vignette shows that header rows can be stacked by chaining more than one call. - Group rows with
pack_rows("Group 1", 1, 2), which takes a label, a start row and an end row, or withpack_rows(index = c(...))when you want to name several groups in one call. - Finish with
footnote(general = "Illustrative data."). The vignette showsfootnote()acceptinggeneral,number,alphabetandsymbolarguments.
Assembled, the README’s own pattern reads as one pipeline: kbl(dt, caption = "Demo Table") %>% kable_styling(bootstrap_options = "striped", full_width = F) %>% add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2)) %>% footnote(c("table footnote")). For a PDF, the README’s LaTeX variant is kbl(dt, booktabs = T, ...) %>% kable_styling(latex_options = c("striped", "hold_position"), full_width = F).
Core functions at a glance
| Function | What it does | Example from the documentation |
|---|---|---|
| kbl() | Builds the base table; README describes it as an alternative to kable() with better documentation and format detection | kbl(dt, caption = “Demo Table”) |
| kable_styling() | Sets theme options, position, font size, fixed header and, for LaTeX, latex_options | kable_styling(position = “left”); font_size = 7; fixed_thead = T |
| column_spec() | Formats chosen columns | column_spec(5:7, bold = T) |
| row_spec() | Formats chosen rows, including the header as row 0 | row_spec(3:5, bold = T, color = “white”, background = “#D7261E”); row_spec(0, angle = -45) |
| add_header_above() | Adds a spanning header row; calls can be stacked | add_header_above(c(” ” = 1, “Group 1” = 2)) |
| pack_rows() | Groups rows under a label | pack_rows(“Group 1”, 4, 7) |
| collapse_rows() | Merges repeated cells into a multi-row cell | Listed in the vignette under grouped columns and rows |
| footnote() | Adds notes below the table | footnote(general = …, number = …, alphabet = …, symbol = …) |
| scroll_box() | HTML only: scrollable table container | scroll_box(width = “500px”, height = “200px”) |
Treat the example calls as patterns and check argument names against your installed version with ?kableExtra::pack_rows. Function names in the table come from the package vignette and README.
Output and how to read it
In HTML, kableExtra output is a styled table: striping, hover and condensed options come from the bootstrap classes you request, the spanning header appears as an extra header row above the column names, grouped rows appear as label rows, and footnotes appear beneath the table. In LaTeX the same calls emit table code that is compiled with the rest of the document, which is why booktabs = T and latex_options exist as separate arguments. In an add_header_above() specification, each name is followed by the number of columns it spans, as in the README example.
Footnote markers deserve care. The HTML vignette pairs footnote_marker_symbol(1) and footnote_marker_alphabet(1) with escape = F in kbl() so that the marker is rendered in a cell instead of being displayed as literal text.
Troubleshooting
| Symptom | Cause stated in the documentation | Fix from the documentation |
|---|---|---|
| group_rows() behaves like a dplyr function or errors | The vignette warns that group_rows() clashes with dplyr::group_rows | Use pack_rows(), or call conflicted::conflict_prefer(“group_rows”, “kableExtra”, “dplyr”) |
| Footnote marker shows as plain text | The vignette pairs footnote markers with escape = F | Add escape = F in kbl() when using footnote_marker_symbol() or footnote_marker_alphabet() |
| A feature has no effect in the PDF | Some features are listed under HTML-only in the vignette, for example scroll_box() | Use LaTeX options such as latex_options in kable_styling() for PDF output |
| PDF build fails in a custom template | The README says automatic loading of LaTeX packages applies to vanilla R Markdown | Load the required LaTeX packages in your own template |
Free alternatives
All of the packages in the data table below are free R packages distributed on CRAN. The table lists each package’s CRAN version, publication date and the role its CRAN description gives it, so you can match a package to the output you need. flextable’s description lists HTML, PDF, Typst, RTF, Word, PowerPoint, R Grid Graphics and patchwork as supported formats with the same syntax for every format, which makes it the closest match when a Word deliverable is required (see the flextable guide). gtsummary focuses on presentation-ready summary and regression tables, covered in the gtsummary guide. If your table is a cross-tabulation of categorical variables, the guide to crosstabs in R shows how to produce the underlying counts before styling.
Frequently asked questions
Is kableExtra a replacement for kable()?
No. According to its README, kableExtra adds features to a kable() output rather than generating tables, so knitr remains required (CRAN lists knitr (>= 1.33) as an import).
Does one kableExtra pipeline work for both HTML and PDF?
Yes for the shared functions. The README says that once the format is set in kable() or through knitr.table.format, the functions choose the right way automatically. HTML-only features such as scroll_box() are the exception.
What should I use instead of group_rows()?
Use pack_rows(). The HTML vignette warns that group_rows() clashes with dplyr::group_rows, and offers conflicted::conflict_prefer() as the other remedy.
How do I install it?
Run install.packages("kableExtra") for the CRAN release, or devtools::install_github("haozhu233/kableExtra") for the development version, as documented in the README.
How do I cite it?
CRAN gives the package DOI 10.32614/CRAN.package.kableExtra and the README cites the Zenodo DOI 10.5281/zenodo.1035917. State the version number you used, for example 1.4.1.
Sources
- CRAN, kableExtra package page: https://cran.r-project.org/web/packages/kableExtra/index.html (checked 2026-11-14)
- kableExtra README on GitHub: https://github.com/haozhu233/kableExtra (checked 2026-11-14)
- Create Awesome HTML Table with knitr::kable and kableExtra (vignette): https://haozhu233.github.io/kableExtra/awesome_table_in_html.html (checked 2026-11-14)
- CRAN package pages for flextable, gt and gtsummary: flextable, gt, gtsummary (checked 2026-11-14)
Data: R table-formatting packages on CRAN: version, release date and stated role
Compares kableExtra with flextable, gt and gtsummary using each package's own CRAN page: current CRAN version, publication date and the role or output formats stated in its CRAN description. Compiled by reading the four CRAN package pages.
Period covered: 2026.
| Package | CRAN version | CRAN publication date | Role stated on CRAN |
|---|---|---|---|
| kableExtra | 1.4.1 | 2026-07-08 | Build complex HTML or LaTeX tables using kable() from knitr and magrittr piping |
| flextable | 0.10.4 | 2026-11-08 | Tabular reporting grammar; HTML, PDF, Typst, RTF, Word, PowerPoint, R Grid Graphics and patchwork with the same syntax |
| gt | 1.4.0 | 2026-10-15 | Presentation-ready display tables built from table parts, with formatting functions, footnotes and cell styles |
| gtsummary | 2.6.1 | 2026-09-04 | Presentation-ready summary tables of data sets and regression models |
Sources
- CRAN: Package kableExtra (accessed 2026-11-14)
- CRAN: Package flextable (accessed 2026-11-14)
- CRAN: Package gt (accessed 2026-11-14)
- CRAN: Package gtsummary (accessed 2026-11-14)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







