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 | 9410a27 | 2020-08-03 01:11:47 -0400 | [diff] [blame] | 7 | kable_styling( |
| 8 | kable_input, |
| 9 | bootstrap_options = "basic", |
| 10 | latex_options = "basic", |
| 11 | full_width = NULL, |
| 12 | position = "center", |
| 13 | font_size = NULL, |
| 14 | row_label_position = "l", |
Duncan Murdoch | 911dca3 | 2019-01-05 16:39:32 -0500 | [diff] [blame] | 15 | repeat_header_text = "\\\\textit{(continued)}", |
| 16 | repeat_header_method = c("append", "replace"), |
Hao Zhu | 9410a27 | 2020-08-03 01:11:47 -0400 | [diff] [blame] | 17 | repeat_header_continued = FALSE, |
| 18 | stripe_color = "gray!6", |
| 19 | stripe_index = NULL, |
| 20 | latex_table_env = NULL, |
| 21 | protect_latex = TRUE, |
| 22 | table.envir = "table", |
Hao Zhu | ad4ea39 | 2020-08-10 01:24:50 -0400 | [diff] [blame] | 23 | fixed_thead = FALSE, |
| 24 | lightable_class = NULL |
Hao Zhu | 9410a27 | 2020-08-03 01:11:47 -0400 | [diff] [blame] | 25 | ) |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 26 | } |
| 27 | \arguments{ |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 28 | \item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 29 | |
| 30 | \item{bootstrap_options}{A character vector for bootstrap table options. |
Hao Zhu | 1fc48a6 | 2017-03-01 14:07:54 -0500 | [diff] [blame] | 31 | Please see package vignette or visit the w3schools' |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 32 | \href{https://www.w3schools.com/bootstrap/bootstrap_tables.asp}{Bootstrap Page} |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 33 | for more information. Possible options include \code{basic}, \code{striped}, |
Hao Zhu | ad4ea39 | 2020-08-10 01:24:50 -0400 | [diff] [blame] | 34 | \code{bordered}, \code{hover}, \code{condensed}, \code{responsive} and \code{none}.} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 35 | |
| 36 | \item{latex_options}{A character vector for LaTeX table options. Please see |
Hao Zhu | 1fc48a6 | 2017-03-01 14:07:54 -0500 | [diff] [blame] | 37 | package vignette for more information. Possible options include |
Hao Zhu | 2a64dc6 | 2017-08-28 10:57:57 -0400 | [diff] [blame] | 38 | \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] | 39 | \code{striped} will add alternative row colors to the table. It will imports |
| 40 | \code{LaTeX} package \code{xcolor} if enabled. \code{hold_position} will "hold" the floating |
| 41 | table to the exact position. It is useful when the \code{LaTeX} table is contained |
| 42 | in a \code{table} environment after you specified captions in \code{kable()}. It will |
| 43 | force the table to stay in the position where it was created in the document. |
Hao Zhu | 9410a27 | 2020-08-03 01:11:47 -0400 | [diff] [blame] | 44 | A stronger version: \code{HOLD_position} requires the \code{float} package and specifies \verb{[H]}. |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 45 | \code{scale_down} is useful for super wide table. It will automatically adjust |
| 46 | 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] | 47 | environment. It will let the header row repeat on every page in that long |
| 48 | table.} |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 49 | |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 50 | \item{full_width}{A \code{TRUE} or \code{FALSE} variable controlling whether the HTML |
Hao Zhu | 9410a27 | 2020-08-03 01:11:47 -0400 | [diff] [blame] | 51 | 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] | 52 | the preferable format for \code{full_width}. If not specified, a HTML table will |
| 53 | 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] | 54 | LaTeX table} |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 55 | |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 56 | \item{position}{A character string determining how to position the table |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 57 | on a page. Possible values include \code{left}, \code{center}, \code{right}, \code{float_left} |
| 58 | and \code{float_right}. Please see the package doc site for demonstrations. For |
Hao Zhu | 9410a27 | 2020-08-03 01:11:47 -0400 | [diff] [blame] | 59 | a \code{LaTeX} table, if \verb{float_*} is selected, \code{LaTeX} package \code{wrapfig} will be |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 60 | imported.} |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 61 | |
| 62 | \item{font_size}{A numeric input for table font size} |
Hao Zhu | a31e97f | 2017-06-08 14:55:41 -0400 | [diff] [blame] | 63 | |
Duncan Murdoch | 911dca3 | 2019-01-05 16:39:32 -0500 | [diff] [blame] | 64 | \item{row_label_position}{A character string determining the justification |
| 65 | of the row labels in a table. Possible values inclued \code{l} for left, \code{c} for |
| 66 | center, and \code{r} for right. The default value is \code{l} for left justifcation.} |
Hao Zhu | 68b5bbf | 2018-03-26 11:30:34 -0400 | [diff] [blame] | 67 | |
Duncan Murdoch | 911dca3 | 2019-01-05 16:39:32 -0500 | [diff] [blame] | 68 | \item{repeat_header_text}{LaTeX option. A text string you want to append on |
| 69 | or replace the caption.} |
| 70 | |
| 71 | \item{repeat_header_method}{LaTeX option, can either be \code{append}(default) or |
| 72 | \code{replace}} |
| 73 | |
Hao Zhu | 1c4917e | 2019-01-15 17:00:01 -0600 | [diff] [blame] | 74 | \item{repeat_header_continued}{T/F or a text string. Whether or not to put |
| 75 | a continued mark on the second page of longtable. If you put in text, we will |
| 76 | use this text as the "continued" mark.} |
| 77 | |
Duncan Murdoch | 911dca3 | 2019-01-05 16:39:32 -0500 | [diff] [blame] | 78 | \item{stripe_color}{LaTeX option allowing users to pick a different color |
| 79 | for their strip lines. This option is not available in HTML} |
| 80 | |
Hao Zhu | d851693 | 2019-01-06 18:56:47 -0500 | [diff] [blame] | 81 | \item{stripe_index}{LaTeX option allowing users to customize which rows |
| 82 | should have stripe color.} |
| 83 | |
Duncan Murdoch | 911dca3 | 2019-01-05 16:39:32 -0500 | [diff] [blame] | 84 | \item{latex_table_env}{LaTeX option. A character string to define customized |
| 85 | table environment such as tabu or tabularx.You shouldn't expect all features |
| 86 | could be supported in self-defined environments.} |
| 87 | |
| 88 | \item{protect_latex}{If \code{TRUE}, LaTeX code embedded between dollar signs |
Duncan Murdoch | 95c1437 | 2019-01-06 10:51:58 -0500 | [diff] [blame] | 89 | will be protected from HTML escaping.} |
Hao Zhu | 9b05159 | 2019-01-07 18:13:51 -0500 | [diff] [blame] | 90 | |
| 91 | \item{table.envir}{LaTeX floating table environment. \code{kable_style} will put |
| 92 | a plain no-caption table in a \code{table} environment in order to center the |
Hao Zhu | 9410a27 | 2020-08-03 01:11:47 -0400 | [diff] [blame] | 93 | table. You can specify this option to things like \verb{table*} or \verb{float*} based |
Hao Zhu | 9b05159 | 2019-01-07 18:13:51 -0500 | [diff] [blame] | 94 | on your need.} |
Hao Zhu | 72917f9 | 2019-03-15 18:41:42 -0400 | [diff] [blame] | 95 | |
| 96 | \item{fixed_thead}{HTML table option so table header row is fixed at top. |
| 97 | Values can be either T/F or \code{list(enabled = T/F, background = "anycolor")}.} |
Hao Zhu | ad4ea39 | 2020-08-10 01:24:50 -0400 | [diff] [blame] | 98 | |
| 99 | \item{lightable_class}{Options to use the in-house lightable themes. |
| 100 | Choices include \code{lightable-minimal}, \code{lightable-classic}, |
| 101 | \code{lightable-material}, \code{lightable-striped} and \code{lightable-hover}.} |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 102 | } |
| 103 | \description{ |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 104 | This function provides a cleaner approach to modify the style |
Hao Zhu | e7c8f70 | 2017-10-10 13:22:59 -0400 | [diff] [blame] | 105 | of HTML tables other than using the \code{table.attr} option in \code{knitr::kable()}. Note |
| 106 | that those bootstrap options requires Twitter bootstrap theme, which is not avaiable |
| 107 | in some customized template being loaded. |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 108 | } |
Hao Zhu | e1be960 | 2017-08-17 15:44:31 -0400 | [diff] [blame] | 109 | \details{ |
antaldaniel | cf11dac | 2018-05-30 21:54:37 +0200 | [diff] [blame] | 110 | For LaTeX, if you use other than English environment |
| 111 | \itemize{ |
| 112 | \item all tables are converted to 'UTF-8'. If you use, for example, Hungarian |
| 113 | characters on a Windows machine, make sure to use |
| 114 | Sys.setlocale("LC_ALL","Hungarian") to avoid unexpected conversions. |
Duncan Murdoch | 95c1437 | 2019-01-06 10:51:58 -0500 | [diff] [blame] | 115 | \item \code{protect_latex = TRUE} has no effect. |
| 116 | } |
| 117 | |
| 118 | For HTML, |
| 119 | \itemize{ |
| 120 | \item \code{protect_latex = TRUE} is for including complicated math in HTML output. |
| 121 | The LaTeX may not include dollar signs even if they are escaped. |
| 122 | Pandoc's rules for recognizing embedded LaTeX are used. |
antaldaniel | cf11dac | 2018-05-30 21:54:37 +0200 | [diff] [blame] | 123 | } |
Hao Zhu | e1be960 | 2017-08-17 15:44:31 -0400 | [diff] [blame] | 124 | } |
Hao Zhu | 78e6122 | 2017-05-24 20:53:35 -0400 | [diff] [blame] | 125 | \examples{ |
| 126 | x_html <- knitr::kable(head(mtcars), "html") |
| 127 | kable_styling(x_html, "striped", position = "left", font_size = 7) |
| 128 | |
| 129 | x_latex <- knitr::kable(head(mtcars), "latex") |
| 130 | kable_styling(x_latex, latex_options = "striped", position = "float_left") |
| 131 | |
| 132 | } |