I have the following diagram,

\begin{tikzcd}[ampersand replacement=\&]
   x \arrow[rr] \arrow[dr] \&  \& y \arrow[dl]  \\ 
    \& z \&   \\

and I would like to use,

\fill[pattern=north east lines, pattern color=blue],

to fill it with that pattern. What is the correct way of doing this? I am just getting errors everytime that I try this.


I think it's ugly-looking, however, if this is what you want...

You can use the fit library and remember picture, overlay:

\usetikzlibrary{fit, patterns}

    \begin{tikzcd}[remember picture, overlay, ampersand replacement=\&]
    x \arrow[rr] \arrow[dr] \&  \& y \arrow[dl]  \\ 
    \& z \&   \\
    \tikz[remember picture, overlay]{
        \node[rectangle, draw, blue,
                pattern=north east lines, pattern color=blue,
                fit={(tikz@f@1-1-1) (tikz@f@1-1-3)  (tikz@f@1-2-2)}

enter image description here


I could be tempted to close as duplicate of the question you referred to in the first question you posted about this: tikz-cd: Shade faces of commutative cube

This is basically the same as what is described in the last part of Gonzalo's answer, but using your \fill command instead.

enter image description here


  ampersand replacement=\&,
  execute at end picture={
    \scoped[on background layer]
    \fill[pattern=north east lines, pattern color=blue] (a.center) -- (b.center) -- (c.center) -- cycle;
   |[alias=a]|x \arrow[rr] \arrow[dr] \&  \& |[alias=b]|y \arrow[dl]  \\ 
    \& |[alias=c]|z \&   

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.