# Filling of diagrams using tikzcd

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.

• Please add the complete code of a small document that shows what you have tried and that produces the errors that you mention in your post. As you surely know as an experienced member of this community, an MWE helps us to help you. – gernot Mar 23 '17 at 18:01

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}


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.

\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}