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 | a31e97f | 2017-06-08 14:55:41 -0400 | [diff] [blame^] | 9 | font_size = NULL, ...) |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 10 | } |
| 11 | \arguments{ |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 12 | \item{kable_input}{Output of `knitr::kable()` with `format` specified} |
| 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} |
| 17 | for more information. Possible options include `basic`, `striped`, |
| 18 | `bordered`, `hover`, `condensed` and `responsive`.} |
| 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 | 971d89f | 2017-06-07 19:22:47 -0400 | [diff] [blame] | 22 | `basic`, `striped`, `hold_position`, `scale_down` & `repeat_header`. |
| 23 | `striped` will add alternative row colors to the table. It will imports |
| 24 | `LaTeX` package `xcolor` if enabled. `hold_position` will "hold" the floating |
| 25 | table to the exact position. It is useful when the `LaTeX` table is contained |
| 26 | in a `table` environment after you specified captions in `kable()`. It will |
| 27 | force the table to stay in the position where it was created in the document. |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 28 | `scale_down` is useful for super wide table. It will automatically adjust |
Hao Zhu | 971d89f | 2017-06-07 19:22:47 -0400 | [diff] [blame] | 29 | the table to page width. `repeat_header` in only meaningful in a longtable |
| 30 | environment. It will let the header row repeat on every page in that long |
| 31 | table.} |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 32 | |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 33 | \item{full_width}{A `TRUE` or `FALSE` variable controlling whether the HTML |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 34 | table should have 100\% width. Since HTML and pdf have different flavors on |
| 35 | the preferable format for `full_width`. If not specified, a HTML table will |
| 36 | have full width by default but this option will be set to `FALSE` for a |
| 37 | LaTeX table} |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 38 | |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 39 | \item{position}{A character string determining how to position the table |
| 40 | on a page. Possible values include `left`, `center`, `right`, `float_left` |
| 41 | and `float_right`. Please see the package doc site for demonstrations. For |
| 42 | a `LaTeX` table, if `float_*` is selected, `LaTeX` package `wrapfig` will be |
| 43 | imported.} |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 44 | |
| 45 | \item{font_size}{A numeric input for table font size} |
Hao Zhu | a31e97f | 2017-06-08 14:55:41 -0400 | [diff] [blame^] | 46 | |
| 47 | \item{...}{extra options for HTML or LaTeX} |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 48 | } |
| 49 | \description{ |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 50 | This function provides a cleaner approach to modify the style |
| 51 | of HTML tables other than using the `table.attr` option in `knitr::kable()`. |
| 52 | Currenly, it assumes the HTML document has boot |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 53 | } |
Hao Zhu | 78e6122 | 2017-05-24 20:53:35 -0400 | [diff] [blame] | 54 | \examples{ |
| 55 | x_html <- knitr::kable(head(mtcars), "html") |
| 56 | kable_styling(x_html, "striped", position = "left", font_size = 7) |
| 57 | |
| 58 | x_latex <- knitr::kable(head(mtcars), "latex") |
| 59 | kable_styling(x_latex, latex_options = "striped", position = "float_left") |
| 60 | |
| 61 | } |