I have an R Markdown document that I've been rendering to Word as part of a weekly report for a few years now. I just updated packages and now a ggtitle with some inline HTML styling is rendering as plain text.
Here is a simpler example of what I am trying to do:
(EDIT to add that I had been using ggtext also)
library(tidyverse)
library(ggtext)
a_number <- 1024
ggplot(mtcars, aes(mpg, wt, colour = cyl)) +
geom_point() +
theme(plot.title = element_markdown()) +
ggtitle(paste0("This is my red number: ",
"<span style=color:'#e15759'>",
a_number,
"</span>."))
My mistake, I went back to my original and realized I had also been using ggtext already, I just didn't include it in this example. I've edited to add that part in.
Having done so now the closing '</span>' tag disappears, but still not the right behavior. Really odd.
Does the problem only occur when exporting to Word? Have you tried in html for example? If you just run the chunk without compiling the document, is the title rendered correctly in the preview?