kbl | R Documentation |
The knitr::kable()
function is the foundation of this package.
However, it has many latex/html specific arguments hidden under the ground
unless you check its source code. This wrapper function is created to
provide better documentation (and auto-complete yay) and at the same time,
solve the auto format setting in a better way.
kbl(
x,
format,
digits = getOption("digits"),
row.names = NA,
col.names = NA,
align,
caption = NULL,
label = NULL,
format.args = list(),
escape = TRUE,
table.attr = getOption("knitr.table.html.attr", ""),
booktabs = FALSE,
longtable = FALSE,
tabular = if (longtable) "longtable" else "tabular",
valign = if (tabular %in% c("tabularx", "xltabular")) "{\\linewidth}" else "[t]",
position = "",
centering = TRUE,
vline = getOption("knitr.table.vline", if (booktabs) "" else "|"),
toprule = getOption("knitr.table.toprule", if (booktabs) "\\toprule" else
"\\hline"),
bottomrule = getOption("knitr.table.bottomrule", if (booktabs) "\\bottomrule" else
"\\hline"),
midrule = getOption("knitr.table.midrule", if (booktabs) "\\midrule" else
"\\hline"),
linesep = if (booktabs) c("", "", "", "", "\\addlinespace") else "\\hline",
caption.short = "",
table.envir = if (!is.null(caption)) "table",
...
)
x |
For |
format |
A character string. Possible values are |
digits |
Maximum number of digits for numeric columns, passed to
|
row.names |
Logical: whether to include row names. By default, row names
are included if |
col.names |
A character vector of column names to be used in the table. |
align |
Column alignment: a character vector consisting of |
caption |
The table caption. |
label |
The table reference label. By default, the label is obtained
from |
format.args |
A list of arguments to be passed to |
escape |
Boolean; whether to escape special characters when producing
HTML or LaTeX tables. When |
table.attr |
A character string for addition HTML table attributes. This is convenient if you simply want to add a few HTML classes or styles. For example, you can put 'class="table" style="color: red"'. |
booktabs |
T/F for whether to enable the booktabs format for tables. I personally would recommend you turn this on for every latex table except some special cases. |
longtable |
T/F for whether to use the longtable format. If you have a table that will span over two or more pages, you will have to turn this on. |
tabular |
The "inner environment" to use for the table, e.g. "tabularx". |
valign |
You probably won't need to adjust this latex option very often.
If you are familiar with latex tables, this is the optional position for the
tabular environment controlling the vertical position of the table relative
to the baseline of the surrounding text. Possible choices are |
position |
This is the "real" or say floating position for the latex
table environment. The |
centering |
T (default)/F. Whether to center tables in the table environment. |
vline |
vertical separator. Default is nothing for booktabs tables but "|" for normal tables. |
toprule |
toprule. Default is hline for normal table but toprule for booktabs tables. |
bottomrule |
bottomrule. Default is hline for normal table but bottomrule for booktabs tables. |
midrule |
midrule. Default is hline for normal table but midrule for booktabs tables. |
linesep |
By default, in booktabs tables, |
caption.short |
Another latex feature. Short captions for tables |
table.envir |
You probably don't need to change this as well. The default setting is to put a table environment outside of tabular if a caption is provided. |
... |
Other arguments (see Examples and References). |
The current set of arguments were written for
knitr
version 1.45. If you are using an older
or newer version, some of the default values may be different.
In knitr::kable()
, the escape
parameter does not affect the text
in the caption
argument, and kbl()
inherits this
behavior. This means that special characters
in the caption (such as "%" for LaTeX output)
need to be escaped by the user, e.g.
written as "\\%"
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.