flextable separates border control into high-level helpers for common patterns and lower-level functions for precise placement. All border styling requires anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/davidgohel/flextable/llms.txt
Use this file to discover all available pages before exploring further.
officer::fp_border() object to describe the line’s appearance.
Defining a border style with fp_border()
fp_border() from the officer package describes a single border line:
fp_border_default() returns a border using the current flextable defaults:
Removing all borders
border_remove() sets every border in the table to zero width, across all parts:
Table-level border helpers
These functions apply borders to whole structural regions of the table.Outer borders
border_outer() frames the outside edge of one or all parts:
Inner horizontal borders
border_inner_h() draws a horizontal line between every pair of adjacent rows:
Inner vertical borders
border_inner_v() draws a vertical line between every pair of adjacent columns:
All inner borders
border_inner() applies both horizontal and vertical inner borders in one call:
Row-level horizontal lines
hline() — horizontal line below selected rows
hline() draws a line below each selected row i. It sets both the bottom border of row i and the top border of row i + 1 to ensure consistent rendering:
i selector:
before(x, entries) returns a logical vector marking the rows immediately before the first occurrence of any of entries — a convenient way to insert a separator above a totals row.
hline_top() — top border of a part
hline_top() draws a line at the very top of a table part:
hline_bottom() — bottom border of a part
hline_bottom() draws a line at the very bottom of a table part:
Column-level vertical lines
vline() — vertical line to the right of selected columns
vline() draws a line to the right of each selected column j. It sets the right border of column j and the left border of column j + 1:
vline_left() and vline_right() — outer vertical edges
Highlighting individual cells with surround()
surround() draws borders around specific cells without affecting the rest of the table:
Fixing border rendering issues
fix_border_issues() corrects a rendering artifact where adjacent cells from different table parts display doubled or mismatched borders in some output formats:
fix_border_issues() automatically. Call it explicitly only when you build a border scheme manually.
Building a custom border scheme
Quick reference
| Function | What it does |
|---|---|
border_remove(x) | Remove all borders from all parts |
border_outer(x, border, part) | Set outer (perimeter) borders of a part |
border_inner_h(x, border, part) | Set inner horizontal borders |
border_inner_v(x, border, part) | Set inner vertical borders |
border_inner(x, border, part) | Set all inner borders |
hline(x, i, border, part) | Horizontal line below selected rows |
hline_top(x, border, part) | Top border of a part |
hline_bottom(x, border, part) | Bottom border of a part |
vline(x, j, border, part) | Vertical line to the right of selected columns |
vline_left(x, border, part) | Left edge of the table |
vline_right(x, border, part) | Right edge of the table |
surround(x, i, j, border.*, part) | Borders around individual cells |
fix_border_issues(x) | Correct rendering artifacts at part boundaries |