I'm creating an rmarkdown report and wanted to know if there is a way of specify a list of words that should be bolded or colored throughout the document. For example, I found this function that I can use to highlight certain words red .
This goes in a code chunk -
colorize <- function(x, color) {
if (knitr::is_latex_output()) {
sprintf("\\textcolor{%s}{%s}", color, x)
} else if (knitr::is_html_output()) {
sprintf("<span style='color: %s;'>%s</span>", color,
x)
} else x
}
When I type This word is `r colorize("red", "red")
and knit the document, the word "red" comes out in red text.
Is there a way to specify about 10 words that I want to appear in red text without having to type r colorize("word", "red")
each time I type the word.