# Tikz-cd with two baselines

I have a commutative diagram created using tikz-cd. I have always used the baseline optional argument to get punctuation to follow the diagram in a reasonable way. However, I now want to give the diagram an equation number, and I've just discovered that it misplaces the number! How can we have have Tikz use different baselines for these two purposes? \documentclass[preview]{standalone}
\usepackage{tikz-cd}
\begin{document}

How I normally use the baseline.  To get the punctation to follow the diagram, I do
$\begin{tikzcd}[baseline=(W.base)] X \ar[d] \ar[r] & Y \ar[d] \\ Z \ar[r] & |[alias=W]| W \end{tikzcd}.$

But now if I want to number the diagram as well, I get
\begin{equation}
\begin{tikzcd}[baseline=(W.base)]
X \ar[d] \ar[r] & Y \ar[d] \\
Z \ar[r] & |[alias=W]| W
\end{tikzcd}.
\end{equation}
But I want the equation number positioned as in
\begin{equation}
\begin{tikzcd}
X \ar[d] \ar[r] & Y \ar[d] \\
Z \ar[r] & |[alias=W]| W
\end{tikzcd}.
\end{equation}

\end{document}


One note, I would like this to work in amsart, which does some things to the positioning of equation numbers.

• I normally ass the period inside the diagram, as in W \rlap{\ .}, using \rlap such that the space and the period does not affect the alignment of the W, and then drop the baseline – daleif Apr 23 '18 at 9:36
• Well, you might incorporate the full stop to the diagram , but honestly, I think that for a diagram, it would be better-looking without a full stop. – Bernard Apr 23 '18 at 9:37
• @daleif This is exactly the reason I resorted to the baseline change in the first place... so I think you've solved my problem. – Corey Harris Apr 23 '18 at 9:52
• You can integrate the dot inside the diagram by replacing alias=W with label=right:.. – Kpym Apr 23 '18 at 9:54

W \rlap{ .}

in the last entry in the diagram to add something after the W in a manner that does not affect the alignment in the diagram.