Skip to contents

Helper function for adjusting paragraph margins for use with ggtext/gridtext, which does not natively support margin/padding styles.

Usage

zerowidth_char(size = 12, units = "px")

Arguments

size

Size of the zero-width character

units

Defaults to "px"

Value

A string

Details

The zero-width unicode character only ever takes up vertical space, so when placed in-line its size determines the amount of "top-margins" for the paragraph. This allows finer control over spacing.

Examples

# \dontrun{
library(ggtext)

ggplot() +
  geom_richtext(aes(0, 0, label = "This is a line<br><br>This is a paragraph<br>of text."))


ggplot() +
  geom_richtext(aes(0, 0, label = paste0(
    "This is a line<br>",
    zerowidth_char(30),
    "This is a paragraph<br>of text."
  )))
#> Warning: unable to translate '<U+200B>agg_png122.5' to native encoding
#> Warning: unable to translate '<U+200B>agg_png122.5' to native encoding

# }