I'm looking for the best way to define a new colour in LaTeX using the different methods above. In xcolor.sty, I have


And in svgnam.def I have


I want to define a new colour LightBlue directly in my document, but the following R code does not work. Since the white text shows up where it is supposed to, the error must be in the definition of LightBlue:


temp<-read.table(text=paste("Action      Weight
                      1  Addition     1
                      2  Deletion     2
                      3  UpWeight     3 
                      4  DownWeight   4",sep=""),header=TRUE)

for(i in 1:nrow(temp)){
      temp[,1:ncol(temp)]<-"{\\cellcolor{LightBlue}\\textcolor{white}{  }}"
      temp[,2]<-paste0("{\\cellcolor{LightBlue}\\textcolor{white}{to test}}")

So my questions are:

  1. Is there an error in my current definition?
  2. Should I directly define LightBlue in svgnam.def to avoid converting to the four different colour schemes in xcolor.sty?
  3. Does {RGB} use a scale from 0 to 255 while {rgb} goes from 0 to 1? If so, would the conversion to {rgb} be as easy as dividing each {RGB} value by 255?

Thank you!

  • 1
    You've called the colour RBCLightBlue – Joseph Wright Jun 22 '17 at 14:39
  • Oops, it's defined as LightBlue in the document but I copied the wrong line over in my minimal example- thanks for the catch! – Anna Jun 22 '17 at 14:40
  • @Anna What error message do you get? – samcarter_is_at_topanswers.xyz Jun 22 '17 at 14:42
  • I don't get an error message, but I get the text "LightBlue" in the cell where is it supposed to be coloured LightBlue instead. For the text "to test", it correctly shows up in white. – Anna Jun 22 '17 at 14:44
  • 1
    You should first get it working in a latex document without R and once that is working you can check the R code is generating the correct tex. – David Carlisle Jun 22 '17 at 18:49

For closure, I reinstalled the xcolor package, deleted extra calls of \usepackage, and the combination of the two seemed to work

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.