Change background of rectangle without inner elements
Change background of rectangle without inner elements
I have concatenated rectangles like so:
usetikzlibraryfit, positioning
begintikzpicture
node [rectangle, draw, text width=4em, fill=white] (b) B;
node [rectangle, draw, text width=4em, right=of b, fill=white] (a) A;
node [rectangle, draw, fit=(b) (a), fill=orange, fill opacity=0.1] (local) ;
endtikzpicture
The result of the above is this:
My problem is that I do not want inner boxes A & B to have the orange background (i.e. they should not be coloured..). How can I fix this please? (still new to Tikz!)
fill=white
node [rectangle, draw,text width=4em,fill=white] (b) B;
Thank you, no it does not work. I think because the last fill is overriding previous ones.. I have updated my code above to reflect this..
– ojenn
Sep 3 at 17:34
1 Answer
1
Too long for a comment.
documentclass[tikz,border=3.14mm]standalone
begindocument
usetikzlibraryfit, positioning,backgrounds
begintikzpicture
node [rectangle, draw,text width=4em,fill=white] (b) B;
node [rectangle, draw,text width=4em, right=of b,fill=white] (a) A;
beginscope[on background layer]
node [rectangle, draw, fit=(b) (a),fill=orange,fill opacity=0.1] (local) ;
endscope
endtikzpicture
enddocument
Of course. It was just asking me to wait..
– ojenn
Sep 3 at 17:54
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Welcome to TeX.SE! Does adding
fill=white
to the inner nodes do what you want?node [rectangle, draw,text width=4em,fill=white] (b) B;
and then fill the big node on the background layer.– marmot
Sep 3 at 17:32