2

I have the following diagram,

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

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.

1

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

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

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{fit, patterns}

\begin{document}
    \[
    \begin{tikzcd}[remember picture, overlay, ampersand replacement=\&]
    x \arrow[rr] \arrow[dr] \&  \& y \arrow[dl]  \\ 
    \& z \&   \\
    \end{tikzcd}
    \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)}
            ] 
        {};
    }
    \]
\end{document}

enter image description here

3

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

\documentclass[border=5mm]{standalone}
\usepackage{tikz-cd}
\usetikzlibrary{patterns,backgrounds}
\begin{document}

\begin{tikzcd}[
  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 \&   
\end{tikzcd}
\end{document} 

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.