blob: 2a3248d23a4ee1374c72c075f039a46e3037301f [file] [log] [blame]
Hao Zhue10cfd32017-02-21 16:41:14 -05001#' HTML table attributes
2#'
Hao Zhu26234122017-02-22 15:34:33 -05003#' @description This function provides a cleaner approach to modify the style
4#' of HTML tables other than using the `table.attr` option in `knitr::kable()`.
5#' Currenly, it assumes the HTML document has boot
Hao Zhue10cfd32017-02-21 16:41:14 -05006#'
Hao Zhuf7994dd2017-02-27 16:58:42 -05007#' @param kable_input Output of `knitr::kable()` with `format` specified
8#' @param bootstrap_options A character vector for bootstrap table options.
Hao Zhu6a076462017-03-01 12:59:01 -05009#' Please see package vignette or visit the w3schools'
Hao Zhuf7994dd2017-02-27 16:58:42 -050010#' \href{https://www.w3schools.com/bootstrap/bootstrap_tables.asp}{Bootstrap Page}
11#' for more information. Possible options include `basic`, `striped`,
12#' `bordered`, `hover`, `condensed` and `responsive`.
13#' @param latex_options A character vector for LaTeX table options. Please see
Hao Zhu6a076462017-03-01 12:59:01 -050014#' package vignette for more information. Possible options include
Hao Zhu971d89f2017-06-07 19:22:47 -040015#' `basic`, `striped`, `hold_position`, `scale_down` & `repeat_header`.
16#' `striped` will add alternative row colors to the table. It will imports
17#' `LaTeX` package `xcolor` if enabled. `hold_position` will "hold" the floating
18#' table to the exact position. It is useful when the `LaTeX` table is contained
19#' in a `table` environment after you specified captions in `kable()`. It will
20#' force the table to stay in the position where it was created in the document.
Hao Zhuf7994dd2017-02-27 16:58:42 -050021#' `scale_down` is useful for super wide table. It will automatically adjust
Hao Zhu971d89f2017-06-07 19:22:47 -040022#' the table to page width. `repeat_header` in only meaningful in a longtable
23#' environment. It will let the header row repeat on every page in that long
24#' table.
Hao Zhu59f5fe02017-02-22 11:27:14 -050025#' @param full_width A `TRUE` or `FALSE` variable controlling whether the HTML
Hao Zhuf7994dd2017-02-27 16:58:42 -050026#' table should have 100\% width. Since HTML and pdf have different flavors on
27#' the preferable format for `full_width`. If not specified, a HTML table will
28#' have full width by default but this option will be set to `FALSE` for a
29#' LaTeX table
30#' @param position A character string determining how to position the table
31#' on a page. Possible values include `left`, `center`, `right`, `float_left`
32#' and `float_right`. Please see the package doc site for demonstrations. For
33#' a `LaTeX` table, if `float_*` is selected, `LaTeX` package `wrapfig` will be
34#' imported.
Hao Zhu94956582017-02-21 18:18:29 -050035#' @param font_size A numeric input for table font size
Hao Zhue1be9602017-08-17 15:44:31 -040036#' @param ... extra options for HTML or LaTeX. See `details`.
37#'
38#' @details For LaTeX, extra options includes:
39#' - `repeat_header_method` can either be `append`(default) or `replace`
40#' - `repeat_header_text` is just a text string you want to append on or
41#' replace the caption.
Hao Zhu71a224f2017-08-18 11:06:22 -040042#' - `stripe_color` allows users to pick a different color for their strip lines.
Hao Zhue10cfd32017-02-21 16:41:14 -050043#'
Hao Zhu78e61222017-05-24 20:53:35 -040044#' @examples x_html <- knitr::kable(head(mtcars), "html")
45#' kable_styling(x_html, "striped", position = "left", font_size = 7)
46#'
47#' x_latex <- knitr::kable(head(mtcars), "latex")
48#' kable_styling(x_latex, latex_options = "striped", position = "float_left")
49#'
Hao Zhue10cfd32017-02-21 16:41:14 -050050#' @export
Hao Zhuc1f38412017-02-23 12:13:48 -050051kable_styling <- function(kable_input,
52 bootstrap_options = "basic",
Hao Zhuc05e1812017-02-25 01:45:35 -050053 latex_options = "basic",
54 full_width = NULL,
Hao Zhu9b45a182017-02-27 18:17:46 -050055 position = "center",
Hao Zhua31e97f2017-06-08 14:55:41 -040056 font_size = NULL,
57 ...) {
Hao Zhu9b45a182017-02-27 18:17:46 -050058
59 if (length(bootstrap_options) == 1 && bootstrap_options == "basic") {
60 bootstrap_options <- getOption("kable_styling_bootstrap_options", "basic")
61 }
62 if (length(latex_options) == 1 && latex_options == "basic") {
63 latex_options <- getOption("kable_styling_latex_options", "basic")
64 }
65 if (position == "center") {
66 position <- getOption("kable_styling_position", "center")
67 }
68 position <- match.arg(position,
69 c("center", "left", "right", "float_left", "float_right"))
70 if (is.null(font_size)) {
71 font_size <- getOption("kable_styling_font_size", NULL)
72 }
73
Hao Zhuc1f38412017-02-23 12:13:48 -050074 kable_format <- attr(kable_input, "format")
Hao Zhu9b45a182017-02-27 18:17:46 -050075
Hao Zhuc1f38412017-02-23 12:13:48 -050076 if (!kable_format %in% c("html", "latex")) {
guangchuang yu9c405392017-04-29 12:34:04 +080077 message("Currently generic markdown table using pandoc is not supported.")
78 return(kable_input)
Hao Zhuc1f38412017-02-23 12:13:48 -050079 }
80 if (kable_format == "html") {
Hao Zhu9b45a182017-02-27 18:17:46 -050081 if (is.null(full_width)) {
82 full_width <- getOption("kable_styling_full_width", T)
83 }
Hao Zhuc1f38412017-02-23 12:13:48 -050084 return(htmlTable_styling(kable_input,
85 bootstrap_options = bootstrap_options,
86 full_width = full_width,
Hao Zhuc05e1812017-02-25 01:45:35 -050087 position = position,
Hao Zhua31e97f2017-06-08 14:55:41 -040088 font_size = font_size, ...))
Hao Zhuc1f38412017-02-23 12:13:48 -050089 }
90 if (kable_format == "latex") {
Hao Zhu9b45a182017-02-27 18:17:46 -050091 if (is.null(full_width)) {
92 full_width <- getOption("kable_styling_full_width", F)
93 }
Hao Zhuc05e1812017-02-25 01:45:35 -050094 return(pdfTable_styling(kable_input,
95 latex_options = latex_options,
96 full_width = full_width,
97 position = position,
Hao Zhua31e97f2017-06-08 14:55:41 -040098 font_size = font_size, ...))
Hao Zhuc1f38412017-02-23 12:13:48 -050099 }
100}
101
102# htmlTable Styling ------------
Hao Zhu26234122017-02-22 15:34:33 -0500103htmlTable_styling <- function(kable_input,
104 bootstrap_options = "basic",
105 full_width = T,
Hao Zhuc05e1812017-02-25 01:45:35 -0500106 position = c("center", "left", "right",
107 "float_left", "float_right"),
Hao Zhu26234122017-02-22 15:34:33 -0500108 font_size = NULL) {
Hao Zhu909ea382017-06-12 15:43:47 -0400109 kable_attrs <- attributes(kable_input)
Hao Zhu9bab1532017-07-24 15:08:41 -0400110 kable_xml <- read_kable_as_xml(kable_input)
Hao Zhu26234122017-02-22 15:34:33 -0500111
112 # Modify class
Hao Zhue10cfd32017-02-21 16:41:14 -0500113 bootstrap_options <- match.arg(
114 bootstrap_options,
Hao Zhu26234122017-02-22 15:34:33 -0500115 c("basic", "striped", "bordered", "hover", "condensed", "responsive"),
Hao Zhue10cfd32017-02-21 16:41:14 -0500116 several.ok = T
117 )
118
Hao Zhu26234122017-02-22 15:34:33 -0500119 kable_xml_class <- NULL
120 if (xml_has_attr(kable_xml, "class")) {
121 kable_xml_class <- xml_attr(kable_xml, "class")
Hao Zhue10cfd32017-02-21 16:41:14 -0500122 }
Hao Zhu26234122017-02-22 15:34:33 -0500123 if (length(bootstrap_options) == 1 && bootstrap_options == "basic") {
124 bootstrap_options <- "table"
125 } else {
126 bootstrap_options <- bootstrap_options[bootstrap_options != "basic"]
127 bootstrap_options <- paste0("table-", bootstrap_options)
128 bootstrap_options <- c("table", bootstrap_options)
129 }
130 xml_attr(kable_xml, "class") <- paste(c(kable_xml_class, bootstrap_options),
131 collapse = " ")
Hao Zhue10cfd32017-02-21 16:41:14 -0500132
Hao Zhu26234122017-02-22 15:34:33 -0500133 # Modify style
134 kable_xml_style <- NULL
135 if (xml_has_attr(kable_xml, "style")) {
136 kable_xml_style <- xml_attr(kable_xml, "style")
137 }
Hao Zhue10cfd32017-02-21 16:41:14 -0500138 if (!is.null(font_size)) {
Hao Zhu26234122017-02-22 15:34:33 -0500139 kable_xml_style <- c(kable_xml_style,
Hao Zhuc1f38412017-02-23 12:13:48 -0500140 paste0("font-size: ", font_size, "px;"))
Hao Zhufc14c9b2017-05-22 14:03:22 -0400141 kable_caption_node <- xml_tpart(kable_xml, "caption")
142 if (!is.null(kable_caption_node)) {
143 xml_attr(kable_caption_node, "style") <- "font-size: initial !important;"
144 }
Hao Zhue10cfd32017-02-21 16:41:14 -0500145 }
146 if (!full_width) {
Hao Zhu26234122017-02-22 15:34:33 -0500147 kable_xml_style <- c(kable_xml_style, "width: auto !important;")
Hao Zhue10cfd32017-02-21 16:41:14 -0500148 }
Hao Zhu94956582017-02-21 18:18:29 -0500149
Hao Zhuc05e1812017-02-25 01:45:35 -0500150 position <- match.arg(position)
151 position_style <- switch(
152 position,
153 center = "margin-left: auto; margin-right: auto;",
Hao Zhufd516ba2017-07-28 14:30:25 -0400154 left = "",
Hao Zhuc05e1812017-02-25 01:45:35 -0500155 right = "margin-right: 0; margin-left: auto",
156 float_left = "float: left; margin-right: 10px;",
157 float_right = "float: right; margin-left: 10px;"
158 )
159 kable_xml_style <- c(kable_xml_style, position_style)
160
Hao Zhu26234122017-02-22 15:34:33 -0500161 if (length(kable_xml_style) != 0) {
162 xml_attr(kable_xml, "style") <- paste(kable_xml_style, collapse = " ")
Hao Zhue10cfd32017-02-21 16:41:14 -0500163 }
Hao Zhu9b45a182017-02-27 18:17:46 -0500164
Hao Zhuf2dfd142017-07-24 14:43:28 -0400165 out <- as_kable_xml(kable_xml)
Hao Zhu909ea382017-06-12 15:43:47 -0400166 attributes(out) <- kable_attrs
Hao Zhu9b45a182017-02-27 18:17:46 -0500167 return(out)
Hao Zhue10cfd32017-02-21 16:41:14 -0500168}
Hao Zhuc1f38412017-02-23 12:13:48 -0500169
170# LaTeX table style
171pdfTable_styling <- function(kable_input,
Hao Zhuc05e1812017-02-25 01:45:35 -0500172 latex_options = "basic",
173 full_width = F,
174 position = c("center", "left", "right",
Hao Zhua3fc0c42017-02-27 12:04:59 -0500175 "float_left", "float_right"),
Hao Zhua31e97f2017-06-08 14:55:41 -0400176 font_size = NULL,
Hao Zhuca211db2017-07-25 00:06:43 -0400177 repeat_header_text = "\\textit{(continued)}",
Hao Zhue1be9602017-08-17 15:44:31 -0400178 repeat_header_method = c("append", "replace"),
Hao Zhu71a224f2017-08-18 11:06:22 -0400179 stripe_color = "gray!6") {
Hao Zhuc1f38412017-02-23 12:13:48 -0500180
Hao Zhuc05e1812017-02-25 01:45:35 -0500181 latex_options <- match.arg(
182 latex_options,
Hao Zhu971d89f2017-06-07 19:22:47 -0400183 c("basic", "striped", "hold_position", "scale_down", "repeat_header"),
Hao Zhuc05e1812017-02-25 01:45:35 -0500184 several.ok = T
185 )
186
Hao Zhuca211db2017-07-25 00:06:43 -0400187 repeat_header_method <- match.arg(repeat_header_method)
188
Hao Zhua3fc0c42017-02-27 12:04:59 -0500189 out <- NULL
Hao Zhuc05e1812017-02-25 01:45:35 -0500190 out <- as.character(kable_input)
191 table_info <- magic_mirror(kable_input)
Hao Zhuc05e1812017-02-25 01:45:35 -0500192
193 if ("striped" %in% latex_options) {
Hao Zhu71a224f2017-08-18 11:06:22 -0400194 out <- styling_latex_striped(out, table_info, stripe_color)
Hao Zhuc05e1812017-02-25 01:45:35 -0500195 }
196
197 # hold_position is only meaningful in a table environment
198 if ("hold_position" %in% latex_options & table_info$table_env) {
Hao Zhua3fc0c42017-02-27 12:04:59 -0500199 out <- styling_latex_hold_position(out)
Hao Zhuc05e1812017-02-25 01:45:35 -0500200 }
201
Hao Zhua3fc0c42017-02-27 12:04:59 -0500202 if ("scale_down" %in% latex_options) {
203 out <- styling_latex_scale_down(out, table_info)
Hao Zhuc05e1812017-02-25 01:45:35 -0500204 }
205
Hao Zhu971d89f2017-06-07 19:22:47 -0400206 if ("repeat_header" %in% latex_options & table_info$tabular == "longtable") {
Hao Zhuca211db2017-07-25 00:06:43 -0400207 out <- styling_latex_repeat_header(out, table_info, repeat_header_text,
208 repeat_header_method)
Hao Zhu971d89f2017-06-07 19:22:47 -0400209 }
210
Hao Zhuc05e1812017-02-25 01:45:35 -0500211 if (full_width) {
Hao Zhua3fc0c42017-02-27 12:04:59 -0500212 out <- styling_latex_full_width(out, table_info)
213 }
Hao Zhuc05e1812017-02-25 01:45:35 -0500214
Hao Zhua3fc0c42017-02-27 12:04:59 -0500215 if (!is.null(font_size)) {
216 out <- styling_latex_font_size(out, table_info, font_size)
Hao Zhuc05e1812017-02-25 01:45:35 -0500217 }
218
219 position <- match.arg(position)
Hao Zhua3fc0c42017-02-27 12:04:59 -0500220 out <- styling_latex_position(out, table_info, position, latex_options)
Hao Zhuc05e1812017-02-25 01:45:35 -0500221
222 out <- structure(out, format = "latex", class = "knitr_kable")
Hao Zhu32f43f72017-06-20 18:24:54 -0400223 attr(out, "kable_meta") <- table_info
Hao Zhuc05e1812017-02-25 01:45:35 -0500224 return(out)
Hao Zhuc1f38412017-02-23 12:13:48 -0500225}
Hao Zhua3fc0c42017-02-27 12:04:59 -0500226
Hao Zhue1be9602017-08-17 15:44:31 -0400227styling_latex_striped <- function(x, table_info, color) {
Hao Zhu7d4a3e32017-06-08 21:29:13 -0400228 # gray!6 is the same as shadecolor ({RGB}{248, 248, 248}) in pdf_document
229 if (table_info$tabular == "longtable" & !is.na(table_info$caption)) {
Hao Zhue1be9602017-08-17 15:44:31 -0400230 row_color <- sprintf("\\rowcolors{2}{white}{%s}", color)
Hao Zhu7d4a3e32017-06-08 21:29:13 -0400231 } else {
Hao Zhue1be9602017-08-17 15:44:31 -0400232 row_color <- sprintf("\\rowcolors{2}{%s}{white}", color)
Hao Zhu7d4a3e32017-06-08 21:29:13 -0400233 }
Hao Zhu00ba87c2017-08-01 12:42:58 -0400234
235 x <- read_lines(x)
236 if (table_info$booktabs) {
237 header_rows_start <- which(x == "\\toprule")[1]
238 header_rows_end <- which(x == "\\midrule")[1]
239 } else {
240 header_rows_start <- which(x == "\\hline")[1]
241 header_rows_end <- which(x == "\\hline")[2]
242 }
243
244 x <- c(
245 row_color,
246 x[1:(header_rows_start - 1)],
247 "\\hiderowcolors",
248 x[header_rows_start:header_rows_end],
249 "\\showrowcolors",
250 x[(header_rows_end + 1):length(x)],
251 "\\rowcolors{2}{white}{white}"
252 )
253 x <- paste0(x, collapse = "\n")
254 return(x)
Hao Zhua3fc0c42017-02-27 12:04:59 -0500255}
256
257styling_latex_hold_position <- function(x) {
258 sub("\\\\begin\\{table\\}", "\\\\begin\\{table\\}[!h]", x)
259}
260
261styling_latex_scale_down <- function(x, table_info) {
262 # You cannot put longtable in a resizebox
263 # http://tex.stackexchange.com/questions/83457/how-to-resize-or-scale-a-longtable-revised
264 if (table_info$tabular == "longtable") {
265 warning("Longtable cannot be resized.")
266 return(x)
267 }
268 x <- sub(table_info$begin_tabular,
Hao Zhucc21dc72017-05-20 01:15:25 -0400269 paste0("\\\\resizebox\\{\\\\linewidth\\}\\{\\!\\}\\{",
Hao Zhua3fc0c42017-02-27 12:04:59 -0500270 table_info$begin_tabular),
271 x)
272 sub(table_info$end_tabular, paste0(table_info$end_tabular, "\\}"), x)
273}
274
Hao Zhuca211db2017-07-25 00:06:43 -0400275styling_latex_repeat_header <- function(x, table_info, repeat_header_text,
276 repeat_header_method) {
Hao Zhua31e97f2017-06-08 14:55:41 -0400277 x <- read_lines(x)
278 if (table_info$booktabs) {
279 header_rows_start <- which(x == "\\toprule")[1]
280 header_rows_end <- which(x == "\\midrule")[1]
281 } else {
282 header_rows_start <- which(x == "\\hline")[1]
283 header_rows_end <- which(x == "\\hline")[2]
284 }
Hao Zhufdec1842017-06-08 17:06:04 -0400285
286 if (is.na(table_info$caption)) {
287 continue_line <- paste0(
288 "\\multicolumn{", table_info$ncol, "}{@{}l}{", repeat_header_text,
289 "}\\\\"
290 )
291 } else {
Hao Zhuca211db2017-07-25 00:06:43 -0400292 if (repeat_header_method == "append") {
Hao Zhufd2ef9b2017-07-25 13:14:18 -0400293 caption_without_lab <- sub("\\\\label\\{[^\\}]*\\}", "", table_info$caption)
Hao Zhu6f95ea42017-07-25 13:12:12 -0400294 repeat_header_text <- paste(caption_without_lab, repeat_header_text)
Hao Zhuca211db2017-07-25 00:06:43 -0400295 }
Hao Zhu68d4fe92017-07-25 14:07:50 -0400296 continue_line <- paste0("\\caption[]{", repeat_header_text, "}\\\\")
Hao Zhufdec1842017-06-08 17:06:04 -0400297 }
298
Stéphane Laurent316fd742017-08-12 21:02:52 +0200299 index_bottomrule <- which(x == "\\bottomrule")
300 x <- x[-index_bottomrule]
301 x[index_bottomrule - 1] <- paste0(x[index_bottomrule - 1], "*\\bottomrule")
Hao Zhua31e97f2017-06-08 14:55:41 -0400302 x <- c(
303 x[1:header_rows_end],
304 "\\endfirsthead",
305 continue_line,
306 x[header_rows_start:header_rows_end],
307 "\\endhead",
308 x[(header_rows_end + 1):length(x)]
309 )
310 x <- paste0(x, collapse = "\n")
311 return(x)
Hao Zhu971d89f2017-06-07 19:22:47 -0400312}
313
Hao Zhua3fc0c42017-02-27 12:04:59 -0500314styling_latex_full_width <- function(x, table_info) {
315 size_matrix <- sapply(sapply(table_info$contents, str_split, " & "), nchar)
316 col_max_length <- apply(size_matrix, 1, max) + 4
317 col_ratio <- round(col_max_length / sum(col_max_length), 2)
318 col_align <- paste0("p{\\\\dimexpr", col_ratio,
Hao Zhu6a076462017-03-01 12:59:01 -0500319 "\\\\columnwidth-2\\\\tabcolsep}")
Hao Zhua3fc0c42017-02-27 12:04:59 -0500320 col_align <- paste0("{", paste(col_align, collapse = ""), "}")
321 x <- sub(paste0(table_info$begin_tabular, "\\{[^\\\\n]*\\}"),
322 table_info$begin_tabular, x)
323 sub(table_info$begin_tabular,
324 paste0(table_info$begin_tabular, col_align), x)
325}
326
327styling_latex_position <- function(x, table_info, position, latex_options) {
328 hold_position <- "hold_position" %in% latex_options
329 switch(
330 position,
331 center = styling_latex_position_center(x, table_info, hold_position),
332 left = styling_latex_position_left(x, table_info),
333 right = styling_latex_position_right(x, table_info, hold_position),
334 float_left = styling_latex_position_float(x, table_info, "l"),
335 float_right = styling_latex_position_float(x, table_info, "r")
336 )
337}
338
339styling_latex_position_center <- function(x, table_info, hold_position) {
340 if (!table_info$table_env & table_info$tabular == "tabular") {
Hao Zhuf7994dd2017-02-27 16:58:42 -0500341 return(paste0("\\begin{table}[!h]\n\\centering", x, "\n\\end{table}"))
Hao Zhua3fc0c42017-02-27 12:04:59 -0500342 }
343 return(x)
344}
345
346styling_latex_position_left <- function(x, table_info) {
347 if (table_info$tabular != "longtable") return(sub("\\\\centering\\n", "", x))
348 longtable_option <- "\\[l\\]"
349 sub(paste0("\\\\begin\\{longtable\\}", table_info$valign2),
350 paste0("\\\\begin\\{longtable\\}", longtable_option), x)
351}
352
353styling_latex_position_right <- function(x, table_info, hold_position) {
354 warning("Position = right is only supported for longtable in LaTeX. ",
355 "Setting back to center...")
356 styling_latex_position_center(x, table_info, hold_position)
357}
358
359styling_latex_position_float <- function(x, table_info, option) {
360 if (table_info$tabular == "longtable") {
361 warning("wraptable is not supported for longtable.")
362 if (option == "l") return(styling_latex_position_left(x, table_info))
363 if (option == "r") return(styling_latex_position_right(x, table_info, F))
364 }
Hao Zhuf7994dd2017-02-27 16:58:42 -0500365 size_matrix <- sapply(sapply(table_info$contents, str_split, " & "), nchar)
366 col_max_length <- apply(size_matrix, 1, max) + 4
Hao Zhua3fc0c42017-02-27 12:04:59 -0500367 if (table_info$table_env) {
Hao Zhua3fc0c42017-02-27 12:04:59 -0500368 option <- sprintf("\\\\begin\\{wraptable\\}\\{%s\\}", option)
369 option <- paste0(option, "\\{",sum(col_max_length) * 0.15, "cm\\}")
370 x <- sub("\\\\begin\\{table\\}\\[\\!h\\]", "\\\\begin\\{table\\}", x)
371 x <- sub("\\\\begin\\{table\\}", option, x)
372 x <- sub("\\\\end\\{table\\}", "\\\\end\\{wraptable\\}", x)
Hao Zhuf7994dd2017-02-27 16:58:42 -0500373 } else {
374 option <- sprintf("\\begin{wraptable}{%s}", option)
375 option <- paste0(option, "{",sum(col_max_length) * 0.15, "cm}")
376 x <- paste0(option, x, "\\end{wraptable}")
Hao Zhua3fc0c42017-02-27 12:04:59 -0500377 }
Hao Zhuf7994dd2017-02-27 16:58:42 -0500378 return(x)
Hao Zhua3fc0c42017-02-27 12:04:59 -0500379}
380
381styling_latex_font_size <- function(x, table_info, font_size) {
382 row_height <- font_size + 2
383 if (table_info$tabular == "tabular" & table_info$table_env) {
384 return(sub(table_info$begin_tabular,
385 paste0("\\\\fontsize\\{", font_size, "\\}\\{", row_height,
386 "\\}\\\\selectfont\n", table_info$begin_tabular),
387 x))
388 }
389 # For longtable and tabular without table environment. Simple wrap around
390 # fontsize is good enough
391 return(paste0(
392 "\\begingroup\\fontsize{", font_size, "}{", row_height, "}\\selectfont\n", x,
393 "\\endgroup"
394 ))
395}
Hao Zhuf2dfd142017-07-24 14:43:28 -0400396
397