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