Draw a styled multilingual label

markup_grob.RdMarkdown supports emphasis, paragraphs, inline code and line breaks. Inline b, i, strong, em, u, s, del, code, sup, sub, br and span tags are supported. Spans accept color (hex), font-family (a local family), font-size (pt), font-weight (normal or bold), font-style and text-decoration (none, underline or line-through). Images, links and external resources are rejected. Paint changes preserve whole-paragraph shaping. A colour change within one ligature uses the colour at its first source character.
Usage
markup_grob(
label,
format = c("markdown", "plain", "mixed"),
x = 0.5,
y = 0.5,
width = NULL,
hjust = 0.5,
vjust = 0.5,
align = "left",
angle = 0,
family = "sans",
size = 12,
colour = "black",
face = "plain",
lineheight = 1.15,
lang = NULL,
text_direction = "auto",
padding = grid::unit(0, "pt"),
fill = NA,
border = NA,
radius = grid::unit(0, "pt"),
paragraph_spacing = 0
)Arguments
- label
One character string. For formulas use one plotmath string or a length-one expression.
- format
Input grammar. Use
"plain"for literal text,"markdown"for the documented markup subset, or"mixed"for markup with plotmath. In mixed mode a matched pair of single dollar signs encloses an inline expression. A display expression occupies its own block.- x, y
Position in grid units, or a number in normalized parent units.
- width
Optional scalar grid unit for language-aware line wrapping.
- hjust, vjust
Numeric horizontal and vertical anchor. Zero and one select opposite edges. Values outside this interval provide extra offset.
- align
Alignment of lines, one of left, center and right.
- angle
Counterclockwise rotation in degrees.
- family
Local font family. Generic sans, serif and mono are supported.
- size
Font size in big points (1/72 inch).
- colour
Foreground colour.
- face
One of plain, bold, italic or bold.italic.
- lineheight
Positive line-height multiplier.
- lang
Optional ICU locale or BCP 47 language tag for line breaks.
- text_direction
Base reading direction, auto, ltr or rtl.
- padding
A scalar grid unit or four units in top, right, bottom, left order.
- fill, border
Background and border colours. NA leaves them transparent.
- radius
A scalar nonnegative grid unit for corner rounding.
- paragraph_spacing
Additional space between paragraphs, in big points.
Details
The device must support positioned glyphs. Examples include ragg PNG and R Cairo PDF and SVG. Text and font fallback depend on the local fonts. A width includes the horizontal padding. An indivisible segment wider than the requested width keeps its natural width and produces a warning. Lao, Thai, Khmer and Myanmar use ICU root line-break rules with script-selected dictionaries. Other supplied locales request ICU tailoring.
Examples
note <- markup_grob("One **estimate** per group", width = grid::unit(36, "mm"))
grid::grobWidth(note)
#> [1] 1grobwidth
estimate <- markup_grob("Mean $frac(sum(x[i], i == 1, n), n)$", format = "mixed")
grid::grobHeight(estimate)
#> [1] 1grobheight