cell_spec: Specify Cell/Text format

View source: R/cell_spec.R

cell_specR Documentation

Specify Cell/Text format

Description

Specify Cell format before it gets into kable

Usage

cell_spec(
  x,
  format,
  bold = FALSE,
  italic = FALSE,
  monospace = FALSE,
  underline = FALSE,
  strikeout = FALSE,
  color = NULL,
  background = NULL,
  align = NULL,
  font_size = NULL,
  angle = NULL,
  tooltip = NULL,
  popover = NULL,
  link = NULL,
  new_tab = FALSE,
  extra_css = NULL,
  escape = TRUE,
  background_as_tile = TRUE,
  latex_background_in_cell = TRUE
)

text_spec(
  x,
  format,
  bold = FALSE,
  italic = FALSE,
  monospace = FALSE,
  underline = FALSE,
  strikeout = FALSE,
  color = NULL,
  background = NULL,
  align = NULL,
  font_size = NULL,
  angle = NULL,
  tooltip = NULL,
  popover = NULL,
  link = NULL,
  new_tab = FALSE,
  extra_css = NULL,
  escape = TRUE,
  background_as_tile = TRUE,
  latex_background_in_cell = FALSE
)

Arguments

x

Things to be formatted. It could be a vector of numbers or strings.

format

Either "html" or "latex". It can also be set through option(knitr.table.format), same as knitr::kable().

bold

T/F for font bold.

italic

T/F for font italic.

monospace

T/F for font monospaced (verbatim)

underline

A T/F value to control whether the text of the selected row need to be underlined

strikeout

A T/F value to control whether the text of the selected row need to be struck out.

color

A character string for text color. Here please pay attention to the differences in color codes between HTML and LaTeX.

background

A character string for background color. Here please pay attention to the differences in color codes between HTML and LaTeX. Also note that in HTML, background defined in cell_spec won't cover the whole cell.

align

A character string for cell alignment. For HTML, possible values could be l, c, r plus left, center, right, justify, initial and inherit while for LaTeX, you can only choose from l, c & r.

font_size

A numeric input for font size. For HTML, you can also use options including xx-small, x-small, small, medium, large, x-large, xx-large, smaller, larger, initial and inherit.

angle

0-360, degree that the text will rotate. Can be a vector.

tooltip

A vector of strings to be displayed as tooltip. Obviously, this feature is only available in HTML. Read the package vignette to see how to use bootstrap tooltip css to improve the loading speed and look.

popover

Similar with tooltip but can hold more contents. The best way to build a popover is through spec_popover(). If you only provide a text string, it will be used as content. Note that You have to enable this bootstrap module manually. Read the package vignette to see how.

link

A vector of strings for url links. Can be used together with tooltip and popover.

new_tab

T/F for whether to open up the new link in new tab.

extra_css

Extra css text to be passed into the cell

escape

T/F value showing whether special characters should be escaped.

background_as_tile

T/F value indicating if you want to have round cornered tile as background in HTML.

latex_background_in_cell

T/F value. It only takes effect in LaTeX when background provided, Default value is TRUE. If it's TRUE, the background only works in a table cell. If it's FALSE, it works outside of a table environment.


kableExtra documentation built on June 22, 2024, 10:59 a.m.