blob: 2d693eaaeb13a5bc9e8e5f2db21160fe06cc703c [file] [log] [blame]
Hao Zhue10cfd32017-02-21 16:41:14 -05001% Generated by roxygen2: do not edit by hand
Hao Zhuc1f38412017-02-23 12:13:48 -05002% Please edit documentation in R/kable_styling.R
3\name{kable_styling}
4\alias{kable_styling}
Hao Zhue10cfd32017-02-21 16:41:14 -05005\title{HTML table attributes}
6\usage{
Hao Zhua3fc0c42017-02-27 12:04:59 -05007kable_styling(kable_input, bootstrap_options = "basic",
Hao Zhu1fc48a62017-03-01 14:07:54 -05008 latex_options = "basic", full_width = NULL, position = "center",
Hao Zhu68b5bbf2018-03-26 11:30:34 -04009 font_size = NULL, row_label_position = "l", ...)
Hao Zhue10cfd32017-02-21 16:41:14 -050010}
11\arguments{
Hao Zhu76281fe2017-07-03 19:33:09 -040012\item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified}
Hao Zhuf7994dd2017-02-27 16:58:42 -050013
14\item{bootstrap_options}{A character vector for bootstrap table options.
Hao Zhu1fc48a62017-03-01 14:07:54 -050015Please see package vignette or visit the w3schools'
Hao Zhuf7994dd2017-02-27 16:58:42 -050016\href{https://www.w3schools.com/bootstrap/bootstrap_tables.asp}{Bootstrap Page}
Hao Zhu76281fe2017-07-03 19:33:09 -040017for more information. Possible options include \code{basic}, \code{striped},
18\code{bordered}, \code{hover}, \code{condensed} and \code{responsive}.}
Hao Zhuf7994dd2017-02-27 16:58:42 -050019
20\item{latex_options}{A character vector for LaTeX table options. Please see
Hao Zhu1fc48a62017-03-01 14:07:54 -050021package vignette for more information. Possible options include
Hao Zhu2a64dc62017-08-28 10:57:57 -040022\code{basic}, \code{striped}, \code{hold_position}, \code{HOLD_position}, \code{scale_down} & \code{repeat_header}.
Hao Zhu76281fe2017-07-03 19:33:09 -040023\code{striped} will add alternative row colors to the table. It will imports
24\code{LaTeX} package \code{xcolor} if enabled. \code{hold_position} will "hold" the floating
25table to the exact position. It is useful when the \code{LaTeX} table is contained
26in a \code{table} environment after you specified captions in \code{kable()}. It will
27force the table to stay in the position where it was created in the document.
Hao Zhu53e240f2017-09-04 20:04:29 -040028A stronger version: \code{HOLD_position} requires the \code{float} package and specifies \code{[H]}.
Hao Zhu76281fe2017-07-03 19:33:09 -040029\code{scale_down} is useful for super wide table. It will automatically adjust
30the table to page width. \code{repeat_header} in only meaningful in a longtable
Hao Zhu971d89f2017-06-07 19:22:47 -040031environment. It will let the header row repeat on every page in that long
32table.}
Hao Zhue10cfd32017-02-21 16:41:14 -050033
Hao Zhu76281fe2017-07-03 19:33:09 -040034\item{full_width}{A \code{TRUE} or \code{FALSE} variable controlling whether the HTML
Hao Zhuf7994dd2017-02-27 16:58:42 -050035table should have 100\% width. Since HTML and pdf have different flavors on
Hao Zhu76281fe2017-07-03 19:33:09 -040036the preferable format for \code{full_width}. If not specified, a HTML table will
37have full width by default but this option will be set to \code{FALSE} for a
Hao Zhuf7994dd2017-02-27 16:58:42 -050038LaTeX table}
Hao Zhu94956582017-02-21 18:18:29 -050039
Hao Zhuf7994dd2017-02-27 16:58:42 -050040\item{position}{A character string determining how to position the table
Hao Zhu76281fe2017-07-03 19:33:09 -040041on a page. Possible values include \code{left}, \code{center}, \code{right}, \code{float_left}
42and \code{float_right}. Please see the package doc site for demonstrations. For
43a \code{LaTeX} table, if \code{float_*} is selected, \code{LaTeX} package \code{wrapfig} will be
Hao Zhuf7994dd2017-02-27 16:58:42 -050044imported.}
Hao Zhu94956582017-02-21 18:18:29 -050045
46\item{font_size}{A numeric input for table font size}
Hao Zhua31e97f2017-06-08 14:55:41 -040047
Hao Zhu68b5bbf2018-03-26 11:30:34 -040048\item{row_label_position}{A character string determining the justification of the row
49labels in a table. Possible values inclued \code{l} for left, \code{c} for center, and \code{r} for
50right. The default value is \code{l} for left justifcation.}
51
Hao Zhue1be9602017-08-17 15:44:31 -040052\item{...}{extra options for HTML or LaTeX. See \code{details}.}
Hao Zhue10cfd32017-02-21 16:41:14 -050053}
54\description{
Hao Zhu26234122017-02-22 15:34:33 -050055This function provides a cleaner approach to modify the style
Hao Zhue7c8f702017-10-10 13:22:59 -040056of HTML tables other than using the \code{table.attr} option in \code{knitr::kable()}. Note
57that those bootstrap options requires Twitter bootstrap theme, which is not avaiable
58in some customized template being loaded.
Hao Zhue10cfd32017-02-21 16:41:14 -050059}
Hao Zhue1be9602017-08-17 15:44:31 -040060\details{
61For LaTeX, extra options includes:
62\itemize{
63\item \code{repeat_header_method} can either be \code{append}(default) or \code{replace}
64\item \code{repeat_header_text} is just a text string you want to append on or
65replace the caption.
Hao Zhuec7ab922017-08-19 22:56:44 -040066\item \code{stripe_color} allows users to pick a different color for their strip lines.
Hao Zhu53e240f2017-09-04 20:04:29 -040067\item \code{latex_table_env} character string to define customized table environment
68such as tabu or tabularx.You shouldn't expect all features could be
69supported in self-defined environments.
Hao Zhue1be9602017-08-17 15:44:31 -040070}
71}
Hao Zhu78e61222017-05-24 20:53:35 -040072\examples{
73x_html <- knitr::kable(head(mtcars), "html")
74kable_styling(x_html, "striped", position = "left", font_size = 7)
75
76x_latex <- knitr::kable(head(mtcars), "latex")
77kable_styling(x_latex, latex_options = "striped", position = "float_left")
78
79}