blob: 608e6f932c7fc015b520a875b6e49b56112966e5 [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 Zhu7039ecf2019-01-06 17:51:21 -05009 font_size = NULL, row_label_position = "l",
10 repeat_header_text = "\\\\textit{(continued)}",
11 repeat_header_method = c("append", "replace"),
12 repeat_header_continued = FALSE, stripe_color = "gray!6",
13 latex_table_env = NULL)
Hao Zhue10cfd32017-02-21 16:41:14 -050014}
15\arguments{
Hao Zhu76281fe2017-07-03 19:33:09 -040016\item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified}
Hao Zhuf7994dd2017-02-27 16:58:42 -050017
18\item{bootstrap_options}{A character vector for bootstrap table options.
Hao Zhu1fc48a62017-03-01 14:07:54 -050019Please see package vignette or visit the w3schools'
Hao Zhuf7994dd2017-02-27 16:58:42 -050020\href{https://www.w3schools.com/bootstrap/bootstrap_tables.asp}{Bootstrap Page}
Hao Zhu76281fe2017-07-03 19:33:09 -040021for more information. Possible options include \code{basic}, \code{striped},
22\code{bordered}, \code{hover}, \code{condensed} and \code{responsive}.}
Hao Zhuf7994dd2017-02-27 16:58:42 -050023
24\item{latex_options}{A character vector for LaTeX table options. Please see
Hao Zhu1fc48a62017-03-01 14:07:54 -050025package vignette for more information. Possible options include
Hao Zhu2a64dc62017-08-28 10:57:57 -040026\code{basic}, \code{striped}, \code{hold_position}, \code{HOLD_position}, \code{scale_down} & \code{repeat_header}.
Hao Zhu76281fe2017-07-03 19:33:09 -040027\code{striped} will add alternative row colors to the table. It will imports
28\code{LaTeX} package \code{xcolor} if enabled. \code{hold_position} will "hold" the floating
29table to the exact position. It is useful when the \code{LaTeX} table is contained
30in a \code{table} environment after you specified captions in \code{kable()}. It will
31force the table to stay in the position where it was created in the document.
Hao Zhu53e240f2017-09-04 20:04:29 -040032A stronger version: \code{HOLD_position} requires the \code{float} package and specifies \code{[H]}.
Hao Zhu76281fe2017-07-03 19:33:09 -040033\code{scale_down} is useful for super wide table. It will automatically adjust
34the table to page width. \code{repeat_header} in only meaningful in a longtable
Hao Zhu971d89f2017-06-07 19:22:47 -040035environment. It will let the header row repeat on every page in that long
36table.}
Hao Zhue10cfd32017-02-21 16:41:14 -050037
Hao Zhu76281fe2017-07-03 19:33:09 -040038\item{full_width}{A \code{TRUE} or \code{FALSE} variable controlling whether the HTML
Hao Zhuf7994dd2017-02-27 16:58:42 -050039table should have 100\% width. Since HTML and pdf have different flavors on
Hao Zhu76281fe2017-07-03 19:33:09 -040040the preferable format for \code{full_width}. If not specified, a HTML table will
41have full width by default but this option will be set to \code{FALSE} for a
Hao Zhuf7994dd2017-02-27 16:58:42 -050042LaTeX table}
Hao Zhu94956582017-02-21 18:18:29 -050043
Hao Zhuf7994dd2017-02-27 16:58:42 -050044\item{position}{A character string determining how to position the table
Hao Zhu76281fe2017-07-03 19:33:09 -040045on a page. Possible values include \code{left}, \code{center}, \code{right}, \code{float_left}
46and \code{float_right}. Please see the package doc site for demonstrations. For
47a \code{LaTeX} table, if \code{float_*} is selected, \code{LaTeX} package \code{wrapfig} will be
Hao Zhuf7994dd2017-02-27 16:58:42 -050048imported.}
Hao Zhu94956582017-02-21 18:18:29 -050049
50\item{font_size}{A numeric input for table font size}
Hao Zhua31e97f2017-06-08 14:55:41 -040051
Hao Zhu7039ecf2019-01-06 17:51:21 -050052\item{row_label_position}{A character string determining the justification
53of the row labels in a table. Possible values inclued \code{l} for left, \code{c} for
54center, and \code{r} for right. The default value is \code{l} for left justifcation.}
Hao Zhu68b5bbf2018-03-26 11:30:34 -040055
Hao Zhu7039ecf2019-01-06 17:51:21 -050056\item{repeat_header_text}{LaTeX option. A text string you want to append on
57or replace the caption.}
58
59\item{repeat_header_method}{LaTeX option, can either be \code{append}(default) or
60\code{replace}}
61
62\item{stripe_color}{LaTeX option allowing users to pick a different color
63for their strip lines. This option is not available in HTML}
64
65\item{latex_table_env}{LaTeX option. A character string to define customized
66table environment such as tabu or tabularx.You shouldn't expect all features
67could be supported in self-defined environments.}
Hao Zhue10cfd32017-02-21 16:41:14 -050068}
69\description{
Hao Zhu26234122017-02-22 15:34:33 -050070This function provides a cleaner approach to modify the style
Hao Zhue7c8f702017-10-10 13:22:59 -040071of HTML tables other than using the \code{table.attr} option in \code{knitr::kable()}. Note
72that those bootstrap options requires Twitter bootstrap theme, which is not avaiable
73in some customized template being loaded.
Hao Zhue10cfd32017-02-21 16:41:14 -050074}
Hao Zhue1be9602017-08-17 15:44:31 -040075\details{
antaldanielcf11dac2018-05-30 21:54:37 +020076For LaTeX, if you use other than English environment
77\itemize{
78\item all tables are converted to 'UTF-8'. If you use, for example, Hungarian
79characters on a Windows machine, make sure to use
80Sys.setlocale("LC_ALL","Hungarian") to avoid unexpected conversions.
81}
Hao Zhue1be9602017-08-17 15:44:31 -040082}
Hao Zhu78e61222017-05-24 20:53:35 -040083\examples{
84x_html <- knitr::kable(head(mtcars), "html")
85kable_styling(x_html, "striped", position = "left", font_size = 7)
86
87x_latex <- knitr::kable(head(mtcars), "latex")
88kable_styling(x_latex, latex_options = "striped", position = "float_left")
89
90}