Add line breaks to get prettier captions
Usage
addLineBreakToCaption(
captions,
maxLines = reEnv$maxLinesPerLegendCaption,
width = reEnv$maxWidthPerLegendCaption
)
Examples
# Use cat to display result of line break character
cat(addLineBreakToCaption("this-is-a-long-sentence-with-dashes", maxLines = 2, width = 25))
#> this-is-a-long-
#> sentence-with-dashes
cat(addLineBreakToCaption("this is a sentence with spaces", maxLines = 2, width = 25))
#> this is a sentence
#> with spaces
cat(addLineBreakToCaption(
"this_is_a_long_sentence_without_preferential_splits",
maxLines = 2, width = 25
))
#> this_is_a_long_sentence_w
#> ithout_preferential_splits
cat(addLineBreakToCaption("this too short to split", maxLines = 3, width = 40))
#> this too short to split
cat(addLineBreakToCaption("this forces the sentence to use one line", maxLines = 1, width = 5))
#> this forces the sentence to use one line