Created
September 16, 2016 06:35
-
-
Save koncina/c205af6bd80d7f59c3557345e8121195 to your computer and use it in GitHub Desktop.
Color text for Pdf or Html output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From http://stackoverflow.com/a/37122306 | |
txtcol <- function(x, color) { | |
outputFormat = knitr::opts_knit$get("rmarkdown.pandoc.to") | |
if (outputFormat == 'latex') | |
paste("\\textcolor{", color, "}{", x, "}", sep = "") | |
else if (outputFormat == 'html') | |
paste("<font color='", color, "'>", x, "</font>", sep = "") | |
else | |
x | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment