Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 2 | % Please edit documentation in R/kable_styling.R |
| 3 | \name{kable_styling} |
| 4 | \alias{kable_styling} |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 5 | \title{HTML table attributes} |
| 6 | \usage{ |
Hao Zhu | a3fc0c4 | 2017-02-27 12:04:59 -0500 | [diff] [blame] | 7 | kable_styling(kable_input, bootstrap_options = "basic", |
Hao Zhu | 1fc48a6 | 2017-03-01 14:07:54 -0500 | [diff] [blame] | 8 | latex_options = "basic", full_width = NULL, position = "center", |
Hao Zhu | 68b5bbf | 2018-03-26 11:30:34 -0400 | [diff] [blame] | 9 | font_size = NULL, row_label_position = "l", ...) |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 10 | } |
| 11 | \arguments{ |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 12 | \item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 13 | |
| 14 | \item{bootstrap_options}{A character vector for bootstrap table options. |
Hao Zhu | 1fc48a6 | 2017-03-01 14:07:54 -0500 | [diff] [blame] | 15 | Please see package vignette or visit the w3schools' |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 16 | \href{https://www.w3schools.com/bootstrap/bootstrap_tables.asp}{Bootstrap Page} |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 17 | for more information. Possible options include \code{basic}, \code{striped}, |
| 18 | \code{bordered}, \code{hover}, \code{condensed} and \code{responsive}.} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 19 | |
| 20 | \item{latex_options}{A character vector for LaTeX table options. Please see |
Hao Zhu | 1fc48a6 | 2017-03-01 14:07:54 -0500 | [diff] [blame] | 21 | package vignette for more information. Possible options include |
Hao Zhu | 2a64dc6 | 2017-08-28 10:57:57 -0400 | [diff] [blame] | 22 | \code{basic}, \code{striped}, \code{hold_position}, \code{HOLD_position}, \code{scale_down} & \code{repeat_header}. |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 23 | \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 |
| 25 | table to the exact position. It is useful when the \code{LaTeX} table is contained |
| 26 | in a \code{table} environment after you specified captions in \code{kable()}. It will |
| 27 | force the table to stay in the position where it was created in the document. |
Hao Zhu | 53e240f | 2017-09-04 20:04:29 -0400 | [diff] [blame] | 28 | A stronger version: \code{HOLD_position} requires the \code{float} package and specifies \code{[H]}. |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 29 | \code{scale_down} is useful for super wide table. It will automatically adjust |
| 30 | the table to page width. \code{repeat_header} in only meaningful in a longtable |
Hao Zhu | 971d89f | 2017-06-07 19:22:47 -0400 | [diff] [blame] | 31 | environment. It will let the header row repeat on every page in that long |
| 32 | table.} |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 33 | |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 34 | \item{full_width}{A \code{TRUE} or \code{FALSE} variable controlling whether the HTML |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 35 | table should have 100\% width. Since HTML and pdf have different flavors on |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 36 | the preferable format for \code{full_width}. If not specified, a HTML table will |
| 37 | have full width by default but this option will be set to \code{FALSE} for a |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 38 | LaTeX table} |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 39 | |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 40 | \item{position}{A character string determining how to position the table |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 41 | on a page. Possible values include \code{left}, \code{center}, \code{right}, \code{float_left} |
| 42 | and \code{float_right}. Please see the package doc site for demonstrations. For |
| 43 | a \code{LaTeX} table, if \code{float_*} is selected, \code{LaTeX} package \code{wrapfig} will be |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 44 | imported.} |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 45 | |
| 46 | \item{font_size}{A numeric input for table font size} |
Hao Zhu | a31e97f | 2017-06-08 14:55:41 -0400 | [diff] [blame] | 47 | |
Hao Zhu | 68b5bbf | 2018-03-26 11:30:34 -0400 | [diff] [blame] | 48 | \item{row_label_position}{A character string determining the justification of the row |
| 49 | labels in a table. Possible values inclued \code{l} for left, \code{c} for center, and \code{r} for |
| 50 | right. The default value is \code{l} for left justifcation.} |
| 51 | |
Hao Zhu | e1be960 | 2017-08-17 15:44:31 -0400 | [diff] [blame] | 52 | \item{...}{extra options for HTML or LaTeX. See \code{details}.} |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 53 | } |
| 54 | \description{ |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 55 | This function provides a cleaner approach to modify the style |
Hao Zhu | e7c8f70 | 2017-10-10 13:22:59 -0400 | [diff] [blame] | 56 | of HTML tables other than using the \code{table.attr} option in \code{knitr::kable()}. Note |
| 57 | that those bootstrap options requires Twitter bootstrap theme, which is not avaiable |
| 58 | in some customized template being loaded. |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 59 | } |
Hao Zhu | e1be960 | 2017-08-17 15:44:31 -0400 | [diff] [blame] | 60 | \details{ |
| 61 | For 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 |
| 65 | replace the caption. |
Hao Zhu | ec7ab92 | 2017-08-19 22:56:44 -0400 | [diff] [blame] | 66 | \item \code{stripe_color} allows users to pick a different color for their strip lines. |
Hao Zhu | 53e240f | 2017-09-04 20:04:29 -0400 | [diff] [blame] | 67 | \item \code{latex_table_env} character string to define customized table environment |
| 68 | such as tabu or tabularx.You shouldn't expect all features could be |
| 69 | supported in self-defined environments. |
Hao Zhu | e1be960 | 2017-08-17 15:44:31 -0400 | [diff] [blame] | 70 | } |
| 71 | } |
Hao Zhu | 78e6122 | 2017-05-24 20:53:35 -0400 | [diff] [blame] | 72 | \examples{ |
| 73 | x_html <- knitr::kable(head(mtcars), "html") |
| 74 | kable_styling(x_html, "striped", position = "left", font_size = 7) |
| 75 | |
| 76 | x_latex <- knitr::kable(head(mtcars), "latex") |
| 77 | kable_styling(x_latex, latex_options = "striped", position = "float_left") |
| 78 | |
| 79 | } |