I am trying to create a ggplot2 figure with two captions, one left-aligned and one right-aligned. This works properly when using element_text() in theme() to format the figures.
ggplot(mtcars) +
aes(x=cyl, y=disp) +
geom_point() +
labs(caption=c("First caption here","Second caption here")) +
theme(plot.caption=element_text(hjust=c(0,1)))
When I attempt to replicate this with element_markdown() from the ggtext package instead of element_text(), it does not place the captions properly.
ggplot(mtcars) +
aes(x=cyl, y=disp) +
geom_point() +
labs(caption=c("First caption here","Second caption here")) +
theme(plot.caption=element_markdown(hjust=c(0,1)))
Ideally, I'd like to use element_markdown() because it would allow more formatting options in the captions (bolding text, including images, etc). I'd greatly appreciate any advice on how to troubleshoot this. Thank you!


I am unsure why this is not working the same way but you could simply change the hjust to a more extreme value. It will be harder to get exactly right but should work.