Adding colour to text output in R Markdown to docx output


Trying to print coloured text from Markdown into a docx output.

It's easy in a table, etc. However, can't format inline.

I've tried $\color{red}{\text{Text to format}}$ and the Crayon library, however, neither seems to work for docx output.

The LaTeX markup won't work for a Word doc.

First, if you aren't aware already, check out the documentation to support special styling for Word docx outputwith R Markdown: Word Documents with R Markdown, also Happy collaboration with Rmd to docx.

Have you read this discussion?

Their advice worked for me on a Rmd doc to docx, though I'll note, word didn't like me using hyphens or spaces in my new style name.

1 Like