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