With Tikz, I can specify that my tree nodes use a gradient fill by specifying the top and bottom colours, using something like this:

\begin{tikzpicture}[every node/.style = {shape=rectangle, rounded corners, draw, align=center, top color=white, bottom color=aubergine!20}]]
  \node {$a$};

I would like to use a similar fill for the nodes in a diagram I have created with the forest package.

I can use a solid colour by setting the fill option in the before typesetting nodes part of the diagram definition but I cannot see a way to specify a gradient fill:

  before typesetting nodes={for tree={draw, fill=aubergine!20}},

Is it possible?


I don't see any problem using top color and bottom color:


  before typesetting nodes={for tree={draw, top color=red!20, bottom color=red!80}},

enter image description here

  • I didn't think to try that, but in hindsight I guess it was slightly obvious. Thanks! – Adam Williams Mar 2 '17 at 12:06
  • 1
    @AdamWilliams You don't need before typesetting nodes here. Just for tree={...} will do. (This will be slightly quicker.) – cfr Mar 3 '17 at 2:52

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.