R: Combine expression,atop and line break

Viewed 35

Do you have any idea how to combine multiple lines with expression and atop? I Mean I use this:

library(Gmisc)
library(glue)
box <- boxGrob(expr(atop(bold("1. My First Step"), italic("This is a very long text that needs \n a line break"))))

This results in

enter image description here

1 Answers

To fix the overlapping lines, you could use glue like this:

library(Gmisc)
library(glue)
boxGrob(glue("1. My First Step",
             "This is a very long text that needs \n a line break",
             tot = 30,
             uninterested = 12,
             contra = 30 - 12,
             .sep = "\n"),
        just = "left")

Created on 2022-07-15 by the reprex package (v2.0.1)

I am only not sure how to implement bold and italic in this.

Related