Hao Zhu | bff0191 | 2017-05-23 18:05:00 -0400 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
| 2 | % Please edit documentation in R/column_spec.R |
| 3 | \name{column_spec} |
| 4 | \alias{column_spec} |
| 5 | \title{Specify the look of the selected column} |
| 6 | \usage{ |
Hao Zhu | 78e6122 | 2017-05-24 20:53:35 -0400 | [diff] [blame] | 7 | column_spec(kable_input, column, width = NULL, bold = FALSE, |
Hao Zhu | 53454f0 | 2018-01-14 16:29:10 -0500 | [diff] [blame] | 8 | italic = FALSE, monospace = FALSE, underline = FALSE, |
| 9 | strikeout = FALSE, color = NULL, background = NULL, |
Hao Zhu | b1caa27 | 2018-04-14 14:19:46 -0400 | [diff] [blame] | 10 | border_left = FALSE, border_right = FALSE, width_min = NULL, |
Duncan Murdoch | 8bc9622 | 2019-04-29 12:46:39 -0400 | [diff] [blame] | 11 | width_max = NULL, extra_css = NULL, include_thead = FALSE, |
| 12 | latex_column_spec = NULL) |
Hao Zhu | bff0191 | 2017-05-23 18:05:00 -0400 | [diff] [blame] | 13 | } |
| 14 | \arguments{ |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 15 | \item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified} |
Hao Zhu | bff0191 | 2017-05-23 18:05:00 -0400 | [diff] [blame] | 16 | |
Hao Zhu | 322de08 | 2017-09-11 19:25:29 -0400 | [diff] [blame] | 17 | \item{column}{A numeric value or vector indicating which column(s) to be selected.} |
Hao Zhu | bff0191 | 2017-05-23 18:05:00 -0400 | [diff] [blame] | 18 | |
| 19 | \item{width}{A character string telling HTML & LaTeX how wide the column |
| 20 | needs to be, e.g. "10cm", "3in" or "30em".} |
| 21 | |
| 22 | \item{bold}{A T/F value to control whether the text of the selected column |
| 23 | need to be bolded.} |
| 24 | |
| 25 | \item{italic}{A T/F value to control whether the text of the selected column |
| 26 | need to be emphasized.} |
Hao Zhu | 8f20299 | 2017-07-15 02:20:18 -0400 | [diff] [blame] | 27 | |
| 28 | \item{monospace}{A T/F value to control whether the text of the selected column |
| 29 | need to be monospaced (verbatim)} |
Hao Zhu | ec7ab92 | 2017-08-19 22:56:44 -0400 | [diff] [blame] | 30 | |
Hao Zhu | 53454f0 | 2018-01-14 16:29:10 -0500 | [diff] [blame] | 31 | \item{underline}{A T/F value to control whether the text of the selected row |
| 32 | need to be underlined} |
| 33 | |
| 34 | \item{strikeout}{A T/F value to control whether the text of the selected row |
| 35 | need to be stricked out.} |
| 36 | |
Hao Zhu | 53e240f | 2017-09-04 20:04:29 -0400 | [diff] [blame] | 37 | \item{color}{A character string for column text color. Here please pay |
| 38 | attention to the differences in color codes between HTML and LaTeX.} |
Hao Zhu | ec7ab92 | 2017-08-19 22:56:44 -0400 | [diff] [blame] | 39 | |
Hao Zhu | 53e240f | 2017-09-04 20:04:29 -0400 | [diff] [blame] | 40 | \item{background}{A character string for column background color. Here please |
| 41 | pay attention to the differences in color codes between HTML and LaTeX.} |
| 42 | |
| 43 | \item{border_left}{A logical variable indicating whether there should be a |
| 44 | border line on the left of the selected column. In HTML, you can also pass |
| 45 | in a character string for the CSS of the border line} |
| 46 | |
| 47 | \item{border_right}{A logical variable indicating whether there should be a |
| 48 | border line on the right of the selected column. In HTML, you can also pass |
| 49 | in a character string for the CSS of the border line} |
Hao Zhu | b1de967 | 2018-01-08 16:29:24 -0500 | [diff] [blame] | 50 | |
Hao Zhu | 6107f37 | 2018-05-21 00:23:26 -0400 | [diff] [blame] | 51 | \item{width_min}{Only for HTML table. Normal column width will automatically |
| 52 | collapse when the window cannot hold enough contents. With this \code{width_min}, |
| 53 | you can set up a column with a width that won't collapse even when the |
| 54 | window is not wide enough.} |
| 55 | |
| 56 | \item{width_max}{Only for HTML table. \code{width_max} defines the maximum width |
| 57 | of table columns.} |
| 58 | |
Hao Zhu | b1de967 | 2018-01-08 16:29:24 -0500 | [diff] [blame] | 59 | \item{extra_css}{Extra css text to be passed into the cells of the row. Note |
| 60 | that it's not for the whole column but to each individual cells} |
Hao Zhu | b1caa27 | 2018-04-14 14:19:46 -0400 | [diff] [blame] | 61 | |
Hao Zhu | 907ddfe | 2018-04-23 15:19:09 -0400 | [diff] [blame] | 62 | \item{include_thead}{T/F. A HTML only feature to contoll whether the |
| 63 | header row will be manipulated. Default is \code{FALSE}.} |
Duncan Murdoch | 8bc9622 | 2019-04-29 12:46:39 -0400 | [diff] [blame] | 64 | |
| 65 | \item{latex_column_spec}{Only for LaTeX tables. Code to replace the column |
| 66 | specification. If not \code{NULL}, will override all other arguments.} |
Hao Zhu | bff0191 | 2017-05-23 18:05:00 -0400 | [diff] [blame] | 67 | } |
| 68 | \description{ |
| 69 | This function allows users to select a column and then specify |
Hao Zhu | e7c8f70 | 2017-10-10 13:22:59 -0400 | [diff] [blame] | 70 | its look. |
Hao Zhu | bff0191 | 2017-05-23 18:05:00 -0400 | [diff] [blame] | 71 | } |
Duncan Murdoch | 8bc9622 | 2019-04-29 12:46:39 -0400 | [diff] [blame] | 72 | \details{ |
| 73 | Use \code{latex_column_spec} in a LaTeX table to change or |
| 74 | customize the column specification. Because of the way it is handled |
| 75 | internally, any backslashes must be escaped. |
| 76 | } |
Hao Zhu | 78e6122 | 2017-05-24 20:53:35 -0400 | [diff] [blame] | 77 | \examples{ |
| 78 | x <- knitr::kable(head(mtcars), "html") |
Hao Zhu | 4840bc9 | 2017-09-15 15:55:05 -0400 | [diff] [blame] | 79 | column_spec(x, 1:2, width = "20em", bold = TRUE, italic = TRUE) |
Duncan Murdoch | 8bc9622 | 2019-04-29 12:46:39 -0400 | [diff] [blame] | 80 | x <- knitr::kable(head(mtcars), "latex", booktabs = TRUE) |
| 81 | column_spec(x, 1, latex_column_spec = ">{\\\\\\\\color{red}}c") |
Hao Zhu | 78e6122 | 2017-05-24 20:53:35 -0400 | [diff] [blame] | 82 | } |