1

So I have the following Tikzcd diagram and I am trying to place a Y in the center of the triangle W, (X x Y), X or the triangle W, (X x Y), (X x Y) x Z

\begin{equation*}
\begin{tikzcd}[column sep=large, row sep=large]
    X
    &
    & W 
        \ar[lldd, "(f'\times g')" description, dashed]  
        \ar[dd, "(f'\times g')\times g" description, dashed]
        \ar[rdd, "g"]
        \ar[ll, "f'"']
    & 
\\
    &Y
    &Y
    &
\\
    (X\times Y) 
        \ar[uu, "\pi_X"]
    &
    & (X\times Y)\times Z 
        \ar[ll, "p_{X\times Y}"]
        \ar[r, "p_Z"']
    & Z
\end{tikzcd}
\end{equation*}

enter image description here

I have tried adding more rows and columns. But it seems that tikz-cd makes it so that the column spacing isn't uniform, it takes way too many rows and columns to be practical. What is the best way to fix this?

1 Answer 1

3

You can remember the nodes and use an overlay to draw the desired nodes at the barycenters of the triangles.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\begin{equation*}
\begin{tikzcd}[column sep=large, row sep=large,remember picture]
    |[alias=X]| X
    &
    & |[alias=W]| W 
        \ar[lldd, "(f'\times g')" description, dashed]  
        \ar[dd, "(f'\times g')\times g" description, dashed]
        \ar[rdd, "g"]
        \ar[ll, "f'"']
    & 
\\
    &Y
    &Y
    &
\\
    |[alias=XxY]| (X\times Y) 
        \ar[uu, "\pi_X"]
    &
    & |[alias=XxYxZ]| (X\times Y)\times Z 
        \ar[ll, "p_{X\times Y}"]
        \ar[r, "p_Z"']
    & Z
\end{tikzcd}
\tikz[overlay,remember picture]{%
\node (Y1) at (barycentric cs:X=1,W=1,XxY=1) {$Y$};
\draw[->] (Y1) -- (W);\draw[->] (Y1) -- (XxY);
\node (Y2) at (barycentric cs:XxYxZ=1,W=1,XxY=1) {$Y$};
\draw[->] (Y2) -- (W);\draw[->] (Y2) -- (XxY);
}
\end{equation*}
\end{document}

enter image description here

By increasing the coefficients of X or XxYxZ you may move the node a bit more towards the rectangular corners.

UPDATE: Added connecting arrows, probably too many but it should be obvious which ones to remove.

2
  • Thanks. I know this wasn't in my original question, but is there a way to connect Y to W and (X x Y) via arrows using this method? Feb 22, 2018 at 15:46
  • 1
    @WilliamOliver Done
    – user121799
    Feb 22, 2018 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .