Text coloring

To add color you can use CSS or R code like this:

color_text <- function(x, color){
  if(knitr::is_latex_output())
    paste("\\textcolor{",color,"}{",x,"}",sep="")
  else if(knitr::is_html_output())
    paste("<font color='",color,"'>",x,"</font>",sep="")
  else
    x
}

red <- function(x){
  if(knitr::is_latex_output())
    paste("\\textcolor{",'red',"}{",x,"}",sep="")
  else if(knitr::is_html_output())
    paste("<font color='red'>",x,"</font>",sep="")
  else
    x
}

The strng This is colored with the red function comes from:

`r red("This is colored with the red function")`

The string This is colored with the color_text function set to mauve comes from:

`r color_text("This is colored with the color_text function set to mauve", "#E0B0FF")`