TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am just trying to get a rounded corner box with some text in it. The text color will be white and the box will be filled with a particular color.

The preamble includes:


The code I have used is:

\node[drop shadow,fill=black,draw,rounded corners]

How can I specify an arbitrary color (RGB values in a range of 0-255) in the fill option?

Also, am I using too advanced a tool (tikz) to do something simple (draw a rounded corner rectangle filled with a color and text of some other color)?

share|improve this question
Welcome to TeX.sx! – Martin Scharrer Jul 29 '11 at 18:12

In answer to your first question - mixing colours in (say) RGB format - you could use the notation similar to that specified in the xcolor package documentation, since TikZ recognizes this. For example, mixing/sharing proportions of black green is obtained using


and displays

Nodes with different colour fills (sharing between black and green)

Or, if you're interested in mixing certain quantities of RGB colours, you can use a part-wise mix as follows:


which outputs

Part-wise mix of colours

For answering your second question - dealing with boxes - you can use the fancybox package or even PStricks. Here is an example using the latter:


PStricks rounded/coloured boxes

share|improve this answer
Cool, I didn't know before about the rgb:... syntax! – Daniel Jul 2 '12 at 21:24

One approach is to predefine in the preamble all colors one wants to use, for instance


with values in the interval (0,1) or


with integer values in the range 0–255 (use a more sensible name than mycolor) and then mycolor can be used in all color specifications, for instance

\node[drop shadow,fill=mycolor,draw,rounded corners]

In this way you can control the colors and also change them just by modifying their definition.

share|improve this answer
It is also possible to define the colors right before you use them. You can even redefine them later if you want to use different values for them. I did that once when I was generating a plot with a lot of different colors in it. I have created a new answer for this alternative approach. – StrawberryFieldsForever Aug 4 '12 at 0:38
@StrawberryFieldsForever I don't think that changing the meaning of a color name is a good way to proceed. – egreg Aug 4 '12 at 11:08
Why not? It will be like any other variable. Of course you shouldn't call the color "red" or something like that if you intend to change its value because you would expect that color to be constant, but if you call it "mycolor" or "tempcolor" I see no problem with it. – StrawberryFieldsForever Aug 4 '12 at 15:07

Another approach, that builds on egregs answer, is to predefine the color one wants to use right before it is used. In that way one doesn't have to be so creative when coming up with the names for all colors, which is especially cumbersome if a lot of different colors have to be defined. The color can then be used in all color specifications (just like colors defined in the preamble), for instance

\node[drop shadow,fill=tempcolor,draw,rounded corners]

with values in the interval (0,1) or

\node[drop shadow,fill=tempcolor,draw,rounded corners]

with integer values in the range 0–255 (the name "tempcolor" is just a suggestion).

If you want to make sure you're not overriding any earlier defined color named tempcolor, you can always define the color in a separate scope:

    \node[drop shadow,fill=tempcolor,draw,rounded corners]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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