Create a kable table with some reasonable ATLAS defaults.
fmt_kbl(
x,
booktabs = TRUE,
linesep = "",
centering = FALSE,
escape = FALSE,
position = "left",
latex_options = "HOLD_position",
...
)
For kable()
, x
is an R object, which is typically a
matrix or data frame. For kables()
, a list with each element being a
returned value from kable()
.
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.
By default, in booktabs tables, kable
insert an extra space
every five rows for clear display. If you don't want this feature or if you
want to do it in a different pattern, you can consider change this option.
The default is c(”, ”, ”, ”, '\addlinespace'). Also, if you are not
using booktabs, but you want a cleaner display, you can change this to ”.
T (default)/F. Whether to center tables in the table environment.
Boolean; whether to escape special characters when producing
HTML or LaTeX tables. When escape = FALSE
, you have to make sure
that special characters will not trigger syntax errors in LaTeX or HTML.
This is the "real" or say floating position for the latex
table environment. The kable
only puts tables in a table environment when
a caption is provided. That is also the reason why your tables will be
floating around if you specify captions for your table. Possible choices are
h
(here), t
(top, default), b
(bottom) and p
(on a dedicated page).
A character vector for LaTeX table options. Please see
package vignette for more information. Possible options include
basic
, striped
, hold_position
, HOLD_position
, scale_down
, scale_up
& repeat_header
.
striped
will add alternative row colors to the table. It will imports
LaTeX
package xcolor
if enabled. hold_position
will "hold" the floating
table to the exact position. It is useful when the LaTeX
table is contained
in a table
environment after you specified captions in kable()
. It will
force the table to stay in the position where it was created in the document.
A stronger version: HOLD_position
requires the float
package and specifies [H]
.
scale_down
is useful for super wide table. It will automatically adjust
the table to page width. repeat_header
in only meaningful in a longtable
environment. It will let the header row repeat on every page in that long
table.
Additional parameters passed to kableExtra::kbl()
.
A kable object.
fmt_kbl(mtcars[, 1:3], align = c("r", "c", "r"),
col.names = c("Column 1", "Column 2", "Column 3"),
caption = "Example Table Title")
#> <table class="table lightable-classic" style=' font-family: "Arial Narrow", "Source Sans Pro", sans-serif; '>
#> <caption>Example Table Title</caption>
#> <thead>
#> <tr>
#> <th style="text-align:left;"> </th>
#> <th style="text-align:right;"> Column 1 </th>
#> <th style="text-align:center;"> Column 2 </th>
#> <th style="text-align:right;"> Column 3 </th>
#> </tr>
#> </thead>
#> <tbody>
#> <tr>
#> <td style="text-align:left;"> Mazda RX4 </td>
#> <td style="text-align:right;"> 21.0 </td>
#> <td style="text-align:center;"> 6 </td>
#> <td style="text-align:right;"> 160.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Mazda RX4 Wag </td>
#> <td style="text-align:right;"> 21.0 </td>
#> <td style="text-align:center;"> 6 </td>
#> <td style="text-align:right;"> 160.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Datsun 710 </td>
#> <td style="text-align:right;"> 22.8 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 108.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Hornet 4 Drive </td>
#> <td style="text-align:right;"> 21.4 </td>
#> <td style="text-align:center;"> 6 </td>
#> <td style="text-align:right;"> 258.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Hornet Sportabout </td>
#> <td style="text-align:right;"> 18.7 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 360.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Valiant </td>
#> <td style="text-align:right;"> 18.1 </td>
#> <td style="text-align:center;"> 6 </td>
#> <td style="text-align:right;"> 225.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Duster 360 </td>
#> <td style="text-align:right;"> 14.3 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 360.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Merc 240D </td>
#> <td style="text-align:right;"> 24.4 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 146.7 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Merc 230 </td>
#> <td style="text-align:right;"> 22.8 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 140.8 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Merc 280 </td>
#> <td style="text-align:right;"> 19.2 </td>
#> <td style="text-align:center;"> 6 </td>
#> <td style="text-align:right;"> 167.6 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Merc 280C </td>
#> <td style="text-align:right;"> 17.8 </td>
#> <td style="text-align:center;"> 6 </td>
#> <td style="text-align:right;"> 167.6 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Merc 450SE </td>
#> <td style="text-align:right;"> 16.4 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 275.8 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Merc 450SL </td>
#> <td style="text-align:right;"> 17.3 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 275.8 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Merc 450SLC </td>
#> <td style="text-align:right;"> 15.2 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 275.8 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Cadillac Fleetwood </td>
#> <td style="text-align:right;"> 10.4 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 472.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Lincoln Continental </td>
#> <td style="text-align:right;"> 10.4 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 460.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Chrysler Imperial </td>
#> <td style="text-align:right;"> 14.7 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 440.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Fiat 128 </td>
#> <td style="text-align:right;"> 32.4 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 78.7 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Honda Civic </td>
#> <td style="text-align:right;"> 30.4 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 75.7 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Toyota Corolla </td>
#> <td style="text-align:right;"> 33.9 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 71.1 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Toyota Corona </td>
#> <td style="text-align:right;"> 21.5 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 120.1 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Dodge Challenger </td>
#> <td style="text-align:right;"> 15.5 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 318.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> AMC Javelin </td>
#> <td style="text-align:right;"> 15.2 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 304.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Camaro Z28 </td>
#> <td style="text-align:right;"> 13.3 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 350.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Pontiac Firebird </td>
#> <td style="text-align:right;"> 19.2 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 400.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Fiat X1-9 </td>
#> <td style="text-align:right;"> 27.3 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 79.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Porsche 914-2 </td>
#> <td style="text-align:right;"> 26.0 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 120.3 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Lotus Europa </td>
#> <td style="text-align:right;"> 30.4 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 95.1 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Ford Pantera L </td>
#> <td style="text-align:right;"> 15.8 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 351.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Ferrari Dino </td>
#> <td style="text-align:right;"> 19.7 </td>
#> <td style="text-align:center;"> 6 </td>
#> <td style="text-align:right;"> 145.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Maserati Bora </td>
#> <td style="text-align:right;"> 15.0 </td>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:right;"> 301.0 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> Volvo 142E </td>
#> <td style="text-align:right;"> 21.4 </td>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:right;"> 121.0 </td>
#> </tr>
#> </tbody>
#> </table>