Specifies borders for each logical zone of an rtftable().
Each zone is either NULL (no border) or an rtf_border() object.
first_row and last_row are overrides merged on top of the body spec.
Usage
rtf_table_border(
header = NULL,
spanning = NULL,
body = NULL,
first_row = NULL,
last_row = NULL,
outer = NULL,
inside_h = NULL,
inside_v = NULL
)Arguments
- header
rtf_border()for column-header rows.NULL= none.- spanning
rtf_border()for spanning-header rows.NULL= none.- body
rtf_border()for data rows.NULL= none.- first_row
rtf_border()override for the first data row.- last_row
rtf_border()override for the last data row.- outer
rtf_border()for the table's four outermost edges, orNULL(default). See the section above.- inside_h, inside_v
Side values for the rules between rows and between cells, or
NULL(default).
Deprecated since 0.5.0
A border is now written once with rtf_border(), and where it applies is
decided by where you attach it:
rtftable(border = rtf_border(...)) # the whole table
style_zone(header = rtf_border(...), body = ...) # one kind of row
col_cell(border = rtf_border(...)) # one cellouter = becomes the four edges of that rtf_border(); inside_h = and
inside_v = keep their names. This function still works and still returns
the same value, but warns once per session.
Writing borders before and after 0.5.0
Two things changed at 0.5.0. rtf_table_border() is deprecated, so a
border is aimed with rtftable(border = ) or style_zone() instead; and an
edge now always means the outer edge of the selection, so the rules
inside it have to be asked for by name. Each case below, s being an
a border side:
## rules above and below the column header (unchanged in meaning)
was: rtftable(df, border = rtf_table_border(
header = rtf_border(top = s, bottom = s)))
now: rtftable(df, border = "none") |>
style_zone(header = rtf_border(top = s, bottom = s))
## a rule under the last data row (unchanged)
was: rtf_table_border(last_row = rtf_border(bottom = s))
now: style_zone(last_row = rtf_border(bottom = s))
## a rule under EVERY data row (bottom -> inside_h)
was: rtf_table_border(body = rtf_border(bottom = s))
now: style_zone(body = rtf_border(inside_h = s))
## a vertical rule at every column boundary (left/right -> inside_v)
was: rtf_table_border(body = rtf_border(left = s, right = s))
now: style_zone(body = rtf_border(left = s, right = s, inside_v = s))
## a grid around every data cell
was: rtf_table_border(body = rtf_border(all = TRUE))
now: style_zone(body = rtf_border(top = s, bottom = s, left = s,
right = s, inside_h = s, inside_v = s))
## an outer frame only, no rules inside (was not expressible)
now: rtftable(df, border = rtf_border(top = s, bottom = s,
left = s, right = s))
## frame plus a rule under every row -- the listing look
was: four style_header() / style_body() calls on the edge columns
now: rtftable(df, border = rtf_border(top = TRUE, bottom = TRUE,
left = TRUE, right = TRUE,
inside_h = TRUE))
At 0.6.0 the remaining constructors folded in here too, so a side is written as a value rather than built:
rtf_border_none() -> rtf_border()
rtf_border_top() -> rtf_border(top = TRUE)
rtf_border_bottom() -> rtf_border(bottom = TRUE)
rtf_border_box() -> rtf_border(all = TRUE)
rtf_border_with(b, bottom = x) -> layer at the attach point
rtf_border_tfl() -> border = "tfl", rtf_table_style_tfl()
All of them still work and warn once per session; they are removed in 0.9.0, the first CRAN release.
border = "tfl" and rtf_border_tfl() are unaffected, as is any border on
a single cell (col_cell(), cell_styles): a cell has no inside, so its
four edges never meant anything else.
The old and new readings are spelled identically, so rtfreporter warns once
per session when it meets a border that would have rendered differently
before. Naming inside_h / inside_v says which you mean and silences it
– use "none" for "no rule there".
See also
rtf_border() for the pieces; pass the result
as rtftable(border = ).
Examples
s <- TRUE
df <- data.frame(A = c("1", "2"), B = c("x", "y"))
# The clinical TFL look, spelled out one row kind at a time.
rtftable(df, border = "none") |>
style_zone(header = rtf_border(top = s, bottom = s),
last_row = rtf_border(bottom = s))
#> ────
#> A B
#> ────
#> 1 x
#> 2 y
#> ────
#>
#> <rtftable> 2 rows x 2 columns
#> Row title: col 1
#> Borders: set
#> Widths: auto / inherited
#>
# The listing look: outer frame plus a rule under every row, and no vertical
# rules between the columns.
rtftable(df, border = rtf_border(top = s, bottom = s, left = s, right = s,
inside_h = s))
#> A B
#> ────
#> 1 x
#> 2 y
#> ────
#>
#> <rtftable> 2 rows x 2 columns
#> Row title: col 1
#> Borders: set
#> Widths: auto / inherited
#>
# A full grid: add the rules between the cells.
rtftable(df, border = rtf_border(top = s, bottom = s, left = s, right = s,
inside_h = s, inside_v = s))
#> A B
#> ────
#> 1 x
#> 2 y
#> ────
#>
#> <rtftable> 2 rows x 2 columns
#> Row title: col 1
#> Borders: set
#> Widths: auto / inherited
#>
# Deprecated: the same thing written the old way (it says so once).
rtf_table_border(header = rtf_border(top = s, bottom = s))
#> Warning: `rtf_table_border()` is deprecated: a border is now written once with `rtf_border()`, and *where* it applies is decided by where you attach it.
#> whole table : rtftable(border = rtf_border(...))
#> one row kind: style_zone(header = rtf_border(...), body = ...)
#> one cell : col_cell(border = rtf_border(...))
#> `outer =` becomes the four edges of that rtf_border(); `inside_h =` and `inside_v =` keep their names.
#> See ?rtf_border, section "Writing borders before and after 0.5.0", for the old and new spelling of each case.
#> <rtf_table_border>
#> header : T=single/15 B=single/15 L=none R=none
#> spanning : none
#> body : none
#> first_row : none
#> last_row : none